Skip to content

Commit

Permalink
#3 sqlite-compatible indexes added
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZ99 committed Dec 12, 2011
1 parent 88eec61 commit be987a9
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 63 deletions.
7 changes: 4 additions & 3 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ swiftmailer:

doctrine:
dbal:
driver: pdo_sqlite
path: :memory:
memory: true
dbname: %database_name%_test
driver: pdo_sqlite
path: :memory:
memory: true
orm:
auto_generate_proxy_classes: true
auto_mapping: true
Expand Down
14 changes: 11 additions & 3 deletions src/Siwapp/CoreBundle/Tests/Model/SiwappBaseTest.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<?php

namespace Siwapp\CoreBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Console\Application;

class SiwappBaseTest extends PHPUnit_Framework_TestCase
class SiwappBaseTest extends \PHPUnit_Framework_TestCase
{
protected $_application;

/**
* @var \Doctrine\ORM\EntityManager
*/
protected $em;

public function setUp()
{
$kernel = new \AppKernel("test", true);
$kernel->boot();
$this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
$this->_application = new Application($kernel);
$this->_application->setAutoExit(false);
$this->runConsole("doctrine:schema:create");
$this->runConsole("doctrine:schema:drop", array("--force" => true));
$this->runConsole("doctrine:schema:create");
$this->runConsole("cache:warmup");
$this->runConsole("doctrine:fixtures:load", array("--fixtures" => __DIR__ . "/../DataFixtures"));
// $this->runConsole("doctrine:fixtures:load", array("--fixtures" => __DIR__ . "/../DataFixtures"));
$this->runConsole("doctrine:fixtures:load");
}

protected function runConsole($command, Array $options = array())
Expand Down
3 changes: 1 addition & 2 deletions src/Siwapp/EstimateBundle/DataFixtures/ORM/LoadEstimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function load($manager)
{

$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/EstimateBundle';
$bpath = $this->container->get('kernel')->getBundle('SiwappEstimateBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/estimates.yml'));

foreach($value['Estimate'] as $ref => $values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function load($manager)

$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/EstimateBundle';
$bpath = $this->container->get('kernel')->getBundle('SiwappEstimateBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/estimates.yml'));

foreach($value['Item'] as $ref => $values)
Expand Down
8 changes: 4 additions & 4 deletions src/Siwapp/EstimateBundle/Entity/Estimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* Siwapp\EstimateBundle\Entity\Estimate
*
* @ORM\Table(indexes={
* @ORM\index(name="cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="cstml_idx", columns={"customer_email"}),
* @ORM\index(name="cntct_idx", columns={"contact_person"})
* @ORM\index(name="estimate_cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="estimate_cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="estimate_cstml_idx", columns={"customer_email"}),
* @ORM\index(name="estimate_cntct_idx", columns={"contact_person"})
* })
* @ORM\Entity(repositoryClass="Siwapp\EstimateBundle\Entity\EstimateRepository")
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Siwapp/EstimateBundle/Entity/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @ORM\Entity
* @ORM\Table(indexes={
* @ORM\index(name="desc_idx", columns={"description"})
* @ORM\index(name="estimate_item_desc_idx", columns={"description"})
* }, name="EstimateItem")
*/
class Item extends AbstractItem
Expand Down
42 changes: 20 additions & 22 deletions src/Siwapp/InvoiceBundle/DataFixtures/ORM/LoadInvoiceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,30 @@ public function setContainer(ContainerInterface $container = null)

public function load($manager)
{

$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/InvoiceBundle';
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/invoices.yml'));

foreach($value['Invoice'] as $ref => $values)
{
$invoice = new Invoice();
foreach($values as $fname => $fvalue)
{
$method = 'set'.Inflector::camelize($fname);
if(is_callable(array($invoice, $method)))
{
call_user_func(array($invoice, $method), $fvalue);
}
}
$manager->persist($invoice);
$manager->flush();
$this->addReference($ref, $invoice);
}
$yaml = new Parser();
$bpath = $this->container->get('kernel')->getBundle('SiwappInvoiceBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/invoices.yml'));

foreach($value['Invoice'] as $ref => $values)
{
$invoice = new Invoice();
foreach($values as $fname => $fvalue)
{
$method = 'set'.Inflector::camelize($fname);
if(is_callable(array($invoice, $method)))
{
call_user_func(array($invoice, $method), $fvalue);
}
}
$manager->persist($invoice);
$manager->flush();
$this->addReference($ref, $invoice);
}

}

public function getOrder()
{
return '2';
return '2';
}
}
2 changes: 1 addition & 1 deletion src/Siwapp/InvoiceBundle/DataFixtures/ORM/LoadItemData.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function load($manager)
{
$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/InvoiceBundle';
$bpath = $this->container->get('kernel')->getBundle('SiwappInvoiceBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/invoices.yml'));
foreach($value['Item'] as $ref => $values)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Siwapp/InvoiceBundle/Entity/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Siwapp\InvoiceBundle\Entity\Invoice
*
* @ORM\Table(indexes={
* @ORM\index(name="cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="cstml_idx", columns={"customer_email"}),
* @ORM\index(name="cntct_idx", columns={"contact_person"})
* @ORM\index(name="invoice_cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="invoice_cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="invoice_cstml_idx", columns={"customer_email"}),
* @ORM\index(name="invoice_cntct_idx", columns={"contact_person"})
* })
* @ORM\Entity(repositoryClass="Siwapp\InvoiceBundle\Repository\InvoiceRepository")
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Siwapp/InvoiceBundle/Entity/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @ORM\Entity
* @ORM\Table(indexes={
* @ORM\index(name="desc_idx", columns={"description"})
* @ORM\index(name="invoice_item_desc_idx", columns={"description"})
* }, name="InvoiceItem")
*/
class Item extends AbstractItem
Expand Down
10 changes: 9 additions & 1 deletion src/Siwapp/InvoiceBundle/Tests/Model/InvoiceTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<?php

use Siwapp\InvoiceBundle\Entity\Invoice;
use Siwapp\CoreBundle\Tests\SiwappBaseTest;
use Symfony\Bundle\FrameworkBundle\Console\Application;

class InvoiceTest extends PHPUnit_Framework_TestCase

class InvoiceTest extends SiwappBaseTest
{
public function testTrial()
{
$inv = new Invoice();
$this->assertEquals(0,0);
$repo = $this->em->getRepository('SiwappInvoiceBundle:Invoice');
foreach($repo->findAll() as $inv)
{
echo $inv;
}
echo "B";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function load($manager)
{

$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/RecurringInvoiceBundle';
$bpath = $this->container->get('kernel')->getBundle('SiwappRecurringInvoiceBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/recurring_invoices.yml'));

foreach($value['Item'] as $ref => $values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ public function load($manager)

$yaml = new Parser();
// TODO: find a way of obtainin Bundle's path with the help of $this->container
$bpath = './src/Siwapp/RecurringInvoiceBundle';
$bpath = $this->container->get('kernel')->getBundle('SiwappRecurringInvoiceBundle')->getPath();
$value = $yaml->parse(file_get_contents($bpath.'/DataFixtures/recurring_invoices.yml'));

foreach($value['RecurringInvoice'] as $ref => $values)
{
$recurring_invoice = new RecurringInvoice();
foreach($values as $fname => $fvalue)
{
$method = 'set'.Inflector::camelize($fname);
if(is_callable(array($recurring_invoice, $method)))
{
call_user_func(array($recurring_invoice, $method), $fvalue);
}
}
$manager->persist($recurring_invoice);
$manager->flush();
$this->addReference($ref, $recurring_invoice);
$recurring_invoice = new RecurringInvoice();
foreach($values as $fname => $fvalue)
{
$method = 'set'.Inflector::camelize($fname);
if(is_callable(array($recurring_invoice, $method)))
{
call_user_func(array($recurring_invoice, $method), $fvalue);
}
}
$manager->persist($recurring_invoice);
$manager->flush();
$this->addReference($ref, $recurring_invoice);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Siwapp/RecurringInvoiceBundle/Entity/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @ORM\Entity
* @ORM\Table(indexes={
* @ORM\index(name="desc_idx", columns={"description"})
* @ORM\index(name="recurring_invoice_item_desc_idx", columns={"description"})
* }, name="RecurringInvoiceItem")
*/
class Item extends AbstractItem
Expand Down
8 changes: 4 additions & 4 deletions src/Siwapp/RecurringInvoiceBundle/Entity/RecurringInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Siwapp\RecurringInvoiceBundle\Entity\RecurringInvoice
*
* @ORM\Table(indexes={
* @ORM\index(name="cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="cstml_idx", columns={"customer_email"}),
* @ORM\index(name="cntct_idx", columns={"contact_person"})
* @ORM\index(name="recurring_cstnm_idx", columns={"customer_name"}),
* @ORM\index(name="recurring_cstid_idx", columns={"customer_identification"}),
* @ORM\index(name="recurring_cstml_idx", columns={"customer_email"}),
* @ORM\index(name="recurring_cntct_idx", columns={"contact_person"})
* })
* @ORM\Entity(repositoryClass="Siwapp\RecurringInvoiceBundle\Entity\RecurringInvoiceRepository")
*/
Expand Down

0 comments on commit be987a9

Please sign in to comment.