-
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
2009b62
commit ebfc7a8
Showing
10 changed files
with
640 additions
and
0 deletions.
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
tests/ZfcDatagridTest/Column/Action/AbstractActionTest.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,140 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column\Action; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Filter; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Action\AbstractAction | ||
*/ | ||
class AbstractActionTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* | ||
* @var \ZfcDatagrid\Column\AbstractColumn | ||
*/ | ||
private $column; | ||
|
||
public function setUp () | ||
{ | ||
$this->column = $this->getMockForAbstractClass('ZfcDatagrid\Column\AbstractColumn'); | ||
$this->column->setUniqueId('colName'); | ||
} | ||
|
||
public function testLink () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertEquals('#', $action->getLink()); | ||
|
||
$action->setLink('/my/page/is/cool'); | ||
$this->assertEquals('/my/page/is/cool', $action->getLink()); | ||
} | ||
|
||
public function testAttributes () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertEquals(array(), $action->getAttributes()); | ||
|
||
$this->assertEquals('', $action->getAttribute('something')); | ||
|
||
$action->setAttribute('class', 'error'); | ||
$this->assertCount(1, $action->getAttributes()); | ||
$this->assertEquals(array( | ||
'class' => 'error' | ||
), $action->getAttributes()); | ||
|
||
$this->assertEquals('error', $action->getAttribute('class')); | ||
} | ||
|
||
public function testTitle () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertEquals('', $action->getTitle()); | ||
|
||
$action->setTitle('This is my action'); | ||
$this->assertEquals('This is my action', $action->getTitle()); | ||
} | ||
|
||
public function testAddClass () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertEquals('', $action->getAttribute('class')); | ||
|
||
$action->addClass('cssClass'); | ||
$this->assertEquals('cssClass', $action->getAttribute('class')); | ||
|
||
$action->addClass('cssClass2'); | ||
$this->assertEquals('cssClass cssClass2', $action->getAttribute('class')); | ||
} | ||
|
||
public function testShowOnValue () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertCount(0, $action->getShowOnValues()); | ||
|
||
$this->assertFalse($action->hasShowOnValues()); | ||
$action->addShowOnValue($this->column, '23', Filter::EQUAL); | ||
$this->assertTrue($action->hasShowOnValues()); | ||
} | ||
|
||
public function testIsDisplayed () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->assertTrue($action->isDisplayed(array( | ||
$this->column->getUniqueId() => '23' | ||
))); | ||
|
||
// EQUAL | ||
$action->addShowOnValue($this->column, '23', Filter::EQUAL); | ||
|
||
$this->assertTrue($action->isDisplayed(array( | ||
$this->column->getUniqueId() => '23' | ||
))); | ||
|
||
$this->assertFalse($action->isDisplayed(array( | ||
$this->column->getUniqueId() => '33' | ||
))); | ||
} | ||
|
||
public function testIsDisplayedNotEqual () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$action->addShowOnValue($this->column, '23', Filter::NOT_EQUAL); | ||
|
||
$this->assertTrue($action->isDisplayed(array( | ||
$this->column->getUniqueId() => '32' | ||
))); | ||
|
||
$this->assertFalse($action->isDisplayed(array( | ||
$this->column->getUniqueId() => '23' | ||
))); | ||
} | ||
|
||
public function testIsDisplayedException () | ||
{ | ||
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */ | ||
$action = $this->getMockForAbstractClass('ZfcDatagrid\Column\Action\AbstractAction'); | ||
|
||
$this->setExpectedException('Exception'); | ||
$action->addShowOnValue($this->column, '23', Filter::BETWEEN); | ||
$action->isDisplayed(array( | ||
$this->column->getUniqueId() => '32' | ||
)); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column\Action; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Column\Action\Button; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Action\Button | ||
*/ | ||
class ButtonTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstruct () | ||
{ | ||
$button = new Button(); | ||
|
||
$this->assertEquals(array( | ||
'class' => 'btn' | ||
), $button->getAttributes()); | ||
} | ||
|
||
public function testLabel () | ||
{ | ||
$button = new Button(); | ||
|
||
$button->setLabel('My label'); | ||
$this->assertEquals('My label', $button->getLabel()); | ||
|
||
$html = '<a href="#" class="btn">My label</a>'; | ||
$this->assertEquals($html, $button->toHtml()); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column\Action; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Column\Action\Icon; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Action\Icon | ||
*/ | ||
class IconTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstruct () | ||
{ | ||
$icon = new Icon(); | ||
|
||
$this->assertEquals(array(), $icon->getAttributes()); | ||
} | ||
|
||
public function testIcon () | ||
{ | ||
$icon = new Icon(); | ||
$icon->setIconClass('icon-add'); | ||
|
||
$this->assertEquals(array( | ||
'class' => 'icon-add' | ||
), $icon->getAttributes()); | ||
|
||
$icon->setIconLink('/images/icon/add.png'); | ||
|
||
$html = '<i title="" class="icon-add"></i>'; | ||
$this->assertEquals($html, $icon->toHtml()); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column; | ||
|
||
use ZfcDatagrid\Column; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Action | ||
*/ | ||
class ActionTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstructDefaultBoth () | ||
{ | ||
$column = new Column\Action(); | ||
|
||
$this->assertEquals('action', $column->getUniqueId()); | ||
$this->assertEquals('Actions', $column->getLabel()); | ||
$this->assertFalse($column->isUserSortEnabled()); | ||
$this->assertFalse($column->isUserFilterEnabled()); | ||
$this->assertFalse($column->isRowClickEnabled()); | ||
} | ||
|
||
public function testAddAction () | ||
{ | ||
$column = new Column\Action(); | ||
|
||
$this->assertCount(0, $column->getActions()); | ||
|
||
$action = $this->getMock('ZfcDatagrid\Column\Action\Button'); | ||
$column->addAction($action); | ||
|
||
$this->assertCount(1, $column->getActions()); | ||
|
||
$action2 = $this->getMock('ZfcDatagrid\Column\Action\Button'); | ||
$column->addAction($action2); | ||
$action3 = $this->getMock('ZfcDatagrid\Column\Action\Button'); | ||
$column->addAction($action3); | ||
|
||
$this->assertCount(3, $column->getActions()); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Column\Icon; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Icon | ||
*/ | ||
class IconTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstruct () | ||
{ | ||
$col = new Icon(); | ||
|
||
$this->assertEquals('icon', $col->getUniqueId()); | ||
$this->assertFalse($col->isUserSortEnabled()); | ||
$this->assertFalse($col->isUserFilterEnabled()); | ||
$this->assertEquals(5, $col->getWidth()); | ||
} | ||
|
||
public function testIconClass () | ||
{ | ||
$col = new Icon(); | ||
|
||
$this->assertFalse($col->hasIconClass()); | ||
|
||
$col->setIconClass('icon-add'); | ||
$this->assertEquals('icon-add', $col->getIconClass()); | ||
$this->assertTrue($col->hasIconClass()); | ||
} | ||
|
||
public function testIconLink () | ||
{ | ||
$col = new Icon(); | ||
|
||
$this->assertFalse($col->hasIconLink()); | ||
|
||
$col->setIconLink('/images/21/add.png'); | ||
$this->assertEquals('/images/21/add.png', $col->getIconLink()); | ||
$this->assertTrue($col->hasIconLink()); | ||
} | ||
|
||
public function testTitle () | ||
{ | ||
$col = new Icon(); | ||
|
||
$this->assertFalse($col->hasTitle()); | ||
$this->assertEquals('', $col->getTitle()); | ||
|
||
$col->setTitle('blubb'); | ||
$this->assertEquals('blubb', $col->getTitle()); | ||
$this->assertTrue($col->hasTitle()); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
namespace ZfcDatagridTest\Column; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use ZfcDatagrid\Column\Image; | ||
|
||
/** | ||
* @group Column | ||
* @covers ZfcDatagrid\Column\Image | ||
*/ | ||
class ImageTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstruct () | ||
{ | ||
$col = new Image(); | ||
|
||
$this->assertEquals('image', $col->getUniqueId()); | ||
$this->assertFalse($col->isUserSortEnabled()); | ||
$this->assertFalse($col->isUserFilterEnabled()); | ||
} | ||
} |
Oops, something went wrong.