comicpress-2.8/test/ComicPressPostMediaHandling...

38 lines
1.2 KiB
PHP
Raw Normal View History

<?php
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once(dirname(__FILE__) . '/../classes/ComicPressPostMediaHandlingMetabox.inc');
class ComicPressPostMediaHandlingMetaboxTest extends PHPUnit_Framework_TestCase {
2009-12-05 03:36:00 +00:00
function setUp() {
_reset_wp();
2009-12-10 12:32:28 +00:00
$_REQUEST = array();
2009-12-05 03:36:00 +00:00
$this->pmh = new ComicPressPostMediaHandlingMetabox();
}
2009-12-10 12:32:28 +00:00
function providerTestSavePost() {
return array(
2009-12-10 12:32:28 +00:00
array(array(), array()),
array(array('urls' => false), array()),
array(array('urls' => array()), array()),
array(array('urls' => array('test' => 'test')), array()),
array(array('urls' => array('comic' => 'test')), array('comic' => 'test')),
);
}
/**
2009-12-10 12:32:28 +00:00
* @dataProvider providerTestSavePost
*/
2009-12-10 12:32:28 +00:00
function testSavePost($input, $expected_post_metadata) {
$pmh = $this->getMock('ComicPressPostMediaHandlingMetabox', array('_get_valid_types', '_verify_nonce'));
$pmh->expects($this->once())->method('_verify_nonce')->will($this->returnValue(true));
2009-12-05 03:36:00 +00:00
$pmh->expects($this->any())->method('_get_valid_types')->will($this->returnValue(array('comic')));
2009-12-10 12:32:28 +00:00
$_REQUEST = array('cp' => $input);
$pmh->save_post(1);
2009-12-05 03:36:00 +00:00
$this->assertEquals($expected_post_metadata, get_post_meta(1, 'backend_url_images', true));
}
}