comicpress-2.8/test/widgets/GraphicalNavigationTest.php

92 lines
2.5 KiB
PHP
Raw Normal View History

<?php
2009-11-04 12:24:28 +00:00
require_once('MockPress/mockpress.php');
require_once('PHPUnit/Framework.php');
require_once(dirname(__FILE__) . '/../../widgets/graphical-navigation.php');
2009-10-21 01:08:17 +00:00
class GraphicalNavigationTest extends PHPUnit_Framework_TestCase {
2009-10-22 00:11:22 +00:00
function setUp() {
_reset_wp();
$this->w = new WidgetComicPressGraphicalStorylineNavigation();
2009-10-22 00:11:22 +00:00
}
2009-11-04 12:17:45 +00:00
/**
* @covers WidgetComicPressGraphicalStorylineNavigation::update
*/
2009-10-22 00:11:22 +00:00
function testUpdateWidget() {
$result = $this->w->update(array(
2009-10-21 01:08:17 +00:00
"next" => "<b>test</b>",
"next_title" => "<b>test</b>",
"archive_path" => "<b>test</b>",
2009-10-22 00:11:22 +00:00
), array());
foreach (array(
"next" => "on",
"next_title" => "test",
"archive_path" => "test",
) as $field => $expected_value) {
$this->assertEquals($expected_value, $result[$field]);
}
}
function providerTestIsNavLinkVisible() {
return array(
array('first', 1, 2, true),
array('first', 1, 1, false),
array('last', 1, 2, true),
array('last', 1, 1, false),
array('prev', 1, 2, true),
);
}
/**
* @dataProvider providerTestIsNavLinkVisible
2009-11-04 12:17:45 +00:00
* @covers WidgetComicPressGraphicalStorylineNavigation::_will_display_nav_link
2009-10-22 00:11:22 +00:00
*/
function testIsNavLinkVisible($which, $current_id, $target_id, $expected_result) {
2009-10-22 00:11:22 +00:00
$current = (object)array('ID' => $current_id);
$target = (object)array('ID' => $target_id);
$this->assertEquals($expected_result, $this->w->_will_display_nav_link($which, $current, $target));
2009-10-21 01:08:17 +00:00
}
2009-11-04 12:17:45 +00:00
function providerTestGroupNavigationButtons() {
return array(
array(array(), array()),
array(
array('one' => 'will be left'),
array(
'left' => array('one' => 'will be left')
)
),
array(
array('four' => 'will be right'),
array(
'right' => array('four' => 'will be right')
)
),
array(
array('seven' => 'will be center'),
array(
'center' => array('seven' => 'will be center')
)
),
);
}
/**
* @dataProvider providerTestGroupNavigationButtons
* @covers WidgetComicPressGraphicalStorylineNavigation::_group_navigation_buttons
*/
function testGroupNavigationButtons($buttons, $expected_grouping) {
_set_filter_expectation('comicpress_navigation_grouping_details', array(
'left' => array('one', 'two', 'three'),
'center' => true,
'right' => array('four', 'five', 'six'),
));
$this->assertEquals($expected_grouping, $this->w->_group_navigation_buttons($buttons, array()));
}
}
?>