-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46cb710
commit 165b7bd
Showing
6 changed files
with
163 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Column; | ||
use ZfcDatagrid\Column\DataPopulation; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\ExternalData | ||
*/ | ||
class ExternalDataTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstruct() | ||
{ | ||
$column = new Column\ExternalData('myData'); | ||
|
||
$this->assertEquals('myData', $column->getUniqueId()); | ||
|
||
$this->assertFalse($column->isUserFilterEnabled()); | ||
$this->assertFalse($column->isUserSortEnabled()); | ||
} | ||
|
||
public function testSetGetData() | ||
{ | ||
$column = new Column\ExternalData('myData'); | ||
|
||
|
||
$object = new DataPopulation\Object(); | ||
$object->setObject(new DataPopulation\Object\Gravatar()); | ||
$this->assertEquals(false, $column->hasDataPopulation()); | ||
|
||
$column->setDataPopulation($object); | ||
|
||
$this->assertEquals(true, $column->hasDataPopulation()); | ||
$this->assertInstanceOf('ZfcDatagrid\Column\DataPopulation\Object', $column->getDataPopulation()); | ||
} | ||
|
||
public function testException() | ||
{ | ||
$column = new Column\ExternalData('myData'); | ||
|
||
$object = new DataPopulation\Object(); | ||
$this->setExpectedException('Exception'); | ||
$column->setDataPopulation($object); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
tests/ZfcDatagridTest/Renderer/AbstractRendererTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Renderer; | ||
|
||
use ZfcDatagrid\Column\DataPopulation; | ||
use ZfcDatagrid\Filter; | ||
use ZfcDatagrid\Column\Type; | ||
use ZfcDatagrid\Column\Style; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Renderer\AbstractRenderer | ||
*/ | ||
class AbstractRendererTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testOptions() | ||
{ | ||
$renderer = $this->getMockForAbstractClass('ZfcDatagrid\Renderer\AbstractRenderer'); | ||
$renderer->setOptions(array( | ||
'test' | ||
)); | ||
|
||
$this->assertEquals(array( | ||
'test' | ||
), $renderer->getOptions()); | ||
} | ||
|
||
public function testRendererOptions() | ||
{ | ||
$renderer = $this->getMockForAbstractClass('ZfcDatagrid\Renderer\AbstractRenderer'); | ||
$renderer->expects($this->any()) | ||
->method('getName') | ||
->will($this->returnValue('abstract')); | ||
|
||
$this->assertEquals(array(), $renderer->getOptionsRenderer()); | ||
|
||
$renderer->setOptions(array( | ||
'renderer' => array( | ||
'abstract' => array( | ||
'test' | ||
) | ||
) | ||
)); | ||
|
||
$this->assertEquals(array( | ||
'test' | ||
), $renderer->getOptionsRenderer()); | ||
} | ||
|
||
public function testViewModel() | ||
{ | ||
$renderer = $this->getMockForAbstractClass('ZfcDatagrid\Renderer\AbstractRenderer'); | ||
|
||
$this->assertNull($renderer->getViewModel()); | ||
|
||
$viewModel = $this->getMock('Zend\View\Model\ViewModel'); | ||
$renderer->setViewModel($viewModel); | ||
$this->assertSame($viewModel, $renderer->getViewModel()); | ||
} | ||
|
||
public function testTemplate() | ||
{ | ||
$renderer = $this->getMockForAbstractClass('ZfcDatagrid\Renderer\AbstractRenderer'); | ||
$renderer->expects($this->any()) | ||
->method('getName') | ||
->will($this->returnValue('abstract')); | ||
|
||
$this->assertEquals('zfc-datagrid/renderer/abstract/layout', $renderer->getTemplate()); | ||
$this->assertEquals('zfc-datagrid/toolbar/toolbar', $renderer->getToolbarTemplate()); | ||
|
||
$renderer->setTemplate('blubb/layout'); | ||
$this->assertEquals('blubb/layout', $renderer->getTemplate()); | ||
|
||
$renderer->setToolbarTemplate('blubb/toolbar'); | ||
$this->assertEquals('blubb/toolbar', $renderer->getToolbarTemplate()); | ||
} | ||
|
||
public function testTemplateConfig() | ||
{ | ||
$renderer = $this->getMockForAbstractClass('ZfcDatagrid\Renderer\AbstractRenderer'); | ||
$renderer->expects($this->any()) | ||
->method('getName') | ||
->will($this->returnValue('abstract')); | ||
|
||
$renderer->setOptions(array( | ||
'renderer' => array( | ||
'abstract' => array( | ||
'templates' => array( | ||
'layout' => 'config/my/template', | ||
'toolbar' => 'config/my/toolbar' | ||
) | ||
) | ||
) | ||
)); | ||
|
||
$this->assertEquals('config/my/template', $renderer->getTemplate()); | ||
$this->assertEquals('config/my/toolbar', $renderer->getToolbarTemplate()); | ||
} | ||
} |