예제 #1
0
 public function testIsValidForSaving_changeNameWithOwner()
 {
     $vasya = new User('vasya');
     $ce1 = new ConfigurationEntry('cf_1');
     $ce1->setValue('foo');
     $ce2 = new ConfigurationEntry('cf_2');
     $ce2->setValue('foo');
     self::$em->persist($vasya);
     self::$em->persist($ce1);
     self::$em->persist($ce2);
     self::$em->flush();
     $ce2->setName('cf_1');
     $uv = new UniquityValidator(self::$em, array('owner_entity' => get_class($vasya)));
     $this->assertFalse($uv->isValidForSaving($ce2));
 }
 public function testFindAllExposed()
 {
     $ce1 = new ConfigurationEntry('cf_1');
     $ce1->setValue('foo');
     $ce2 = new ConfigurationEntry('cf_2');
     $ce2->setValue('foo');
     $ce3 = new ConfigurationEntry('cf_3');
     $ce3->setValue('foo');
     $ce3->setExposed(false);
     $this->getManager()->save($ce1);
     $this->getManager()->save($ce2);
     $this->getManager()->save($ce3);
     $result = $this->getManager()->findAllExposed();
     $this->assertEquals(2, count($result));
     $this->assertEquals('cf_1', $result[0]->getName());
     $this->assertEquals('cf_2', $result[1]->getName());
     // ---
     $vasya = new User('vasya');
     self::$em->persist($vasya);
     self::$em->flush();
     $ce1->setOwner($vasya);
     $this->getManager()->save($ce1);
     $result = $this->getManager()->findAllExposed();
     $this->assertEquals(1, count($result));
     $this->assertEquals('cf_2', $result[0]->getName());
     // ---
     $result = $this->getManager()->findAllExposed($vasya);
     $this->assertEquals(1, count($result));
     $this->assertEquals('cf_1', $result[0]->getName());
 }
예제 #3
0
 public function testUpdateHandler()
 {
     $id = 'update_handler';
     $handler = $this->createMock('Modera\\ConfigBundle\\Config\\ValueUpdatedHandlerInterface');
     $container = $this->createMockContainer($id, $handler);
     $ce = new CE('foo_prop');
     $ce->setServerHandlerConfig(array('update_handler' => $id));
     $ce->init($container);
     $ce->setValue('foo');
     self::$em->persist($ce);
     self::$em->flush();
     $handler->expects($this->atLeastOnce())->method('onUpdate')->with($this->equalTo($ce));
     $ce->setValue('bar');
     self::$em->flush();
 }