summaryrefslogtreecommitdiff
path: root/tests/app/Models/CategoryTest.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:45:37 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:45:37 +0100
commita97bbd9bd54c5fa56d54b3c214cf4e8af96af8b2 (patch)
tree6e83890bc1b3814a12c3b7bedc0d5944f30f507b /tests/app/Models/CategoryTest.php
parent42fd539a1b14f883077048a35864b4294b6efe94 (diff)
parente91b72b63cd11ae3c4f59e48439e93955242c673 (diff)
Merge branch 'dev'
Conflicts: CHANGELOG README.fr.md README.md app/Controllers/feedController.php app/Controllers/indexController.php app/i18n/en.php app/i18n/fr.php app/views/helpers/view/normal_view.phtml app/views/stats/index.phtml app/views/stats/repartition.phtml constants.php p/scripts/main.js
Diffstat (limited to 'tests/app/Models/CategoryTest.php')
-rw-r--r--tests/app/Models/CategoryTest.php32
1 files changed, 32 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'),
+ );
+ }
+
+}