2009-10-21 00:48:01 +00:00
|
|
|
<?php
|
|
|
|
|
2009-11-04 12:24:28 +00:00
|
|
|
require_once('MockPress/mockpress.php');
|
2009-10-21 00:48:01 +00:00
|
|
|
require_once('PHPUnit/Framework.php');
|
2009-11-26 15:19:40 +00:00
|
|
|
require_once(dirname(__FILE__) . '/../../widgets/GraphicalNavigationWidget.inc');
|
2009-10-21 00:48:01 +00:00
|
|
|
|
2009-11-26 15:19:40 +00:00
|
|
|
class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
2009-10-22 00:11:22 +00:00
|
|
|
function setUp() {
|
|
|
|
_reset_wp();
|
2009-12-25 18:38:56 +00:00
|
|
|
$this->w = new ComicPressGraphicalNavigationWidget();
|
2009-10-22 00:11:22 +00:00
|
|
|
}
|
2009-10-21 00:48:01 +00:00
|
|
|
|
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-10-31 19:46:01 +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
|
|
|
|
*/
|
|
|
|
function testGroupNavigationButtons($buttons, $expected_grouping) {
|
2009-11-20 05:02:23 +00:00
|
|
|
_set_filter_expectation('comicpress_navigation_grouping_details', array(array(
|
2009-11-04 12:17:45 +00:00
|
|
|
'left' => array('one', 'two', 'three'),
|
|
|
|
'center' => true,
|
|
|
|
'right' => array('four', 'five', 'six'),
|
2009-11-20 05:02:23 +00:00
|
|
|
)));
|
2009-11-04 12:17:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals($expected_grouping, $this->w->_group_navigation_buttons($buttons, array()));
|
|
|
|
}
|
2009-11-24 02:50:18 +00:00
|
|
|
|
|
|
|
function providerTestSetUpPostNav() {
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array('story_prev_acts_as_prev_in' => 'off'),
|
|
|
|
array('storyline-previous' => 'test', 'storyline-chapter-previous' => 'test'),
|
|
|
|
array('storyline-previous' => 'test', 'storyline-chapter-previous' => 'test')
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array('story_prev_acts_as_prev_in' => 'on'),
|
|
|
|
array('storyline-previous' => 'test2', 'storyline-chapter-previous' => 'test'),
|
|
|
|
array('storyline-previous' => 'test2', 'storyline-chapter-previous' => 'test2')
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array('story_prev_acts_as_prev_in' => 'off'),
|
|
|
|
array('storyline-previous' => false, 'storyline-chapter-previous' => 'test'),
|
|
|
|
array('storyline-previous' => false, 'storyline-chapter-previous' => 'test')
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array('story_prev_acts_as_prev_in' => 'on'),
|
|
|
|
array('storyline-previous' => false, 'storyline-chapter-previous' => 'test'),
|
|
|
|
array('storyline-previous' => false, 'storyline-chapter-previous' => 'test')
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTestSetUpPostNav
|
|
|
|
*/
|
2009-11-26 15:38:25 +00:00
|
|
|
function testComicPressSetUpPostNavFilter($instance, $post_nav, $expected_post_nav) {
|
|
|
|
$this->assertEquals($expected_post_nav, array_shift($this->w->comicpress_set_up_post_nav($post_nav, $instance)));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSetUpPostNav() {
|
2009-11-24 02:50:18 +00:00
|
|
|
global $post;
|
|
|
|
|
|
|
|
$post = 'post';
|
|
|
|
|
2009-12-25 18:38:56 +00:00
|
|
|
$css = $this->getMock('ComicPressGraphicalNavigationWidget', array('_new_comicpress_storyline', '_new_comicpress_navigation'));
|
2009-11-24 02:50:18 +00:00
|
|
|
|
|
|
|
update_option('comicpress-storyline-category-order', 'test');
|
|
|
|
|
|
|
|
$storyline = $this->getMock('ComicPressStoryline', array('set_order_via_flattened_storyline'));
|
|
|
|
$storyline->expects($this->once())->method('set_order_via_flattened_storyline')->with('test');
|
|
|
|
|
|
|
|
$css->expects($this->once())->method('_new_comicpress_storyline')->will($this->returnValue($storyline));
|
|
|
|
|
|
|
|
$navigation = $this->getMock('ComicPressNavigation', array('init', 'get_post_nav'));
|
|
|
|
$navigation->expects($this->once())->method('init');
|
2009-11-26 15:38:25 +00:00
|
|
|
$navigation->expects($this->once())->method('get_post_nav')->with($post)->will($this->returnValue('true'));
|
2009-11-24 02:50:18 +00:00
|
|
|
|
|
|
|
$css->expects($this->once())->method('_new_comicpress_navigation')->will($this->returnValue($navigation));
|
|
|
|
|
2009-11-26 15:38:25 +00:00
|
|
|
$css->set_up_post_nav(array());
|
2009-11-24 02:50:18 +00:00
|
|
|
}
|
2009-10-21 00:48:01 +00:00
|
|
|
}
|
|
|
|
|
2009-11-26 15:19:40 +00:00
|
|
|
?>
|