protected function setUp()
 {
     parent::setUp();
     // SUT
     $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
     $this->_emMock = EntityManagerMock::create($this->_connectionMock);
 }
Ejemplo n.º 2
0
	public function testPostUpdaetInsert()
	{
		$this->markTestSkipped();
		return;
		$this->assertInstanceOf('Doctrine\Common\EventSubscriber', $this->listener, "instance of Doctrine\\Common\\EventSubscriber");
		$em = \Doctrine\Tests\Mocks\EntityManagerMock::create(new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver));
		$args = new \Doctrine\ORM\Event\OnFlushEventArgs($em);
		$entity = new Versionable\EntityMock;
		$entity->setData("foo");
		$em->persist($entity);

		$this->listener->postUpdate($args);

		$uow = $em->getUnitOfWork();
		$ve = NULL;
		foreach ($uow->getScheduledEntityInsertions() as $ventity) {
			if ($ventity instanceof \Nella\Doctrine\Listeners\VersionEntity) {
				$ve = $ventity;
			}
		}

		$this->assertNotNull($ve, "is existing snapshot");
		$this->assertEquals(get_class($entity), $ve->getEntityClass(), "validate snapshot class");
		$this->assertEquals($entity->takeSnapshot(), $ve->getEntityData(), "validate snapshot data");
	}
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connectionMock = new ConnectionMock(array(), new DriverMock());
     $this->emMock = EntityManagerMock::create($this->connectionMock);
     $this->uowMock = new UnitOfWorkMock($this->emMock);
     $this->emMock->setUnitOfWork($this->uowMock);
     $this->proxyFactory = new ProxyFactory($this->emMock, sys_get_temp_dir(), 'Proxies', true);
 }
Ejemplo n.º 4
0
 protected function setUp()
 {
     parent::setUp();
     $this->_connectionMock = new ConnectionMock(array(), new DriverMock());
     $this->_emMock = EntityManagerMock::create($this->_connectionMock);
     // SUT
     $this->_unitOfWork = new UnitOfWorkMock($this->_emMock);
     $this->_emMock->setUnitOfWork($this->_unitOfWork);
 }
Ejemplo n.º 5
0
 protected function setUp()
 {
     parent::setUp();
     $this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
     $this->_emMock = EntityManagerMock::create($this->_connMock);
     $this->_uowMock = new UnitOfWorkMock($this->_emMock);
     $this->_emMock->setUnitOfWork($this->_uowMock);
     $this->_idGenMock = new SequenceMock($this->_emMock, 'seq', 20);
     //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock);
 }
Ejemplo n.º 6
0
 protected function setUp()
 {
     parent::setUp();
     $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
     $this->_emMock = EntityManagerMock::create($this->_connectionMock);
     $this->_uowMock = new UnitOfWorkMock($this->_emMock);
     $this->_emMock->setUnitOfWork($this->_uowMock);
     // SUT
     $this->_proxyFactory = new ProxyFactory($this->_emMock, __DIR__ . '/generated', 'Proxies', true);
 }
Ejemplo n.º 7
0
	public function setup()
	{
		$container = new \Nette\DI\Container;
		$container->params = array('productionMode' => FALSE, 'appDir' => __DIR__ . "/..");
		$container->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create(
			new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver)
		));
		$container = new \Nella\Doctrine\Container($container);
		$this->service = new Service($container, 'NellaTests\Doctrine\Service\EntityMock');
	}
 public function setUp()
 {
     $em = EntityManagerMock::create(new ConnectionMock([], new DriverMock()));
     $this->qb = $em->createQueryBuilder()->select('p.name, p.price, c.name')->from('Product', 'p')->join('p.category', 'c');
     $this->testObject = new \StdClass();
     $this->testObject->name = 'foobar';
     $this->testObject->price = 2.5;
     $this->testObject->category = new \StdClass();
     $this->testObject->category->name = 'foo';
     $this->dataSource = $this->createDataSourceMock([0 => 'p.name', 1 => 'p.price'], [$this->testObject]);
 }
 protected function _createEntityManager($metadataDriver)
 {
     $driverMock = new DriverMock();
     $config = new \Doctrine\ORM\Configuration();
     $config->setProxyDir(__DIR__ . '/../../Proxies');
     $config->setProxyNamespace('Doctrine\\Tests\\Proxies');
     $eventManager = new EventManager();
     $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager);
     $mockDriver = new MetadataDriverMock();
     $config->setMetadataDriverImpl($metadataDriver);
     return EntityManagerMock::create($conn, $config, $eventManager);
 }
