2009-10-18 21:59:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('MockPress/mockpress.php');
|
|
|
|
require_once('PHPUnit/Framework.php');
|
2009-11-07 17:18:53 +00:00
|
|
|
require_once('ComicPressNavigation.inc');
|
2009-10-18 21:59:40 +00:00
|
|
|
|
2009-10-20 11:22:34 +00:00
|
|
|
/**
|
|
|
|
* Integration Testing. Just make sure things are called correctly.
|
|
|
|
*/
|
2009-10-18 21:59:40 +00:00
|
|
|
class ComicPressNavigationTest extends PHPUnit_Framework_TestCase {
|
|
|
|
function setUp() {
|
|
|
|
_reset_wp();
|
|
|
|
$this->nav = new ComicPressNavigation();
|
|
|
|
}
|
|
|
|
|
2009-10-20 11:22:34 +00:00
|
|
|
function testGetPostNav() {
|
2009-10-21 00:40:16 +00:00
|
|
|
$dbi = $this->getMock('ComicPressDBInterface', array('get_previous_comic', 'get_next_comic', 'get_first_comic', 'get_last_comic'));
|
|
|
|
$storyline = new ComicPressStoryline();
|
|
|
|
|
|
|
|
$storyline->_structure = array(
|
|
|
|
'1' => array('next' => 2),
|
|
|
|
'2' => array('previous' => 1, 'next' => 3),
|
|
|
|
'3' => array('previous' => 2)
|
|
|
|
);
|
2009-10-20 11:22:34 +00:00
|
|
|
|
|
|
|
wp_insert_post(array('ID' => 1));
|
|
|
|
$post = get_post(1);
|
|
|
|
|
2009-10-21 00:40:16 +00:00
|
|
|
wp_set_post_categories(1, array(2));
|
2009-10-20 11:22:34 +00:00
|
|
|
|
2009-10-21 00:40:16 +00:00
|
|
|
$dbi->expects($this->at(0))->method('get_previous_comic')->with(null, $post);
|
|
|
|
$dbi->expects($this->at(1))->method('get_next_comic')->with(null, $post);
|
2009-11-06 12:51:32 +00:00
|
|
|
$dbi->expects($this->at(2))->method('get_first_comic')->with(null);
|
|
|
|
$dbi->expects($this->at(3))->method('get_last_comic')->with(null);
|
2009-10-21 00:40:16 +00:00
|
|
|
$dbi->expects($this->at(4))->method('get_previous_comic')->with(2, $post);
|
|
|
|
$dbi->expects($this->at(5))->method('get_next_comic')->with(2, $post);
|
|
|
|
$dbi->expects($this->at(6))->method('get_first_comic')->with(1);
|
|
|
|
$dbi->expects($this->at(7))->method('get_first_comic')->with(3);
|
2009-10-20 11:22:34 +00:00
|
|
|
|
|
|
|
$this->nav->_dbi = $dbi;
|
2009-10-21 00:40:16 +00:00
|
|
|
$this->nav->_storyline = $storyline;
|
2009-10-20 11:22:34 +00:00
|
|
|
|
2009-11-07 16:52:01 +00:00
|
|
|
$this->assertFalse(wp_cache_get('navigation-1', 'comicpress'));
|
|
|
|
|
2009-10-20 11:22:34 +00:00
|
|
|
$this->nav->get_post_nav($post);
|
2009-11-07 16:52:01 +00:00
|
|
|
|
|
|
|
$this->assertTrue(wp_cache_get('navigation-1', 'comicpress') !== false);
|
2009-10-18 21:59:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|