CategoryTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class CategoryTest extends PHPUnit\Framework\TestCase {
  3. public function test__construct_whenNoParameters_createsObjectWithDefaultValues() {
  4. $category = new FreshRSS_Category();
  5. $this->assertEquals(0, $category->id());
  6. $this->assertEquals('', $category->name());
  7. }
  8. /**
  9. * @param string $input
  10. * @param string $expected
  11. * @dataProvider provideValidNames
  12. */
  13. public function test_name_whenValidValue_storesModifiedValue($input, $expected) {
  14. $category = new FreshRSS_Category($input);
  15. $this->assertEquals($expected, $category->name());
  16. }
  17. public function provideValidNames() {
  18. return array(
  19. array('', ''),
  20. array('this string does not need trimming', 'this string does not need trimming'),
  21. array(' this string needs trimming on left', 'this string needs trimming on left'),
  22. array('this string needs trimming on right ', 'this string needs trimming on right'),
  23. array(' this string needs trimming on both ends ', 'this string needs trimming on both ends'),
  24. array(str_repeat('This string needs to be shortened because its length is way too long. ', 4),
  25. str_repeat('This string needs to be shortened because its length is way too long. ', 3) . 'This string needs to be shortened because its'),
  26. );
  27. }
  28. }