Advertisement
Guest User

Untitled

a guest
Feb 26th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3. namespace TMS\OpenBundle\Tests\Controller;
  4.  
  5. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  6.  
  7. class DefaultControllerTest extends WebTestCase {
  8.  
  9.     /**
  10.      * @var \Doctrine\ORM\EntityManager
  11.      */
  12.     private $em;
  13.  
  14.     /**
  15.      * {@inheritDoc}
  16.      */
  17.     public function setUp() {
  18.         static::$kernel = static::createKernel();
  19.         static::$kernel->boot();
  20.         $this->em = static::$kernel->getContainer()
  21.                 ->get('doctrine')
  22.                 ->getManager()
  23.         ;
  24.         $f = $this->em->getFilters()->enable('is_active');
  25.         $f->setParameter('is_active', true);
  26.  
  27.         $childRecord = new \TMS\OpenBundle\Entity\ChildClass();
  28.         $childRecord->setIsActive(false);
  29.         $this->em->persist($childRecord);
  30.         $this->em->flush();
  31.  
  32.         $assocClass = new \TMS\OpenBundle\Entity\AssocClass();
  33.         $assocClass->setChild($childRecord);
  34.         $this->em->persist($assocClass);
  35.         $this->em->flush();
  36.         $this->em->clear();
  37.     }
  38.  
  39.     public function testSearchByCategoryName() {
  40.         $q = 'SELECT a,child FROM TMSOpenBundle:AssocClass a JOIN a.child child';
  41.  
  42.         $q = $this->em->createQuery($q);
  43.         $records = $q->getResult();
  44.  
  45.         $this->assertCount(0, $records);
  46.     }
  47.  
  48.     /**
  49.      * {@inheritDoc}
  50.      */
  51.     protected function tearDown() {
  52.         parent::tearDown();
  53.         $this->em->close();
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement