w = new GraphicalNavigationWidget(); } function testUpdateWidget() { $result = $this->w->update(array( "next" => "test", "next_title" => "test", "archive_path" => "test", ), 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 */ function testIsNavLinkVisible($which, $current_id, $target_id, $expected_result) { $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)); } 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) { _set_filter_expectation('comicpress_navigation_grouping_details', array(array( 'left' => array('one', 'two', 'three'), 'center' => true, 'right' => array('four', 'five', 'six'), ))); $this->assertEquals($expected_grouping, $this->w->_group_navigation_buttons($buttons, array())); } 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 */ 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() { global $post; $post = 'post'; $css = $this->getMock('GraphicalNavigationWidget', array('_new_comicpress_storyline', '_new_comicpress_navigation')); 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'); $navigation->expects($this->once())->method('get_post_nav')->with($post)->will($this->returnValue('true')); $css->expects($this->once())->method('_new_comicpress_navigation')->will($this->returnValue($navigation)); $css->set_up_post_nav(array()); } } ?>