From b17cdadf15f21dc1e39ec3b270da6ae031072203 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 17 Jan 2015 10:42:24 -0500 Subject: Add the first unit test Add phpunit configuration to run tests and add the first running test to validate the configuration --- tests/app/Models/CategoryTest.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/app/Models/CategoryTest.php (limited to 'tests/app/Models/CategoryTest.php') 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 @@ +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'), + ); + } + +} -- cgit v1.2.3