adds tests for terms

This commit is contained in:
Rodrigo de Oliveira 2021-03-12 03:53:13 -03:00
parent 566292eebd
commit 1422887696
2 changed files with 15 additions and 3 deletions

View File

@ -51,11 +51,11 @@ class Term extends Entity {
}
}
public function __toString(){
return apply_filters("tainacan-term-to-string", $this->get_name(), $this);
public function __toString() {
return (string) apply_filters("tainacan-term-to-string", $this->get_name(), $this);
}
public function _toArray(){
public function _toArray() {
$term_array = parent::_toArray();
$term_id = $term_array['term_id'];

View File

@ -21,6 +21,7 @@ class HTML_Injection extends TAINACAN_UnitTestCase
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
// Evil attempts
$link = "<a href='www.tainacan.org'>link</a>";
@ -128,6 +129,17 @@ class HTML_Injection extends TAINACAN_UnitTestCase
/*
* Test terms
*/
$term = $this->tainacan_entity_factory->create_entity(
'term',
array(
'taxonomy' => $taxonomy->get_db_identifier(),
'name' => $css,
),
true
);
$t = $Tainacan_Terms->fetch($term->get_term_id(), $taxonomy);
$this->assertEquals($t->get_name(), 'my text along with some style');
/*
* Test taxonomies