2009-12-04 00:13:10 +00:00
|
|
|
<?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();
|
|
|
|
$this->pmh = new ComicPressPostMediaHandlingMetabox();
|
|
|
|
}
|
|
|
|
|
|
|
|
function providerTestPostMediaUpdate() {
|
2009-12-04 00:13:10 +00:00
|
|
|
return array(
|
2009-12-05 03:36:00 +00:00
|
|
|
array(array(), ''),
|
|
|
|
array(array('post_id' => 'test'), ''),
|
|
|
|
array(array('post_id' => 1), array()),
|
|
|
|
array(array('post_id' => 1, 'urls' => false), array()),
|
|
|
|
array(array('post_id' => 1, 'urls' => array()), array()),
|
|
|
|
array(array('post_id' => 1, 'urls' => array('test' => 'test')), array()),
|
|
|
|
array(array('post_id' => 1, 'urls' => array('comic' => 'test')), array('comic' => 'test')),
|
2009-12-04 00:13:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-05 03:36:00 +00:00
|
|
|
* @dataProvider providerTestPostMediaUpdate
|
2009-12-04 00:13:10 +00:00
|
|
|
*/
|
2009-12-05 03:36:00 +00:00
|
|
|
function testPostMediaUpdate($input, $expected_post_metadata) {
|
|
|
|
$pmh = $this->getMock('ComicPressPostMediaHandlingMetabox', array('_get_valid_types'));
|
|
|
|
$pmh->expects($this->any())->method('_get_valid_types')->will($this->returnValue(array('comic')));
|
2009-12-04 00:13:10 +00:00
|
|
|
|
2009-12-05 03:36:00 +00:00
|
|
|
$this->pmh->handle_post_media_update($input);
|
|
|
|
$this->assertEquals($expected_post_metadata, get_post_meta(1, 'backend_url_images', true));
|
2009-12-04 00:13:10 +00:00
|
|
|
}
|
|
|
|
}
|