Commit 5d588d86 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature 5333 / Thumbnail: fixed unit tests

parent 208fd77f
...@@ -20,6 +20,10 @@ class OnString { ...@@ -20,6 +20,10 @@ class OnString {
* @return string * @return string
*/ */
public static function strrstr($haystack, $needle) { public static function strrstr($haystack, $needle) {
return substr($haystack, strpos($haystack, $needle) + 1); if (empty($needle) || empty($haystack)) {
return '';
}
return substr($haystack, strrpos($haystack, $needle) + 1);
} }
} }
...@@ -12,6 +12,7 @@ require_once(__DIR__ . '/../../qfq/helper/OnArray.php'); ...@@ -12,6 +12,7 @@ require_once(__DIR__ . '/../../qfq/helper/OnArray.php');
class OnArrayTest extends \PHPUnit_Framework_TestCase { class OnArrayTest extends \PHPUnit_Framework_TestCase {
public function testSortByKey() { public function testSortByKey() {
$unsorted = [ $unsorted = [
'a' => 'z', 'a' => 'z',
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
namespace qfq; namespace qfq;
require_once(__DIR__ . '/../../qfq/helper/OnString.php');
use qfq; use qfq;
//use qfq\exceptions\CodeException; //use qfq\exceptions\CodeException;
...@@ -17,13 +19,13 @@ use qfq; ...@@ -17,13 +19,13 @@ use qfq;
//require_once(__DIR__ . '/../../qfq/exceptions/CodeException.php'); //require_once(__DIR__ . '/../../qfq/exceptions/CodeException.php');
// //
class StringTest extends \PHPUnit_Framework_TestCase { class OnStringTest extends \PHPUnit_Framework_TestCase {
public function testStrrstr() { public function testStrrstr() {
$this->assertEquals('', String::strrstr('', '')); $this->assertEquals('', OnString::strrstr('', ''));
$this->assertEquals('', String::strrstr('hello world to the limit', '')); $this->assertEquals('', OnString::strrstr('hello world to the limit', ''));
$this->assertEquals('limit', String::strrstr('hello world to the limit', ' ')); $this->assertEquals('limit', OnString::strrstr('hello world to the limit', ' '));
$this->assertEquals('', String::strrstr('', ' ')); $this->assertEquals('', OnString::strrstr('', ' '));
} }
} }
\ No newline at end of file
...@@ -336,6 +336,10 @@ EOT; ...@@ -336,6 +336,10 @@ EOT;
DOCUMENTATION_QFQ => DOCUMENTATION_QFQ_URL, DOCUMENTATION_QFQ => DOCUMENTATION_QFQ_URL,
SYSTEM_ENTER_AS_SUBMIT => 1, SYSTEM_ENTER_AS_SUBMIT => 1,
SYSTEM_CMD_INKSCAPE => 'inkscape',
SYSTEM_CMD_CONVERT => 'convert',
SYSTEM_THUMBNAIL_DIR_PUBLIC => SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT,
SYSTEM_THUMBNAIL_DIR_SECURE => SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT,
]; ];
$fileName = $this->createFile($body); $fileName = $this->createFile($body);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment