comicpress-core/test/backends/ComicPressBackendFilesystemTest.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2009-11-24 12:52:53 +00:00
<?php
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once('backends/ComicPressBackendFilesystem.inc');
2009-11-25 00:33:16 +00:00
require_once('ComicPress.inc');
2009-11-24 12:52:53 +00:00
require_once('vfsStream/vfsStream.php');
class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
function setUp() {
_reset_wp();
$this->fs = new ComicPressBackendFilesystem();
2009-11-25 00:19:53 +00:00
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
2009-11-24 12:52:53 +00:00
}
2010-02-02 03:41:56 +00:00
function providerTestDims() {
return array(
array(false, array()),
array(
array(
200, 100, 300
),
array(
'width' => 200,
'height' => 100
)
)
);
}
/**
* @dataProvider providerTestDims
*/
function testDims($getimagesize_return, $expected_result) {
$fs = $this->getMock('ComicPressBackendFilesystem', array('_getimagesize', 'ensure_type'));
$fs->expects($this->once())->method('ensure_type')->with('type')->will($this->returnValue('newtype'));
$fs->expects($this->once())->method('_getimagesize')->with('file')->will($this->returnValue($getimagesize_return));
$fs->files_by_type = array('newtype' => 'file');
$this->assertEquals($expected_result, $fs->dims('type'));
}
function testUrl() {
$fs = $this->getMock('ComicPressBackendFilesystem', array('ensure_type'));
$fs->expects($this->once())->method('ensure_type')->with('type')->will($this->returnValue('newtype'));
$fs->file_urls_by_type = array('newtype' => 'url');
$this->assertEquals('url', $fs->url('type'));
}
2010-02-02 12:49:09 +00:00
function testGetImageSize() {
$result = $this->fs->_getimagesize(dirname(__FILE__) . '/../files/test.png');
$this->assertTrue(is_array($result));
$this->assertEquals(20, $result[0]);
$this->assertEquals(10, $result[1]);
}
2009-11-25 03:15:34 +00:00
}