public function testFlush() { $model = new EntityConfigModel(self::ENTITY_CLASS); $entityConfigId = new EntityConfigId('entity', self::ENTITY_CLASS); $entityConfig = new Config($entityConfigId); $entityConfig->set('icon', 'test_icon'); $entityConfig->set('label', 'test_label'); $entityPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['icon' => [], 'label' => ['options' => ['indexed' => true]]]]]); $this->entityConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($entityPropertyConfig)); $testConfigId = new EntityConfigId('test', self::ENTITY_CLASS); $testConfig = new Config($testConfigId); $testConfig->set('attr1', 'test_attr1'); $testPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['attr1' => []]]]); $this->testConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($testPropertyConfig)); $this->modelManager->expects($this->once())->method('getEntityModel')->with($entityConfigId->getClassName())->will($this->returnValue($model)); $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->modelManager->expects($this->any())->method('getEntityManager')->will($this->returnValue($em)); $this->setFlushExpectations($em, [$model]); $this->eventDispatcher->expects($this->at(2))->method('dispatch')->with(Events::PRE_FLUSH, new PreFlushConfigEvent(['entity' => $entityConfig, 'test' => $testConfig], $this->configManager)); $this->configManager->persist($entityConfig); $this->configManager->persist($testConfig); $this->configManager->flush(); $this->assertEquals(['icon' => 'test_icon', 'label' => 'test_label'], $model->toArray('entity')); $this->assertEquals(['attr1' => 'test_attr1'], $model->toArray('test')); $this->assertCount(3, $model->getIndexedValues()); $this->assertEquals('entity_config', $model->getIndexedValues()[0]->getScope()); $this->assertEquals('module_name', $model->getIndexedValues()[0]->getCode()); $this->assertEquals('entity_config', $model->getIndexedValues()[1]->getScope()); $this->assertEquals('entity_name', $model->getIndexedValues()[1]->getCode()); $this->assertEquals('entity', $model->getIndexedValues()[2]->getScope()); $this->assertEquals('label', $model->getIndexedValues()[2]->getCode()); }
public function testIsSupportedTargetEntityWrongEntity() { $correctTarget = new EntityConfigId('entity', 'Acme\\DemoBundle\\Entity\\CorrectEntity'); $notCorrectTarget = new EntityConfigId('entity', 'Acme\\DemoBundle\\Entity\\NotCorrectEntity'); $this->configManager->expects($this->once())->method('getIds')->will($this->returnValue([$correctTarget, $notCorrectTarget])); $testEntity = new \stdClass(); $this->doctrineHelper->expects($this->once())->method('getEntityClass')->with($testEntity)->will($this->returnValue($notCorrectTarget->getClassName())); $this->assertFalse($this->provider->isSupportedTargetEntity($testEntity)); }
public function testClearEntityCache() { $configId = new EntityConfigId('entity', self::ENTITY_CLASS); $this->configCache->expects($this->once())->method('deleteEntityConfig')->with($configId->getClassName()); $this->configManager->clearCache($configId); }
public function testSetState() { $entityId = EntityConfigId::__set_state(['className' => 'Test\\Class', 'scope' => 'testScope']); $this->assertEquals('Test\\Class', $entityId->getClassName()); $this->assertEquals('testScope', $entityId->getScope()); }
public function testDeleteEntityConfig() { $configId = new EntityConfigId(self::SCOPE, self::ENTITY_CLASS); $cacheKey = self::ENTITY_CLASS; $this->cache->expects($this->at(0))->method('delete')->with(ConfigCache::ENTITY_CLASSES_KEY)->willReturn(true); $this->cache->expects($this->at(1))->method('delete')->with(ConfigCache::FIELD_NAMES_KEY . self::ENTITY_CLASS)->willReturn(true); $this->cache->expects($this->at(2))->method('delete')->with($cacheKey)->willReturn(true); $this->assertTrue($this->configCache->deleteEntityConfig($configId->getClassName())); }
public function testGetConfig() { $this->assertEquals('Test\\Class', $this->entityId->getClassName()); $this->assertEquals('testScope', $this->entityId->getScope()); $this->assertEquals('entity_testScope_Test-Class', $this->entityId->toString()); }