start refactoring tests
This commit is contained in:
parent
625318abcc
commit
a6b4fa30d5
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
require_once('classes/ComicPressManager.php');
|
require_once('classes/ComicPressManager.php');
|
||||||
require_once('classes/ComicPressManagerAdmin.php');
|
require_once('classes/ComicPressManagerAdmin.php');
|
||||||
require_once('FirePHPCore/fb.php');
|
//require_once('FirePHPCore/fb.php');
|
||||||
|
|
||||||
include('cp_configuration_options.php');
|
include('cp_configuration_options.php');
|
||||||
|
|
||||||
|
|
|
@ -58,52 +58,45 @@ class ComicPressManagerAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals("", ob_get_clean());
|
$this->assertEquals("", ob_get_clean());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testVerifyPostBeforeHook() {
|
function providerTestVerifyPostBeforeHook() {
|
||||||
|
return array(
|
||||||
|
array(true, null, null, null),
|
||||||
|
array(false, false, null, null),
|
||||||
|
array(false, true, false, null),
|
||||||
|
array(false, true, true, false),
|
||||||
|
array(false, true, true, true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestVerifyPostBeforeHook
|
||||||
|
*/
|
||||||
|
function testVerifyPostBeforeHook($is_managing, $edit_post_integration, $good_post, $is_entry_post) {
|
||||||
global $comicpress_manager;
|
global $comicpress_manager;
|
||||||
|
|
||||||
// managing posts?
|
|
||||||
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
||||||
$comicpress_manager->is_cpm_managing_posts = true;
|
$comicpress_manager->is_cpm_managing_posts = $is_managing;
|
||||||
|
|
||||||
|
$expected_result = false;
|
||||||
|
|
||||||
|
if ($is_managing) {
|
||||||
$comicpress_manager->expects($this->never())->method('get_cpm_option');
|
$comicpress_manager->expects($this->never())->method('get_cpm_option');
|
||||||
$this->assertFalse($this->adm->_verify_post_before_hook(1));
|
} else {
|
||||||
|
|
||||||
// not managing posts? user called, but not managing
|
|
||||||
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
|
||||||
$comicpress_manager->is_cpm_managing_posts = false;
|
|
||||||
$comicpress_manager->expects($this->once())
|
$comicpress_manager->expects($this->once())
|
||||||
->method('get_cpm_option')
|
->method('get_cpm_option')
|
||||||
->will($this->returnValue("0"));
|
->will($this->returnValue($edit_post_integration ? "1" : "0"));
|
||||||
$this->assertFalse($this->adm->_verify_post_before_hook(1));
|
if ($good_post) {
|
||||||
|
|
||||||
// user called, managing, but bad post
|
|
||||||
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
|
||||||
$comicpress_manager->is_cpm_managing_posts = false;
|
|
||||||
$comicpress_manager->expects($this->once())
|
|
||||||
->method('get_cpm_option')
|
|
||||||
->will($this->returnValue("1"));
|
|
||||||
$this->assertFalse($this->adm->_verify_post_before_hook(1));
|
|
||||||
|
|
||||||
// user called, managing, good post but not an Entry
|
|
||||||
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
|
||||||
$comicpress_manager->is_cpm_managing_posts = false;
|
|
||||||
$comicpress_manager->expects($this->once())
|
|
||||||
->method('get_cpm_option')
|
|
||||||
->will($this->returnValue("1"));
|
|
||||||
$id = wp_insert_post(array(
|
$id = wp_insert_post(array(
|
||||||
'post_type' => 'page'
|
'post_type' => $is_entry_post ? "entry" : "page"
|
||||||
));
|
));
|
||||||
$this->assertFalse($this->adm->_verify_post_before_hook($id));
|
|
||||||
|
|
||||||
// is a valid entry
|
if ($is_entry_post) {
|
||||||
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
|
$expected_result = (object)array('post_type' => 'entry', 'ID' => $id);
|
||||||
$comicpress_manager->is_cpm_managing_posts = false;
|
}
|
||||||
$comicpress_manager->expects($this->once())
|
}
|
||||||
->method('get_cpm_option')
|
}
|
||||||
->will($this->returnValue("1"));
|
|
||||||
$id = wp_insert_post(array(
|
$this->assertEquals($expected_result, $this->adm->_verify_post_before_hook($id));
|
||||||
'post_type' => 'entry'
|
|
||||||
));
|
|
||||||
$this->assertEquals((object)array('post_type' => 'entry', 'ID' => $id), $this->adm->_verify_post_before_hook($id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIsPostInComicCategory() {
|
function testIsPostInComicCategory() {
|
||||||
|
|
Loading…
Reference in New Issue