-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathTestMslsAdminIconTaxonomy.php
76 lines (52 loc) · 2.58 KB
/
TestMslsAdminIconTaxonomy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php declare( strict_types=1 );
namespace lloc\MslsTests;
use Brain\Monkey\Functions;
use lloc\Msls\MslsAdminIconTaxonomy;
class TestMslsAdminIconTaxonomy extends MslsUnitTestCase {
const LANGUAGE = 'de_DE';
const IMAGE_SRC = '/dev/german_flag.png';
protected function setUp(): void {
parent::setUp();
Functions\expect( 'add_query_arg' )->twice()->andReturn( 'https://msls.co/added-args' );
}
public function test_get_img(): void {
Functions\expect( 'get_query_var' )->once()->andReturn( 'post_tag' );
Functions\expect( 'get_taxonomies' )->once()->andReturn( array() );
$obj = ( new MslsAdminIconTaxonomy( 'post_tag' ) )->set_path()->set_language( self::LANGUAGE )->set_src(
self::IMAGE_SRC
);
$expected = sprintf( '<img alt="de_DE" src="%s" />', self::IMAGE_SRC );
$this->assertEquals( $expected, $obj->get_img() );
}
public function test_get_edit_new(): void {
$admin_url = 'https://msls.co/wp-admin/?new_tag';
Functions\expect( 'get_admin_url' )->once()->andReturn( $admin_url );
Functions\expect( 'get_current_blog_id' )->once()->andReturn( 1 );
$obj = ( new MslsAdminIconTaxonomy( 'post_tag' ) )->set_path()->set_language( self::LANGUAGE )->set_src(
self::IMAGE_SRC
);
$this->assertEquals( $admin_url, $obj->get_edit_new() );
}
public function test_set_href(): void {
Functions\expect( 'get_edit_term_link' )->once()->andReturn( 'get-edit-post-link' );
$obj = ( new MslsAdminIconTaxonomy( 'post_tag' ) )->set_path()->set_language( self::LANGUAGE )->set_src(
self::IMAGE_SRC
);
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_href( 42 ) );
$expected = '<a title="Edit the translation in the de_DE-blog" href="get-edit-post-link"><span class="dashicons dashicons-edit"></span></a> ';
$this->assertEquals( $expected, $obj->get_a() );
$this->assertEquals( $expected, $obj->__toString() );
}
public function test_set_href_empty(): void {
Functions\expect( 'get_current_blog_id' )->twice()->andReturn( 1 );
Functions\expect( 'get_edit_term_link' )->once()->andReturn( '' );
Functions\expect( 'get_admin_url' )->twice()->andReturn( 'admin-url-empty' );
$obj = ( new MslsAdminIconTaxonomy( 'post_tag' ) )->set_path()->set_language( self::LANGUAGE )->set_src(
self::IMAGE_SRC
);
$this->assertInstanceOf( MslsAdminIconTaxonomy::class, $obj->set_href( 0 ) );
$expected = '<a title="Create a new translation in the de_DE-blog" href="admin-url-empty"><span class="dashicons dashicons-plus"></span></a> ';
$this->assertEquals( $expected, $obj->get_a() );
$this->assertEquals( $expected, $obj->__toString() );
}
}