Beispiel #1
0
 public function getOptionsResolverMock($name, array $options)
 {
     $expectedResolvedOptions = array('name', 'title', 'params', 'attrs', 'data', 'default', 'format', 'allow_sort', 'allow_filter');
     $type = new Type\BarType();
     $optionsResolver = $type->getOptionsResolver();
     $type->setDefaultOptions($optionsResolver, $this->defaultColumnOptions);
     $options['name'] = $name;
     $resolvedOptions = $optionsResolver->resolve($options);
     foreach ($expectedResolvedOptions as $option) {
         $this->assertArrayHasKey($option, $resolvedOptions);
     }
     $optionsResolverMock = $this->getMock('Symfony\\Component\\OptionsResolver\\OptionsResolver');
     $optionsResolverMock->expects($this->any())->method('resolve')->with($options)->will($this->returnValue($resolvedOptions));
     return $optionsResolverMock;
 }
Beispiel #2
0
 public function testBuildView()
 {
     $type = new BarType();
     $optionsResolver = $type->getOptionsResolver();
     $type->setDefaultOptions($optionsResolver, $this->defaultColumnOptions);
     $options = array('name' => 'foo', 'attrs' => array('a' => 1, 'b' => 2));
     $resolvedOptions = $optionsResolver->resolve($options);
     $view = array();
     $column = new Column($type, $resolvedOptions);
     $type->buildView($view, $column, array('test'), $resolvedOptions);
     $expectedViewKeys = array('name', 'type', 'attrs', 'value');
     foreach ($expectedViewKeys as $key) {
         $this->assertArrayHasKey($key, $view);
     }
     $this->assertArrayHasKey('class', $view['attrs']);
     $this->assertEquals('foo', $view['name']);
     $this->assertEquals($view['type'], $type->getName());
     $this->assertEquals($view['value'], 'test');
     $this->assertEquals(trim('column-' . $type->getName() . ' column-foo'), $view['attrs']['class']);
     $this->assertArrayHasKey('a', $view['attrs']);
     $this->assertArrayHasKey('b', $view['attrs']);
 }