diff options
| author | 2017-02-15 14:14:03 +0100 | |
|---|---|---|
| committer | 2017-02-15 14:14:03 +0100 | |
| commit | 5a1bb1393b4496eb35a2ffb3cc63d41c9dc1e2e5 (patch) | |
| tree | 67028e45792c575c25c92616633f64cc7a4a13eb /tests/app/Models/CategoryTest.php | |
| parent | 7e949d50320317b5c3b5a2da2bdaf324e794b2f7 (diff) | |
| parent | 5f637bd816b7323885bfe1751a1724ee59a822f6 (diff) | |
Merge remote-tracking branch 'FreshRSS/master'
Diffstat (limited to 'tests/app/Models/CategoryTest.php')
| -rw-r--r-- | tests/app/Models/CategoryTest.php | 32 |
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'), + ); + } + +} |
