protected function setUp()
 {
     parent::setUp();
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->emRegistry = $this->createRegistryMock('default', $this->em);
     $this->items = array();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::SINGLE_INT_ID_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $this->createEntities();
     $this->factory = Forms::createFormFactoryBuilder()->addExtensions($this->getExtensions())->addTypeExtension(new ChoiceSelect2TypeExtension($this->dispatcher, $this->requestStack, $this->router, $this->getExtensionTypeName(), 10))->addType(new EntityType($this->emRegistry))->addTypeExtension(new EntitySelect2TypeExtension())->getFormFactory();
     $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
 }
コード例 #2
0
 protected function setUp()
 {
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->registry = $this->createRegistryMock($this->em);
     $this->createSchema($this->em);
     parent::setUp();
 }
コード例 #3
0
 protected function setUp()
 {
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->emRegistry = $this->createRegistryMock('default', $this->em);
     parent::setUp();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
 }
コード例 #4
0
 /**
  * Test setup
  */
 protected function setUp()
 {
     // setup entity aliases
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $entityManagerNamespaces = $this->em->getConfiguration()->getEntityNamespaces();
     $entityManagerNamespaces['WebtownPhpBannerBundle'] = 'WebtownPhp\\BannerBundle\\Entity';
     $this->em->getConfiguration()->setEntityNamespaces($entityManagerNamespaces);
     // setup schema
     $schemaTool = new SchemaTool($this->em);
     $classes = [];
     foreach ($this->getEntities() as $entityClass) {
         $classes[] = $this->em->getClassMetadata($entityClass);
     }
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $registry = \Mockery::mock('Doctrine\\Bundle\\DoctrineBundle\\Registry');
     $registry->shouldReceive('getManager')->andReturn($this->em);
     $this->bm = new ORMManager($registry, new EventDispatcher());
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     self::bootKernel();
     $this->entityClass = 'Fidry\\LoopBackApiBundle\\Tests\\Functional\\Bundle\\TestBundle\\Entity\\Dummy';
     $this->managerRegistry = self::$kernel->getContainer()->get('doctrine');
     $this->repository = DoctrineTestHelper::createTestEntityManager()->getRepository($this->entityClass);
     $this->resource = new Resource($this->entityClass);
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     self::bootKernel();
     $manager = DoctrineTestHelper::createTestEntityManager();
     $this->managerRegistry = self::$kernel->getContainer()->get('doctrine');
     $this->repository = $manager->getRepository(Dummy::class);
     $this->resourceClass = Dummy::class;
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     self::bootKernel();
     $class = 'Dunglas\\ApiBundle\\Tests\\Behat\\TestBundle\\Entity\\Dummy';
     $manager = DoctrineTestHelper::createTestEntityManager();
     $this->managerRegistry = self::$kernel->getContainer()->get('doctrine');
     $this->repository = $manager->getRepository($class);
     $this->resource = new Resource($class);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     self::bootKernel();
     $manager = DoctrineTestHelper::createTestEntityManager();
     $this->managerRegistry = self::$kernel->getContainer()->get('doctrine');
     $this->iriConverter = self::$kernel->getContainer()->get('api_platform.iri_converter');
     $this->propertyAccessor = self::$kernel->getContainer()->get('property_accessor');
     $this->repository = $manager->getRepository(Dummy::class);
     $this->resourceClass = Dummy::class;
 }
コード例 #9
0
 protected function setUp()
 {
     $this->repositoryFactory = new TestRepositoryFactory();
     $config = DoctrineTestHelper::createTestConfiguration();
     $config->setRepositoryFactory($this->repositoryFactory);
     $this->em = DoctrineTestHelper::createTestEntityManager($config);
     $this->registry = $this->createRegistryMock($this->em);
     $this->createSchema($this->em);
     parent::setUp();
 }
