a few more assertions for sidebar

This commit is contained in:
John Bintz 2009-06-16 21:20:56 -04:00
parent dae7abcbb5
commit 09d50fab0e
2 changed files with 45 additions and 10 deletions

View File

@ -1,7 +1,18 @@
<?php
class ComicPressSidebarStandard extends ComicPressView {
function ComicPressSidebarStandard() {
function ComicPressSidebarStandard() {}
function _get_subdir_path() {
global $comicpress_manager;
$this->subdir_path = '';
if (($subdir = $comicpress_manager->get_subcomic_directory()) !== false) {
$this->subdir_path .= '/' . $subdir;
}
}
function _all_comic_dates_ok() {
global $comicpress_manager;
$this->all_comic_dates_ok = true;
@ -18,16 +29,15 @@ class ComicPressSidebarStandard extends ComicPressView {
if ($this->all_comic_dates_ok) {
$this->too_many_comics_message = ", <em>" . __("multiple files on the same date!", 'comicpress-manager') . "</em>";
}
$this->subdir_path = '';
if (($subdir = $comicpress_manager->get_subcomic_directory()) !== false) {
$this->subdir_path .= '/' . $subdir;
}
}
function render() {
global $comicpress_manager;
$this->_get_subdir_path();
$this->_all_comic_dates_ok();
$this->_get_thumbnail_generation_info();
import($this->_partial_path("sidebar"));
}

View File

@ -6,10 +6,35 @@ require_once(realpath(dirname(__FILE__) . '/../classes/views/ComicPressSidebarSt
require_once(realpath(dirname(__FILE__) . '/../../mockpress/mockpress.php'));
class ComicPressSidebarStandardTest extends PHPUnit_Framework_TestCase {
function testInitialize() {
function testAllComicDatesOK() {
global $comicpress_manager;
$this->markTestIncomplete();
// no comics
$comicpress_manager = $this->getMock('ComicPressManager');
$comicpress_manager->comic_files = array();
$v = new ComicPressSidebarStandard();
$v->_all_comic_dates_ok();
$this->assertTrue($v->all_comic_dates_ok);
// one comic
$comicpress_manager = $this->getMock('ComicPressManager', array('breakdown_comic_filename'));
$comicpress_manager->comic_files = array("test");
$comicpress_manager->expects($this->once())->method('breakdown_comic_filename')->will($this->returnValue(array('date' => "test")));
$v = new ComicPressSidebarStandard();
$v->_all_comic_dates_ok();
$this->assertTrue($v->all_comic_dates_ok);
// two comics
$comicpress_manager = $this->getMock('ComicPressManager', array('breakdown_comic_filename'));
$comicpress_manager->comic_files = array("test", "test2");
$comicpress_manager->expects($this->exactly(2))->method('breakdown_comic_filename')->will($this->returnValue(array('date' => "test")));
$v = new ComicPressSidebarStandard();
$v->_all_comic_dates_ok();
$this->assertFalse($v->all_comic_dates_ok);
}
function providerTestThumbnailGenerationInfo() {
@ -60,11 +85,11 @@ class ComicPressSidebarStandardTest extends PHPUnit_Framework_TestCase {
$comicpress_manager = $this->getMock('ComicPressManager', array('breakdown_comic_filename', 'get_subcomic_directory', 'get_cpm_option'));
$comicpress_manager->expects($this->at(2))
$comicpress_manager->expects($this->at(1))
->method('get_cpm_option')
->with('cpm-archive-generate-thumbnails')
->will($this->returnValue($info['option-archive']));
$comicpress_manager->expects($this->at(3))
$comicpress_manager->expects($this->at(2))
->method('get_cpm_option')
->with('cpm-rss-generate-thumbnails')
->will($this->returnValue($info['option-archive']));