Make unit tests pass under Windows
This commit is contained in:
parent
5d15075223
commit
9707c0b4c4
|
|
@ -140,7 +140,7 @@ class FileStorage implements ObjectStorageInterface
|
||||||
*/
|
*/
|
||||||
private function createFolder($key)
|
private function createFolder($key)
|
||||||
{
|
{
|
||||||
$folder = strpos($key, '/') !== false ? $this->path.DIRECTORY_SEPARATOR.dirname($key) : $this->path;
|
$folder = strpos($key, DIRECTORY_SEPARATOR) !== false ? $this->path.DIRECTORY_SEPARATOR.dirname($key) : $this->path;
|
||||||
|
|
||||||
if (! is_dir($folder) && ! mkdir($folder, 0755, true)) {
|
if (! is_dir($folder) && ! mkdir($folder, 0755, true)) {
|
||||||
throw new ObjectStorageException('Unable to create folder: '.$folder);
|
throw new ObjectStorageException('Unable to create folder: '.$folder);
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,10 @@ class Template extends Helper
|
||||||
|
|
||||||
if (strpos($template_name, ':') !== false) {
|
if (strpos($template_name, ':') !== false) {
|
||||||
list($plugin, $template) = explode(':', $template_name);
|
list($plugin, $template) = explode(':', $template_name);
|
||||||
$path = __DIR__.'/../../plugins/'.ucfirst($plugin).'/Template/'.$template.'.php';
|
$path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins';
|
||||||
|
$path .= DIRECTORY_SEPARATOR.ucfirst($plugin).DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.$template.'.php';
|
||||||
} else {
|
} else {
|
||||||
$path = __DIR__.'/../Template/'.$template_name.'.php';
|
$path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.$template_name.'.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
// Enable/disable debug
|
// Enable/disable debug
|
||||||
defined('DEBUG') or define('DEBUG', false);
|
defined('DEBUG') or define('DEBUG', false);
|
||||||
defined('DEBUG_FILE') or define('DEBUG_FILE', __DIR__.'/../data/debug.log');
|
defined('DEBUG_FILE') or define('DEBUG_FILE', __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
||||||
// Plugin directory
|
// Plugin directory
|
||||||
defined('PLUGINS_DIR') or define('PLUGINS_DIR', __DIR__.'/../plugins');
|
defined('PLUGINS_DIR') or define('PLUGINS_DIR', __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins');
|
||||||
|
|
||||||
// Application version
|
// Application version
|
||||||
defined('APP_VERSION') or define('APP_VERSION', 'master');
|
defined('APP_VERSION') or define('APP_VERSION', 'master');
|
||||||
|
|
@ -14,7 +14,7 @@ defined('APP_VERSION') or define('APP_VERSION', 'master');
|
||||||
defined('DB_DRIVER') or define('DB_DRIVER', 'sqlite');
|
defined('DB_DRIVER') or define('DB_DRIVER', 'sqlite');
|
||||||
|
|
||||||
// Sqlite configuration
|
// Sqlite configuration
|
||||||
defined('DB_FILENAME') or define('DB_FILENAME', 'data/db.sqlite');
|
defined('DB_FILENAME') or define('DB_FILENAME', 'data'.DIRECTORY_SEPARATOR.'db.sqlite');
|
||||||
|
|
||||||
// Mysql/Postgres configuration
|
// Mysql/Postgres configuration
|
||||||
defined('DB_USERNAME') or define('DB_USERNAME', 'root');
|
defined('DB_USERNAME') or define('DB_USERNAME', 'root');
|
||||||
|
|
@ -93,7 +93,7 @@ defined('ENABLE_XFRAME') or define('ENABLE_XFRAME', true);
|
||||||
defined('ENABLE_SYSLOG') or define('ENABLE_SYSLOG', true);
|
defined('ENABLE_SYSLOG') or define('ENABLE_SYSLOG', true);
|
||||||
|
|
||||||
// Default files directory
|
// Default files directory
|
||||||
defined('FILES_DIR') or define('FILES_DIR', 'data/files/');
|
defined('FILES_DIR') or define('FILES_DIR', 'data'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Escape html inside markdown text
|
// Escape html inside markdown text
|
||||||
defined('MARKDOWN_ESCAPE_HTML') or define('MARKDOWN_ESCAPE_HTML', true);
|
defined('MARKDOWN_ESCAPE_HTML') or define('MARKDOWN_ESCAPE_HTML', true);
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
define('DEBUG', false);
|
define('DEBUG', false);
|
||||||
|
|
||||||
// Debug file path
|
// Debug file path
|
||||||
define('DEBUG_FILE', __DIR__.'/data/debug.log');
|
define('DEBUG_FILE', __DIR__.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
||||||
// Plugins directory
|
// Plugins directory
|
||||||
define('PLUGINS_DIR', 'data/plugins');
|
define('PLUGINS_DIR', 'data'.DIRECTORY_SEPARATOR.'plugins');
|
||||||
|
|
||||||
// Folder for uploaded files, don't forget the trailing slash
|
// Folder for uploaded files, don't forget the trailing slash
|
||||||
define('FILES_DIR', 'data/files/');
|
define('FILES_DIR', 'data'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// E-mail address for the "From" header (notifications)
|
// E-mail address for the "From" header (notifications)
|
||||||
define('MAIL_FROM', 'notifications@kanboard.local');
|
define('MAIL_FROM', 'notifications@kanboard.local');
|
||||||
|
|
@ -225,4 +225,3 @@ define('HTTP_PROXY_HOSTNAME', '');
|
||||||
define('HTTP_PROXY_PORT', '3128');
|
define('HTTP_PROXY_PORT', '3128');
|
||||||
define('HTTP_PROXY_USERNAME', '');
|
define('HTTP_PROXY_USERNAME', '');
|
||||||
define('HTTP_PROXY_PASSWORD', '');
|
define('HTTP_PROXY_PASSWORD', '');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ abstract class Base extends PHPUnit_Framework_TestCase
|
||||||
$this->container['db']->logQueries = true;
|
$this->container['db']->logQueries = true;
|
||||||
|
|
||||||
$this->container['logger'] = new Logger;
|
$this->container['logger'] = new Logger;
|
||||||
$this->container['logger']->setLogger(new File('/dev/null'));
|
$this->container['logger']->setLogger(new File($this->isWindows() ? 'NUL' : '/dev/null'));
|
||||||
$this->container['httpClient'] = new FakeHttpClient;
|
$this->container['httpClient'] = new FakeHttpClient;
|
||||||
$this->container['emailClient'] = $this->getMockBuilder('EmailClient')->setMethods(array('send'))->getMock();
|
$this->container['emailClient'] = $this->getMockBuilder('EmailClient')->setMethods(array('send'))->getMock();
|
||||||
|
|
||||||
|
|
@ -99,4 +99,9 @@ abstract class Base extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$this->container['db']->closeConnection();
|
$this->container['db']->closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isWindows()
|
||||||
|
{
|
||||||
|
return substr(PHP_OS, 0, 3) === 'WIN';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,34 @@ class TemplateTest extends Base
|
||||||
public function testGetTemplateFile()
|
public function testGetTemplateFile()
|
||||||
{
|
{
|
||||||
$t = new Template($this->container);
|
$t = new Template($this->container);
|
||||||
$this->assertStringEndsWith('app/Core/../Template/a/b.php', $t->getTemplateFile('a/b'));
|
$this->assertStringEndsWith(
|
||||||
|
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'a'.DIRECTORY_SEPARATOR.'b.php',
|
||||||
|
$t->getTemplateFile('a'.DIRECTORY_SEPARATOR.'b')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPluginTemplateFile()
|
public function testGetPluginTemplateFile()
|
||||||
{
|
{
|
||||||
$t = new Template($this->container);
|
$t = new Template($this->container);
|
||||||
$this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/a/b.php', $t->getTemplateFile('myplugin:a/b'));
|
$this->assertStringEndsWith(
|
||||||
|
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'Myplugin'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'a'.DIRECTORY_SEPARATOR.'b.php',
|
||||||
|
$t->getTemplateFile('myplugin:a'.DIRECTORY_SEPARATOR.'b')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOverridedTemplateFile()
|
public function testGetOverridedTemplateFile()
|
||||||
{
|
{
|
||||||
$t = new Template($this->container);
|
$t = new Template($this->container);
|
||||||
$t->setTemplateOverride('a/b', 'myplugin:c');
|
$t->setTemplateOverride('a'.DIRECTORY_SEPARATOR.'b', 'myplugin:c');
|
||||||
$this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/c.php', $t->getTemplateFile('a/b'));
|
|
||||||
$this->assertStringEndsWith('app/Core/../Template/d.php', $t->getTemplateFile('d'));
|
$this->assertStringEndsWith(
|
||||||
|
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'Myplugin'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'c.php',
|
||||||
|
$t->getTemplateFile('a'.DIRECTORY_SEPARATOR.'b')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertStringEndsWith(
|
||||||
|
'app'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'d.php',
|
||||||
|
$t->getTemplateFile('d')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class FileTest extends Base
|
||||||
{
|
{
|
||||||
$f = new File($this->container);
|
$f = new File($this->container);
|
||||||
|
|
||||||
$this->assertStringStartsWith('12/34/', $f->generatePath(12, 34, 'test.png'));
|
$this->assertStringStartsWith('12'.DIRECTORY_SEPARATOR.'34'.DIRECTORY_SEPARATOR, $f->generatePath(12, 34, 'test.png'));
|
||||||
$this->assertNotEquals($f->generatePath(12, 34, 'test1.png'), $f->generatePath(12, 34, 'test2.png'));
|
$this->assertNotEquals($f->generatePath(12, 34, 'test1.png'), $f->generatePath(12, 34, 'test2.png'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ class FileTest extends Base
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('put')
|
->method('put')
|
||||||
->with(
|
->with(
|
||||||
$this->stringContains('1/1/'),
|
$this->stringContains('1'.DIRECTORY_SEPARATOR.'1'.DIRECTORY_SEPARATOR),
|
||||||
$this->equalTo(base64_decode($data))
|
$this->equalTo(base64_decode($data))
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
@ -126,7 +126,7 @@ class FileTest extends Base
|
||||||
$file = $f->getById(1);
|
$file = $f->getById(1);
|
||||||
$this->assertNotEmpty($file);
|
$this->assertNotEmpty($file);
|
||||||
$this->assertStringStartsWith('Screenshot taken ', $file['name']);
|
$this->assertStringStartsWith('Screenshot taken ', $file['name']);
|
||||||
$this->assertStringStartsWith('1/1/', $file['path']);
|
$this->assertStringStartsWith('1'.DIRECTORY_SEPARATOR.'1'.DIRECTORY_SEPARATOR, $file['path']);
|
||||||
$this->assertEquals(1, $file['is_image']);
|
$this->assertEquals(1, $file['is_image']);
|
||||||
$this->assertEquals(1, $file['task_id']);
|
$this->assertEquals(1, $file['task_id']);
|
||||||
$this->assertEquals(time(), $file['date'], '', 2);
|
$this->assertEquals(time(), $file['date'], '', 2);
|
||||||
|
|
@ -149,7 +149,7 @@ class FileTest extends Base
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('put')
|
->method('put')
|
||||||
->with(
|
->with(
|
||||||
$this->stringContains('1/1/'),
|
$this->stringContains('1'.DIRECTORY_SEPARATOR.'1'.DIRECTORY_SEPARATOR),
|
||||||
$this->equalTo(base64_decode($data))
|
$this->equalTo(base64_decode($data))
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
@ -159,7 +159,7 @@ class FileTest extends Base
|
||||||
$file = $f->getById(1);
|
$file = $f->getById(1);
|
||||||
$this->assertNotEmpty($file);
|
$this->assertNotEmpty($file);
|
||||||
$this->assertEquals('my file.pdf', $file['name']);
|
$this->assertEquals('my file.pdf', $file['name']);
|
||||||
$this->assertStringStartsWith('1/1/', $file['path']);
|
$this->assertStringStartsWith('1'.DIRECTORY_SEPARATOR.'1'.DIRECTORY_SEPARATOR, $file['path']);
|
||||||
$this->assertEquals(0, $file['is_image']);
|
$this->assertEquals(0, $file['is_image']);
|
||||||
$this->assertEquals(1, $file['task_id']);
|
$this->assertEquals(1, $file['task_id']);
|
||||||
$this->assertEquals(time(), $file['date'], '', 2);
|
$this->assertEquals(time(), $file['date'], '', 2);
|
||||||
|
|
@ -211,15 +211,15 @@ class FileTest extends Base
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
|
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
|
||||||
|
|
||||||
$this->assertEquals(1, $f->create(1, 'B.pdf', '/tmp/foo1', 10));
|
$this->assertEquals(1, $f->create(1, 'B.pdf', DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo1', 10));
|
||||||
$this->assertEquals(2, $f->create(1, 'A.png', '/tmp/foo2', 10));
|
$this->assertEquals(2, $f->create(1, 'A.png', DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo2', 10));
|
||||||
$this->assertEquals(3, $f->create(1, 'D.doc', '/tmp/foo3', 10));
|
$this->assertEquals(3, $f->create(1, 'D.doc', DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo3', 10));
|
||||||
|
|
||||||
$this->container['objectStorage']
|
$this->container['objectStorage']
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('/tmp/foo2')
|
$this->equalTo(DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo2')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ class FileTest extends Base
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('thumbnails//tmp/foo2')
|
$this->equalTo('thumbnails'.DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo2')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ class FileTest extends Base
|
||||||
->expects($this->at(2))
|
->expects($this->at(2))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('/tmp/foo1')
|
$this->equalTo(DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo1')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
|
@ -243,7 +243,7 @@ class FileTest extends Base
|
||||||
->expects($this->at(3))
|
->expects($this->at(3))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('/tmp/foo3')
|
$this->equalTo(DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'foo3')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue