Completed
Push — try/composer-jetpack-logo-depe... ( 8eeb81 )
by
unknown
07:25
created

WP_Test_Logo::test_render_custom_logo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Jetpack\Assets\Logo;
4
use PHPUnit\Framework\TestCase;
5
6
class WP_Test_Logo extends TestCase {
7
8
	private $logo = null;
9
	protected function setUp() {
10
		$this->logo = new Logo();
11
	}
12
13
	function test_render_default_logo() {
14
		$output = $this->logo->render();
15
		$expected = home_url( '/wp-content/plugins/jetpack/packages/jetpack-logo/assets/images/logo.svg' );
16
		$this->assertContains( $expected, $output );
17
	}
18
19
	function test_render_custom_logo() {
20
		$example_logo = 'logo2.png';
21
		$output = $this->logo->render( $example_logo );
22
		$this->assertContains( $example_logo, $output );
23
	}
24
25
	function test_render_img_tag() {
26
		$output = $this->logo->render();
27
		$url = home_url( '/wp-content/plugins/jetpack/packages/jetpack-logo/assets/images/logo.svg' );
28
		// Contains only a valid img tag.
29
		$this->assertRegExp( '/^<img.*\/>$/', $output );
30
		// Contains the expected src attribute.
31
		$this->assertRegExp( '/.+src="' . preg_quote( $url, '/' ) . '".+/', $output );
32
		// Contains the expected class attribute.
33
		$this->assertRegExp( '/.+class="jetpack-logo".+/', $output );
34
		// Contains an alt attribute.
35
		$this->assertRegExp( '/.+alt="[^"]+".+/', $output );
36
	}
37
}
38