TagsTest.php 826 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class Elgg_TagsTest extends PHPUnit_Framework_TestCase {
  3. /**
  4. * When providing a string to the string_to_tag_array function it should explode it based on a comma and return an array
  5. */
  6. public function testStringToTagArrayReturnsArray() {
  7. // test if it returns an array with 1 item
  8. $single_tag = string_to_tag_array("a");
  9. $this->assertCount(1, $single_tag);
  10. // test if it returns an array with 3 item
  11. $multiple_tags = string_to_tag_array("a,b,c");
  12. $this->assertCount(3, $multiple_tags);
  13. }
  14. /**
  15. * When providing a non-string the string_to_tag_array function should return the original value
  16. */
  17. public function testStringToTagArrayReturnsOriginalValue() {
  18. // test if the original value (int) 1 is returned
  19. $result = string_to_tag_array(1);
  20. $this->assertEquals(1, $result);
  21. }
  22. }