1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Tests for MslsAdminIconTaxonomy |
4
|
|
|
* |
5
|
|
|
* @author Dennis Ploetner <[email protected]> |
6
|
|
|
* @package Msls |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use lloc\Msls\MslsAdminIconTaxonomy; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* WP_Test_MslsAdminIconTaxonomy |
13
|
|
|
*/ |
14
|
|
|
class WP_Test_MslsAdminIconTaxonomy extends Msls_UnitTestCase { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Constructor |
18
|
|
|
*/ |
19
|
|
|
function test_constructor_method() { |
|
|
|
|
20
|
|
|
$user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); |
21
|
|
|
$term_id = $this->factory->term->create(); |
22
|
|
|
wp_set_current_user( $user_id ); |
23
|
|
|
|
24
|
|
|
$obj = new MslsAdminIconTaxonomy( 'post_tag' ); |
25
|
|
|
|
26
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_path() ); |
27
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_language( 'de_DE' ) ); |
28
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_src( '/dev/german_flag.png' ) ); |
29
|
|
|
|
30
|
|
|
$this->assertEquals( '<img alt="de_DE" src="/dev/german_flag.png" />', $obj->get_img() ); |
31
|
|
|
$this->assertInternalType( 'string', $obj->get_edit_new() ); |
32
|
|
|
|
33
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_href( $term_id ) ); |
34
|
|
|
$value = '<a title="Edit the translation in the de_DE-blog" href="http://example.org/wp-admin/term.php?taxonomy=post_tag&tag_ID=' . $term_id . '&post_type=post"><img alt="de_DE" src="/dev/german_flag.png" /></a> '; |
35
|
|
|
$this->assertEquals( $value, $obj->get_a() ); |
36
|
|
|
$this->assertEquals( $value, $obj->__toString() ); |
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_href( 0 ) ); |
39
|
|
|
$value = '<a title="Create a new translation in the de_DE-blog" href="http://example.org/wp-admin/edit-tags.php?taxonomy=post_tag"><img alt="de_DE" src="/dev/german_flag.png" /></a> '; |
40
|
|
|
$this->assertEquals( $value, $obj->get_a() ); |
41
|
|
|
$this->assertEquals( $value, $obj->__toString() ); |
42
|
|
|
|
43
|
|
|
register_taxonomy( 'test_tax_cat', 'page' ); |
44
|
|
|
$term_id = $this->factory->term->create( array( 'taxonomy' => 'test_tax_cat' ) ); |
45
|
|
|
$obj = new MslsAdminIconTaxonomy( 'test_tax_cat' ); |
46
|
|
|
|
47
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_path() ); |
48
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_language( 'it_IT' ) ); |
49
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_src( '/dev/italian_flag.png' ) ); |
50
|
|
|
|
51
|
|
|
$this->assertEquals( '<img alt="it_IT" src="/dev/italian_flag.png" />', $obj->get_img() ); |
52
|
|
|
$this->assertInternalType( 'string', $obj->get_edit_new() ); |
53
|
|
|
|
54
|
|
|
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_href( $term_id ) ); |
55
|
|
|
$value = '<a title="Edit the translation in the it_IT-blog" href="http://example.org/wp-admin/term.php?taxonomy=test_tax_cat&tag_ID=3&post_type=page"><img alt="it_IT" src="/dev/italian_flag.png" /></a> '; |
56
|
|
|
$this->assertEquals( $value, $obj->get_a() ); |
57
|
|
|
$this->assertEquals( $value, $obj->__toString() ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.