Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. <?php
  2. /**
  3. * this test tests the contains_attribute function
  4. *
  5. * @package test.util
  6. */
  7. /** required, it is the file under test */
  8. require_once('include/text.php');
  9. /**
  10. * TestCase for the contains_attribute function
  11. *
  12. * @author Alexander Kampmann
  13. * @package test.util
  14. */
  15. class ContainsAttributeTest extends PHPUnit_Framework_TestCase {
  16. /**
  17. * test attribute contains
  18. */
  19. public function testAttributeContains1() {
  20. $testAttr="class1 notclass2 class3";
  21. $this->assertTrue(attribute_contains($testAttr, "class3"));
  22. $this->assertFalse(attribute_contains($testAttr, "class2"));
  23. }
  24. /**
  25. * test attribute contains
  26. */
  27. public function testAttributeContains2() {
  28. $testAttr="class1 not-class2 class3";
  29. $this->assertTrue(attribute_contains($testAttr, "class3"));
  30. $this->assertFalse(attribute_contains($testAttr, "class2"));
  31. }
  32. /**
  33. * test with empty input
  34. */
  35. public function testAttributeContainsEmpty() {
  36. $testAttr="";
  37. $this->assertFalse(attribute_contains($testAttr, "class2"));
  38. }
  39. /**
  40. * test input with special chars
  41. */
  42. public function testAttributeContainsSpecialChars() {
  43. $testAttr="--... %\$ä() /(=?}";
  44. $this->assertFalse(attribute_contains($testAttr, "class2"));
  45. }
  46. }