comicpress-core/test/backends/ComicPressBackendAttachment...

56 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2009-11-09 03:11:26 +00:00
<?php
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once('backends/ComicPressBackendAttachment.inc');
class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase {
function setUp() {
_reset_wp();
2009-11-11 04:11:48 +00:00
$this->ba = new ComicPressBackendAttachment((object)array('ID' => 1));
2009-11-09 03:11:26 +00:00
}
2009-11-11 04:11:48 +00:00
function providerTestDims() {
return array(
2009-11-19 12:07:04 +00:00
array('comic', false, array()),
array('comic', true, array()),
array('comic', array(), array()),
array('comic', array('dimensions' => '300x200'), array('width' => 300, 'height' => 200)),
2009-12-09 13:21:15 +00:00
array(null, array('default' => true, 'dimensions' => '300x200'), array('width' => 300, 'height' => 200)),
2009-11-19 12:07:04 +00:00
);
2009-11-11 04:11:48 +00:00
}
/**
* @dataProvider providerTestDims
*/
2009-11-19 12:07:04 +00:00
function testDims($which, $image_options, $expected_result) {
2009-11-16 17:35:48 +00:00
$comicpress = ComicPress::get_instance();
$comicpress->comicpress_options = array(
'image_types' => array(
'comic' => $image_options
)
);
2009-11-19 12:07:04 +00:00
$this->assertEquals($expected_result, $this->ba->dims($which));
2009-11-11 04:11:48 +00:00
}
function providerTestUrl() {
return array(
array(false, false),
array(true, false),
array(array(), false),
2009-12-09 13:21:15 +00:00
array(array('url', 300, 200, false), 'url'),
array(array('url', 300, 200, false), 'url', null),
);
2009-11-11 04:11:48 +00:00
}
/**
* @dataProvider providerTestUrl
*/
2009-12-09 13:21:15 +00:00
function testUrl($image_downsize_result, $expected_result, $which = 'comic') {
_set_image_downsize_result(1, 'comic', $image_downsize_result);
2009-11-11 04:11:48 +00:00
$this->assertEquals($expected_result, $this->ba->url('comic'));
}
2009-11-16 17:35:48 +00:00
}