aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Models/CategoryTest.php32
-rw-r--r--tests/bootstrap.php7
-rw-r--r--tests/phpunit.xml13
3 files changed, 52 insertions, 0 deletions
diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php
new file mode 100644
index 000000000..da439b785
--- /dev/null
+++ b/tests/app/Models/CategoryTest.php
@@ -0,0 +1,32 @@
+<?php
+
+class FreshRSS_CategoryTest extends \PHPUnit_Framework_TestCase {
+
+ public function test__construct_whenNoParameters_createsObjectWithDefaultValues() {
+ $category = new FreshRSS_Category();
+ $this->assertEquals(0, $category->id());
+ $this->assertEquals('', $category->name());
+ }
+
+ /**
+ * @param string $input
+ * @param string $expected
+ * @dataProvider provideValidNames
+ */
+ public function test_name_whenValidValue_storesModifiedValue($input, $expected) {
+ $category = new FreshRSS_Category($input);
+ $this->assertEquals($expected, $category->name());
+ }
+
+ public function provideValidNames() {
+ return array(
+ array('', ''),
+ array('this string does not need trimming', 'this string does not need trimming'),
+ array(' this string needs trimming on left', 'this string needs trimming on left'),
+ array('this string needs trimming on right ', 'this string needs trimming on right'),
+ array(' this string needs trimming on both ends ', 'this string needs trimming on both ends'),
+ array(str_repeat('This string needs to be shortened because its length is way too long. ', 4), str_repeat('This string needs to be shortened because its length is way too long. ', 3) . 'This string needs to be shortened because its'),
+ );
+ }
+
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 000000000..24340b15c
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,7 @@
+<?php
+
+error_reporting(E_ALL);
+ini_set('display_errors', 1);
+
+require('../constants.php');
+require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader \ No newline at end of file
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
new file mode 100644
index 000000000..f639637ec
--- /dev/null
+++ b/tests/phpunit.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit bootstrap="bootstrap.php">
+ <filter>
+ <whitelist>
+ <directory suffix=".php">../app</directory>
+ </whitelist>
+ </filter>
+ <testsuites>
+ <testsuite name="FreshRSS">
+ <directory>app</directory>
+ </testsuite>
+ </testsuites>
+</phpunit> \ No newline at end of file