コード例 #1
0
ファイル: DateTimeTest.php プロジェクト: npakai/enhavo
 function testDefaultFormatDate()
 {
     $object = new EntityMock();
     $object->setName(new \DateTime('1970-01-01 12:34'));
     $options = ['property' => 'name'];
     $widget = new DateTimeWidget();
     $this->assertEquals('01.01.1970 12:34', $widget->render($options, $object));
 }
コード例 #2
0
ファイル: PropertyWidgetTest.php プロジェクト: npakai/enhavo
 /**
  * Test if you try to access an not existing property, will throw an exception
  *
  * @expectedException \Enhavo\Bundle\AppBundle\Exception\PropertyNotExistsException
  */
 function testPropertyAccessIfNotExists()
 {
     $object = new EntityMock();
     $object->setName('my name is route');
     $options = ['property' => 'propertyNotExists'];
     $widget = new PropertyWidget();
     $this->assertEquals('my name is route', $widget->render($options, $object));
 }
コード例 #3
0
 function testRender()
 {
     $object = new EntityMock();
     $object->setName('myName');
     $object->setId(1);
     $options = ['properties' => ['name', 'id']];
     $widget = new MultiplePropertyWidget();
     $this->assertEquals('myName,1', $widget->render($options, $object));
 }
コード例 #4
0
ファイル: ListWidgetTest.php プロジェクト: npakai/enhavo
 protected function getEntityMock()
 {
     $childOne = new EntityMock();
     $childOne->setName('one');
     $childTwo = new EntityMock();
     $childTwo->setName('two');
     $entity = new EntityMock();
     $entity->addEntity($childOne);
     $entity->addEntity($childTwo);
     return $entity;
 }
コード例 #5
0
 /**
  * Test if theEditViewer pass back the correct value for function getParameters
  *
  */
 function testReturnParameters()
 {
     $configParser = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Config\\ConfigParser')->getMock();
     $configParser->method('get')->will($this->returnValueMap([['tabs', 'tabs'], ['form.template', 'form_template'], ['form.action', 'form_action_route'], ['form.delete', 'form_delete_route'], ['buttons', array()], ['parameters', array()], ['translationDomain', 'EnhavoAppBundle']]));
     $router = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')->disableOriginalConstructor()->getMock();
     $router->method('generate')->willReturnCallback(function ($name) {
         if ($name == 'form_action_route') {
             return 'some_action_url';
         }
         if ($name == 'form_delete_route') {
             return 'some_delete_url';
         }
         return null;
     });
     $securityContext = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\SecurityContext')->disableOriginalConstructor()->getMock();
     $securityContext->method('isGranted')->willReturn(true);
     $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock();
     $container->method('get')->willReturnCallback(function ($id) use($router, $securityContext) {
         if ('router' == $id) {
             return $router;
         }
         if ('security.context' == $id) {
             return $securityContext;
         }
         return null;
     });
     $resource = new EntityMock();
     $resource->setId(1);
     $viewer = new EditViewer();
     $viewer->setContainer($container);
     $viewer->setConfig($configParser);
     $viewer->setForm('form');
     $viewer->setResource($resource);
     $parameters = $viewer->getParameters();
     $this->assertArraySubset(['tabs' => 'tabs', 'buttons' => array(), 'form_action' => 'some_action_url', 'form_template' => 'form_template', 'form_delete' => 'some_delete_url', 'form' => 'form', 'viewer' => $viewer, 'data' => $resource, 'translationDomain' => 'EnhavoAppBundle'], $parameters);
 }