コード例 #10
0
 public function testFilterNonIntegerValues()
 {
     $em = DoctrineTestHelper::createTestEntityManager();
     $query = $this->getMockBuilder('QueryMock')->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))->getMock();
     $query->expects($this->once())->method('setParameter')->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2, 3), Connection::PARAM_INT_ARRAY)->willReturn($query);
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setConstructorArgs(array($em))->setMethods(array('getQuery'))->getMock();
     $qb->expects($this->once())->method('getQuery')->willReturn($query);
     $qb->select('e')->from('Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\SingleIntIdEntity', 'e');
     $loader = new ORMQueryBuilderLoader($qb);
     $loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo'));
 }
コード例 #11
0
 public function testSupportProxy()
 {
     $em = DoctrineTestHelper::createTestEntityManager();
     $this->createSchema($em);
     $user1 = new User(1, 1, 'user1');
     $em->persist($user1);
     $em->flush();
     $em->clear();
     $provider = new EntityUserProvider($this->getManager($em), 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\User', 'name');
     $user2 = $em->getReference('Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\User', array('id1' => 1, 'id2' => 1));
     $this->assertTrue($provider->supportsClass(get_class($user2)));
 }
コード例 #12
0
 protected function setUp()
 {
     // Create a test database and table
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\Attachment\\Attachments\\StandardAttachment'));
     $schemaTool->createSchema($classes);
     // Prepare to create forms
     $sanitiser = new Sanitiser();
     $pathHelper = new PathHelper($sanitiser, array('Infinite\\FormBundle\\Tests\\Attachment\\Attachments\\StandardAttachment' => array('dir' => sys_get_temp_dir(), 'format' => 'test/{name}')));
     $this->uploader = new Uploader($sanitiser, $pathHelper);
     $this->factory = Forms::createFormFactoryBuilder()->addType(new AttachmentType('foobar', $this->em, $pathHelper, $this->uploader))->getFormFactory();
 }
コード例 #13
0
 protected function setUp()
 {
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::SINGLE_INT_ID_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_ID_CLASS), $this->em->getClassMetadata(self::COMPOSITE_ID_CLASS), $this->em->getClassMetadata(self::GROUPABLE_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     parent::setUp();
 }
コード例 #14
0
 public function testEmbeddedIdentifierName()
 {
     if (Version::compare('2.5.0') > 0) {
         $this->markTestSkipped('Applicable only for Doctrine >= 2.5.0');
         return;
     }
     $em = DoctrineTestHelper::createTestEntityManager();
     $query = $this->getMockBuilder('QueryMock')->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))->getMock();
     $query->expects($this->once())->method('setParameter')->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY)->willReturn($query);
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setConstructorArgs(array($em))->setMethods(array('getQuery'))->getMock();
     $qb->expects($this->once())->method('getQuery')->willReturn($query);
     $qb->select('e')->from('Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\EmbeddedIdentifierEntity', 'e');
     $loader = new ORMQueryBuilderLoader($qb);
     $loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo'));
 }
コード例 #15
0
 protected function setUp()
 {
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->emRegistry = $this->createRegistryMock('default', $this->em);
     parent::setUp();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_NO_TO_STRING_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_ASSOC_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
 }
