本文整理汇总了PHP中Symfony\Bridge\Doctrine\Test\DoctrineTestHelper::createTestEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP DoctrineTestHelper::createTestEntityManager方法的具体用法?PHP DoctrineTestHelper::createTestEntityManager怎么用?PHP DoctrineTestHelper::createTestEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bridge\Doctrine\Test\DoctrineTestHelper
的用法示例。
在下文中一共展示了DoctrineTestHelper::createTestEntityManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
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: setUp
protected function setUp()
{
$this->em = DoctrineTestHelper::createTestEntityManager();
$this->registry = $this->createRegistryMock($this->em);
$this->createSchema($this->em);
parent::setUp();
}
示例3: setUp
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: setUp
/**
* 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: setUp
/**
* {@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: setUp
/**
* {@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: setUp
/**
* {@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: setUp
/**
* {@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: setUp
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: testFilterNonIntegerValues
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: testSupportProxy
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: setUp
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: setUp
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: testEmbeddedIdentifierName
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: setUp
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) {
}
}