From 09d50fab0eae5fe673d0097c9f2f7f22e52240b1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 16 Jun 2009 21:20:56 -0400 Subject: [PATCH] a few more assertions for sidebar --- classes/views/ComicPressSidebarStandard.php | 22 ++++++++++---- test/ComicPressSidebarStandardTest.php | 33 ++++++++++++++++++--- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/classes/views/ComicPressSidebarStandard.php b/classes/views/ComicPressSidebarStandard.php index 02db007..1cdc2ee 100644 --- a/classes/views/ComicPressSidebarStandard.php +++ b/classes/views/ComicPressSidebarStandard.php @@ -1,7 +1,18 @@ 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 = ", " . __("multiple files on the same date!", 'comicpress-manager') . ""; } - - $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")); } diff --git a/test/ComicPressSidebarStandardTest.php b/test/ComicPressSidebarStandardTest.php index f5c086d..5fa8e3c 100644 --- a/test/ComicPressSidebarStandardTest.php +++ b/test/ComicPressSidebarStandardTest.php @@ -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']));