コード例 #16
0
ファイル: TestBase.php プロジェクト: yavin/symfony-form-tree
 public function setUp()
 {
     $this->checkEnviroment();
     $this->manager = DoctrineTestHelper::createTestEntityManager();
     $this->manager->getEventManager()->addEventSubscriber(new TreeListener());
     $this->managerRegistry = $this->createRegistryMock('default', $this->manager);
     $this->formFactory = $this->createFormFactoryBuilder()->getFormFactory();
     $schemaTool = new SchemaTool($this->manager);
     $classes = array($this->manager->getClassMetadata(self::POST_CLASS), $this->manager->getClassMetadata(self::CATEGORY_CLASS), $this->manager->getClassMetadata(self::SECTION_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
 }
コード例 #17
0
 protected function setUp()
 {
     // Create a test database, tables and a few rows
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\EntitySearch\\Entity\\Fruit'));
     $schemaTool->createSchema($classes);
     foreach (explode(' ', 'apple avocado banana durian orange pineapple') as $fruitName) {
         $fruit = new Fruit();
         $fruit->name = $fruitName;
         $this->em->persist($fruit);
     }
     $this->em->flush();
     $this->emRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->emRegistry->expects($this->once())->method('getManagerForClass')->with($this->equalTo('Infinite\\FormBundle\\Tests\\EntitySearch\\Entity\\Fruit'))->will($this->returnValue($this->em));
     // Prepare to create forms
     $this->factory = Forms::createFormFactoryBuilder()->addType(new EntitySearchType(new EntitySearchTransformerFactory($this->emRegistry)))->getFormFactory();
 }
コード例 #18
0
 protected function setUp()
 {
     // Create a test database, tables and a few rows
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\CheckboxGrid\\Entity\\Area'), $this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\CheckboxGrid\\Entity\\Product'), $this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\CheckboxGrid\\Entity\\Salesman'), $this->em->getClassMetadata('Infinite\\FormBundle\\Tests\\CheckboxGrid\\Entity\\SalesmanProductArea'));
     $schemaTool->createSchema($classes);
     // The area/product arrays are keyed by their IDs
     $this->areas = array(1 => new TestEntity\Area('North side'), 2 => new TestEntity\Area('East side'), 3 => new TestEntity\Area('Inner north'), 4 => new TestEntity\Area('Inner south'));
     $this->products = array(1 => new TestEntity\Product('Chair'), 2 => new TestEntity\Product('Desk'), 3 => new TestEntity\Product('Table'));
     foreach ($this->areas as $area) {
         $this->em->persist($area);
     }
     foreach ($this->products as $product) {
         $this->em->persist($product);
     }
     $this->em->flush();
     // This mock registry returns the real entity manager created above
     $this->emRegistry = $emRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->factory = Forms::createFormFactoryBuilder()->addType(new CheckboxGridType())->addType(new CheckboxRowType())->addType(new EntityCheckboxGridType($emRegistry))->addType(new SalesmanType())->getFormFactory();
 }
 protected function setUp()
 {
     $this->em = DoctrineTestHelper::createTestEntityManager();
     parent::setUp();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata(self::ENTITY_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $ids = range(1, 300);
     foreach ($ids as $id) {
         $name = 65 + chr($id % 57);
         $this->em->persist(new SingleIntIdEntity($id, $name));
     }
     $this->em->flush();
 }
コード例 #20
0
 protected function setUp()
 {
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = $this->getClassesMetadata();
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     list($this->obj1, $this->obj2, $this->obj3, $this->obj4) = $this->createObjects();
     $this->em->persist($this->obj1);
     $this->em->persist($this->obj2);
     $this->em->persist($this->obj3);
     $this->em->persist($this->obj4);
     $this->em->flush();
     parent::setUp();
 }
コード例 #21
0
 protected function setUp()
 {
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $this->emRegistry = $this->getEmRegistry($this->em);
     $schemaTool = new SchemaTool($this->em);
     foreach ($this->getUsedEntityFixtures() as $class) {
         $classes[] = $this->em->getClassMetadata($class);
     }
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     parent::setUp();
     $formExtensions = array(new DoctrineOrmExtension($this->emRegistry));
     $formRegistry = new FormRegistry($formExtensions, $this->getMock('Symfony\\Component\\Form\\ResolvedFormTypeFactory'));
     $translationForm = new \A2lix\TranslationFormBundle\TranslationForm\TranslationForm($formRegistry, $this->emRegistry);
     $translationsListener = new \A2lix\TranslationFormBundle\Form\EventListener\TranslationsListener($translationForm);
     $translationsFormsListener = new \A2lix\TranslationFormBundle\Form\EventListener\TranslationsFormsListener();
     $this->factory = Forms::createFormFactoryBuilder()->addExtensions($formExtensions)->addTypeExtension(new FormTypeValidatorExtension($this->getMock('Symfony\\Component\\Validator\\ValidatorInterface')))->addTypeGuesser($this->getMockBuilder('Symfony\\Component\\Form\\Extension\\Validator\\ValidatorTypeGuesser')->disableOriginalConstructor()->getMock())->addTypes(array(new \A2lix\TranslationFormBundle\Form\Type\TranslationsType($translationsListener, array('fr', 'en', 'de'), 'en'), new \A2lix\TranslationFormBundle\Form\Type\TranslationsFieldsType(), new \A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType($translationForm, $translationsFormsListener, array('fr', 'en', 'de'), 'en')))->getFormFactory();
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
 }
コード例 #22
0
 /**
  * @group GH-1635
  */
 public function testAssociatedCompositeEntity()
 {
     $entityManagerName = "foo";
     $em = DoctrineTestHelper::createTestEntityManager();
     $this->createSchema($em);
     $validator = $this->createValidator($entityManagerName, $em, 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\AssociationEntity', array('composite'));
     $composite = new CompositeIntIdEntity(1, 1, "test");
     $associated = new AssociationEntity();
     $associated->composite = $composite;
     $em->persist($composite);
     $em->persist($associated);
     $em->flush();
     $this->setExpectedException('Symfony\\Component\\Validator\\Exception\\ConstraintDefinitionException', 'Associated entities are not allowed to have more than one identifier field');
     $violationsList = $validator->validate($associated);
 }
 public function testGetSize()
 {
     $em = DoctrineTestHelper::createTestEntityManager();
     $query = $this->getMockBuilder('QueryMock')->setMethods(array('getSingleScalarResult', 'setParameter', 'getResult', 'getSql', '_doExecute'))->getMock();
     $query->expects($this->once())->method('getSingleScalarResult')->willReturn(0);
     /* @var QueryBuilder|\PHPUnit_Framework_MockObject_MockObject $qb */
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setConstructorArgs(array($em))->setMethods(array('getQuery'))->getMock();
     $qb->expects($this->once())->method('getQuery')->willReturn($query);
     $qb->select('e')->from('Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\SingleIntIdEntity', 'e');
     $loader = new AjaxORMQueryBuilderLoader($qb);
     $loader->getSize();
 }
コード例 #24
0
 /**
  * @return EntityManager
  */
 public static function createTestEntityManager()
 {
     return DoctrineTestHelper::createTestEntityManager();
 }
コード例 #25
0
ファイル: UserTypeFilterTest.php プロジェクト: EllynB/Incipio
 /**
  * @return \Doctrine\ORM\QueryBuilder QueryBuilder for filters.
  */
 public function getQueryBuilder()
 {
     return DoctrineTestHelper::createTestEntityManager()->getRepository('ApiBundle\\Entity\\User')->createQueryBuilder('o');
 }
コード例 #26
-1
 protected function setUp()
 {
     if (!class_exists('Symfony\\Component\\Form\\Form')) {
         $this->markTestSkipped('The "Form" component is not available');
     }
     if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
         $this->markTestSkipped('Doctrine DBAL is not available.');
     }
     if (!class_exists('Doctrine\\Common\\Version')) {
         $this->markTestSkipped('Doctrine Common is not available.');
     }
     if (!class_exists('Doctrine\\ORM\\EntityManager')) {
         $this->markTestSkipped('Doctrine ORM is not available.');
     }
     $this->em = DoctrineTestHelper::createTestEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = array($this->em->getClassMetadata($this->getEntityClass()));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     list($this->obj1, $this->obj2, $this->obj3, $this->obj4) = $this->createObjects();
     $this->em->persist($this->obj1);
     $this->em->persist($this->obj2);
     $this->em->persist($this->obj3);
     $this->em->persist($this->obj4);
     $this->em->flush();
     parent::setUp();
 }