public function testIdGetter() { $obj = new ConfigModelIndexValue(); ReflectionUtil::setId($obj, 1); $this->assertEquals(1, $obj->getId()); }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function postSubmitProvider() { $existingConfigModel = new EntityConfigModel('Entity\\Test'); ReflectionUtil::setId($existingConfigModel, 1); return ['empty data' => [[], false, new EntityConfigModel('Entity\\Test'), [], null, null], 'new model without trans (isValid=false)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], false, new EntityConfigModel('Entity\\Test'), [], ['label' => 'label_key', 'icon' => 'testIcon'], null], 'new model without trans (isValid=true)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], true, new EntityConfigModel('Entity\\Test'), [], ['label' => 'label_key', 'icon' => 'testIcon'], ['label_key', 'translated label', 'testLocale']], 'existing model without trans (isValid=true)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], true, $existingConfigModel, [], ['label' => 'label_key', 'icon' => 'testIcon'], ['label_key', 'translated label', 'testLocale']], 'new model with trans (isValid=true)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], true, new EntityConfigModel('Entity\\Test'), ['label_key' => 'translated label'], ['label' => 'label_key', 'icon' => 'testIcon'], ['label_key', 'translated label', 'testLocale']], 'existing model with trans (isValid=true)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], true, $existingConfigModel, ['label_key' => 'translated label'], ['label' => 'label_key', 'icon' => 'testIcon'], null], 'existing model with different trans (isValid=true)' => [['entity' => ['label' => 'translated label', 'icon' => 'testIcon']], true, $existingConfigModel, ['label_key' => 'translated label 1'], ['label' => 'label_key', 'icon' => 'testIcon'], ['label_key', 'translated label', 'testLocale']]]; }
public function testThatEntityListAreLoadedAfterConfigurableEntityIsLoaded() { $entityModel0 = $this->createEntityModel('Test\\ConfigurableEntity'); ReflectionUtil::setId($entityModel0, 123); $entityModel1 = $this->createEntityModel(self::TEST_ENTITY); $entityModel2 = $this->createEntityModel(self::TEST_ENTITY2); $this->repo->expects($this->once())->method('findOneBy')->with(['className' => 'Test\\ConfigurableEntity'])->will($this->returnValue($entityModel0)); $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(['getResult'])->getMockForAbstractClass(); $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $this->repo->expects($this->once())->method('createQueryBuilder')->with('e')->willReturn($qb); $qb->expects($this->once())->method('where')->with('e.id NOT IN (:exclusions)')->willReturnSelf(); $qb->expects($this->once())->method('setParameter')->with('exclusions', [$entityModel0->getId()])->willReturnSelf(); $qb->expects($this->once())->method('getQuery')->willReturn($query); $query->expects($this->once())->method('getResult')->will($this->returnValue([$entityModel1, $entityModel2])); $this->prepareCheckDetached([UnitOfWork::STATE_MANAGED, UnitOfWork::STATE_MANAGED, UnitOfWork::STATE_MANAGED, UnitOfWork::STATE_MANAGED]); $this->assertSame($entityModel0, $this->configModelManager->findEntityModel('Test\\ConfigurableEntity')); $this->assertEquals([$entityModel0, $entityModel1, $entityModel2], $this->configModelManager->getModels()); // test localCache $this->assertSame($entityModel0, $this->configModelManager->findEntityModel('Test\\ConfigurableEntity')); $this->assertSame($entityModel1, $this->configModelManager->findEntityModel(self::TEST_ENTITY)); $this->assertSame($entityModel2, $this->configModelManager->findEntityModel(self::TEST_ENTITY2)); }