private function createEntryWithServerConfig($clientValue, array $config) { $entry = $this->createMock(ConfigurationEntry::clazz(), array(), array(), '', null, false); $entry->expects($this->once())->method('getDenormalizedValue')->will($this->returnValue(1)); $entry->expects($this->atLeastOnce())->method('getServerHandlerConfig')->will($this->returnValue($config)); return $entry; }
public function setUp() { $this->handler = new DictionaryHandler(); $config = array('dictionary' => array('foo' => 'foo-val')); $this->entry = $this->createMock(ConfigurationEntry::clazz(), array(), array(), '', null, false); $this->entry->expects($this->any())->method('getServerHandlerConfig')->will($this->returnValue($config)); }
/** * @param LoadClassMetadataEventArgs $args */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { /* @var ClassMetadataInfo $mapping */ $mapping = $args->getClassMetadata(); if ($mapping->getName() == ConfigurationEntry::clazz()) { $mapping->mapManyToOne(array('fieldName' => 'owner', 'type' => ClassMetadataInfo::MANY_TO_ONE, 'isOwningSide' => true, 'targetEntity' => $this->semanticConfig['owner_entity'])); } }
public function testGetConfigMapDataOnUpdate() { $config = $this->c->getConfig(); $this->assertTrue(is_array($config)); $this->assertArrayHasKey('map_data_on_update', $config); $this->assertTrue(is_callable($config['map_data_on_update'])); $mapper = $config['map_data_on_update']; $entry = \Phake::mock(ConfigurationEntry::clazz()); $this->teachEntry($entry, 'isReadOnly', true); }
/** * @return array */ public function getConfig() { return array('entity' => ConfigurationEntry::clazz(), 'hydration' => array('groups' => array('list' => function (ConfigurationEntry $entry) { return array('id' => $entry->getId(), 'name' => $entry->getName(), 'readableName' => $entry->getReadableName(), 'readableValue' => $entry->getReadableValue(), 'value' => $entry->getValue(), 'isReadOnly' => $entry->isReadOnly(), 'editorConfig' => $entry->getClientHandlerConfig()); }), 'profiles' => ['list']), 'map_data_on_update' => function (array $params, ConfigurationEntry $entry) { if ($entry->isReadOnly() || !$entry->isExposed()) { return; } if (isset($params['value'])) { $entry->setValue($params['value']); } }); }
public function setUp() { $this->em = $this->createMock('Doctrine\\ORM\\EntityManager', array(), array(), '', false); $this->ce = $this->createMock(ConfigurationEntry::clazz(), array(), array(), '', false); $this->handler = new EntityRepositoryHandler($this->em); }
/** * @param object $owner * * @return ConfigurationEntryInterface[] */ public function findAllExposed($owner = null) { $qb = $this->em->createQueryBuilder(); $qb->select('e')->from(ConfigurationEntry::clazz(), 'e')->andWhere($qb->expr()->eq('e.isExposed', '?1')); $qb->setParameter(1, true); if ($this->isOwnerConfigured()) { $qb->andWhere($owner ? $qb->expr()->eq('e.owner', '?2') : $qb->expr()->isNull('e.owner')); if ($owner) { $qb->setParameter(2, $owner); } } return $qb->getQuery()->getResult(); }
/** * {@inheritdoc} */ public static function doTearDownAfterClass() { self::$st->dropSchema([self::$em->getClassMetadata(ConfigurationEntry::clazz()), self::$em->getClassMetadata(User::clazz())]); }
private function entryExists(ConfigurationEntryDefinition $entry) { return (bool) $this->em->getRepository(ConfigurationEntry::clazz())->findOneBy(array('name' => $entry->getName())); }
public function setUp() { $this->entry = $this->createMock(ConfigurationEntry::clazz(), array(), array(), '', null, false); $this->handler = new AsIsHandler(); }
public function testSetValue() { $handlerServiceId = 'bar_handler'; $clientValue = 'foo bar baz'; $convertedValue = 'converted foo bar baz'; $handler = $this->createMock('Modera\\ConfigBundle\\Config\\HandlerInterface'); $handler->expects($this->atLeastOnce())->method('convertToStorageValue')->with($this->equalTo($clientValue), $this->isInstanceOf(CE::clazz()))->will($this->returnValue($convertedValue)); $container = $this->createMockContainer($handlerServiceId, $handler); $ce = new CE('bar_prop'); $ce->setServerHandlerConfig(array('handler' => $handlerServiceId)); $ce->init($container); $ce->setValue($clientValue); $this->assertEquals($convertedValue, $ce->getDenormalizedValue()); }