assertEquals('RC', tainacan_get_initials($string)); $string = 'Ronaldo'; $this->assertEquals('RO', tainacan_get_initials($string)); $this->assertEquals('R', tainacan_get_initials($string, true)); $string = 'Marilia Mendonça das Neves Costa Silva Fonseca'; $this->assertEquals('MF', tainacan_get_initials($string)); $this->assertEquals('M', tainacan_get_initials($string, true)); $string = 'Machado de Assis'; $this->assertEquals('MA', tainacan_get_initials($string)); $string = 'b'; $this->assertEquals('B', tainacan_get_initials($string)); $string = ''; $this->assertEquals('', tainacan_get_initials($string)); } function test_get_descendants_ids() { $collection = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'status' => 'publish', ), true ); $collection2 = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'status' => 'publish', ), true ); $collection2_c = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'parent' => $collection2->get_id(), 'status' => 'publish', ), true ); $collection2_gc = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'parent' => $collection2_c->get_id(), 'status' => 'publish', ), true ); $collection2_gc2 = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'parent' => $collection2_c->get_id(), 'status' => 'publish', ), true ); $collection2_ggc = $this->tainacan_entity_factory->create_entity( 'collection', array( 'name' => 'test', 'parent' => $collection2_gc->get_id(), 'status' => 'publish', ), true ); $Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance(); $test = $Tainacan_Collections->get_descendants_ids($collection2); $this->assertEquals(4, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2_c); $this->assertEquals(3, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2_gc); $this->assertEquals(1, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2_ggc); $this->assertEquals(0, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection); $this->assertEquals(0, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2, 2); $this->assertEquals(3, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2, 1); $this->assertEquals(1, sizeof($test)); $test = $Tainacan_Collections->get_descendants_ids($collection2_c, 1); $this->assertEquals(2, sizeof($test)); } function test_replace_links_to_clickable_tag() { $text = new \Tainacan\Metadata_Types\Text; $text_no_links = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pharetra sapien quis nunc vulputate dictum. Pellentesque id euismod mauris."; $text_no_links_expected = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pharetra sapien quis nunc vulputate dictum. Pellentesque id euismod mauris."; $text_no_links_response = $text->make_clickable_links($text_no_links); $this->assertEquals($text_no_links_expected, $text_no_links_response); $text_simple_link = "Lorem https://www.tainacan.org/ ipsum dolor sit amet, consectetur adipiscing elit. Sed pharetra sapien quis nunc vulputate dictum. Pellentesque id euismod mauris."; $text_simple_link_expected = 'Lorem https://www.tainacan.org/ ipsum dolor sit amet, consectetur adipiscing elit. Sed pharetra sapien quis nunc vulputate dictum. Pellentesque id euismod mauris.'; $text_simple_link_response = $text->make_clickable_links($text_simple_link); $this->assertEquals($text_simple_link_expected, $text_simple_link_response); $text_multiple_links = 'Lorem https://www.tainacan.org ipsum dolor sit amet http://www.tainacan.org' . ' ftp://www.teste.com.br consectetur adipiscing elit. ftps://www.teste.com.br Sed pharetra sapien quis nunc vulputate dictum.' . ' www.simple.com.br ' . ' www.simple.com ' . ' www.simple.org ' . ' Pellentesque id //ww.lair.com.br of a http://wwwliar.com.br euismod mauris. //pegadinha.com.br '; $text_multiple_links_expected = 'Lorem https://www.tainacan.org ipsum dolor sit amet http://www.tainacan.org' . ' ftp://www.teste.com.br consectetur adipiscing elit. ftps://www.teste.com.br Sed pharetra sapien quis nunc vulputate dictum.' . ' www.simple.com.br ' . ' www.simple.com ' . ' www.simple.org ' . ' Pellentesque id //ww.lair.com.br of a http://wwwliar.com.br euismod mauris. //pegadinha.com.br '; $text_multiple_links_response = $text->make_clickable_links($text_multiple_links); $this->assertEquals($text_multiple_links_expected, $text_multiple_links_response); $text_multiple_links = 'Lorem https://www.tainacan.org Lorem https://tainacan.org hahahahahahhttps://tainacan.org hahaha '; $text_multiple_links_expected = 'Lorem https://www.tainacan.org Lorem https://tainacan.org hahahahahahhttps://tainacan.org hahaha '; $text_multiple_links_response = $text->make_clickable_links($text_multiple_links); $this->assertEquals($text_multiple_links_expected, $text_multiple_links_response); $text_input = 'If you type only www.abc.com without the http the link.'; $text_input_expected = 'If you type only www.abc.com without the http the link.'; $text_input_response = $text->make_clickable_links($text_input); $this->assertEquals($text_input_expected, $text_input_response); } }