Ejemplo n.º 10
0
 /**
  * Creates an EntityManager for testing purposes.
  *
  * NOTE: The created EntityManager will have its dependant DBAL parts completely
  * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
  * be configured in the tests to simulate the DBAL behavior that is desired
  * for a particular test,
  *
  * @return Doctrine\ORM\EntityManager
  */
 protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true)
 {
     $metadataCache = $withSharedMetadata ? self::getSharedMetadataCacheImpl() : new \Doctrine\Common\Cache\ArrayCache();
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl($metadataCache);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Doctrine\\Tests\\Proxies');
     if ($conn === null) {
         $conn = array('driverClass' => 'Doctrine\\Tests\\Mocks\\DriverMock', 'wrapperClass' => 'Doctrine\\Tests\\Mocks\\ConnectionMock', 'user' => 'john', 'password' => 'wayne');
     }
     if (is_array($conn)) {
         $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
     }
     return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
 }
Ejemplo n.º 11
0
	),
	'database' => array(
		'driver' => "pdo_mysql",
		'memory' => TRUE,
	),
);
$container->addService('cacheStorage', 'Nette\Caching\Storages\DevNullStorage');
$container->addService('templateCacheStorage', function(Nette\DI\Container $container) {
	return $container->cacheStorage;
});
$container->addService('user', 'NellaTests\Mocks\User');
$container->addService('httpRequest', function() {
	$factory = new Nette\Http\RequestFactory;
	$factory->setEncoding('UTF-8');
	return $factory->createHttpRequest();
});
$container->addService('httpResponse', 'Nette\Http\Response');
$container->addService('components', 'Nella\Application\UI\ComponentContainer');
$container->addService('macros', 'Nella\Latte\Macros');
$container->addService('model', function() {
	$context = new \Nella\Doctrine\Container;
	$context->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create(
		new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver)
	));
	return $context;
});
$container->addService('latteEngine', 'Nella\Latte\Engine');

// Set DI Container
Nette\Environment::setContext($container);
Ejemplo n.º 12
0
 protected function setUp()
 {
     parent::setUp();
     $this->_emMock = EntityManagerMock::create(new ConnectionMock([], new DriverMock()));
 }
 public function setUp()
 {
     $this->factory = new PropertyPathMappingFactory();
     $this->em = EntityManagerMock::create(new ConnectionMock([], new DriverMock()));
 }
Ejemplo n.º 14
0
 /**
  * Creates an EntityManager for testing purposes.
  *
  * NOTE: The created EntityManager will have its dependant DBAL parts completely
  * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
  * be configured in the tests to simulate the DBAL behavior that is desired
  * for a particular test,
  *
  * @param \Doctrine\DBAL\Connection|array    $conn
  * @param mixed                              $conf
  * @param \Doctrine\Common\EventManager|null $eventManager
  * @param bool                               $withSharedMetadata
  *
  * @return \Doctrine\ORM\EntityManager
  */
 protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true)
 {
     $metadataCache = $withSharedMetadata ? self::getSharedMetadataCacheImpl() : new \Doctrine\Common\Cache\ArrayCache();
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl($metadataCache);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true));
     $config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Doctrine\\Tests\\Proxies');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(realpath(__DIR__ . '/Models/Cache')), true));
     if ($this->isSecondLevelCacheEnabled) {
         $cacheConfig = new \Doctrine\ORM\Cache\CacheConfiguration();
         $cache = $this->getSharedSecondLevelCacheDriverImpl();
         $factory = new DefaultCacheFactory($cacheConfig->getRegionsConfiguration(), $cache);
         $this->secondLevelCacheFactory = $factory;
         $cacheConfig->setCacheFactory($factory);
         $config->setSecondLevelCacheEnabled(true);
         $config->setSecondLevelCacheConfiguration($cacheConfig);
     }
     if ($conn === null) {
         $conn = array('driverClass' => 'Doctrine\\Tests\\Mocks\\DriverMock', 'wrapperClass' => 'Doctrine\\Tests\\Mocks\\ConnectionMock', 'user' => 'john', 'password' => 'wayne');
     }
     if (is_array($conn)) {
         $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
     }
     return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
 }
 public function testGetClassName()
 {
     $this->assertEquals(DemoEntity::ENTITY_NAME, $this->configProvider->getClassName(DemoEntity::ENTITY_NAME));
     $className = DemoEntity::ENTITY_NAME;
     $demoEntity = new $className();
     $this->assertEquals(DemoEntity::ENTITY_NAME, $this->configProvider->getClassName($demoEntity));
     $this->assertEquals(DemoEntity::ENTITY_NAME, $this->configProvider->getClassName(array($demoEntity)));
     $classMetadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $classMetadata->expects($this->once())->method('getName')->will($this->returnValue(DemoEntity::ENTITY_NAME));
     $connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
     $emMock = EntityManagerMock::create($connectionMock);
     $persistentCollection = new PersistentCollection($emMock, $classMetadata, new ArrayCollection());
     $this->assertEquals(DemoEntity::ENTITY_NAME, $this->configProvider->getClassName($persistentCollection));
     $this->setExpectedException('Oro\\Bundle\\EntityConfigBundle\\Exception\\RuntimeException');
     $this->assertEquals(DemoEntity::ENTITY_NAME, $this->configProvider->getClassName(array()));
 }