Completed
Push — update/add-csstidy-config-sett... ( 30eb4b...0a5859 )
by
unknown
19:15 queued 09:40
created

Test_CSS_Nudge_Customize_Control   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_if_the_html_is_generated_properly() 0 29 1
1
<?php
2
/**
3
 * CSS_Nudge_Customize_Control file.
4
 * Test CSS_Nudge_Customize_Control.
5
 *
6
 * @package Jetpack
7
 */
8
9
namespace Automattic\Jetpack\Dashboard_Customizations;
10
11
require_once ABSPATH . WPINC . '/class-wp-customize-control.php';
12
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
13
14
require_jetpack_file( 'modules/masterbar/nudges/bootstrap.php' );
15
16
/**
17
 * Class Test_CSS_Nudge_Customize_Control
18
 */
19
class Test_CSS_Nudge_Customize_Control extends \WP_UnitTestCase {
20
21
	/**
22
	 * Check if the HTML for the nudge section is properly generated.
23
	 */
24
	public function test_if_the_html_is_generated_properly() {
25
		$manager = new \WP_Customize_Manager();
26
27
		register_css_nudge_control( $manager );
28
		$control = new CSS_Nudge_Customize_Control(
29
			$manager,
30
			'foo',
31
			array(
32
				'cta_url'    => 'https://wordpress.com',
33
				'nudge_copy' => 'foo',
34
			)
35
		);
36
37
		$this->assertEquals( 'https://wordpress.com', $control->cta_url );
38
		$this->assertEquals( 'foo', $control->nudge_copy );
39
		ob_start();
40
		$control->render_content();
41
		$content = ob_get_contents();
42
		ob_end_flush();
43
		$expected_output = '<div class="nudge-container">
44
				<p>
45
					foo
46
				</p>
47
				<div class="button-container">
48
					<button type="button" class="button-primary navigate-to" data-navigate-to-page="https://wordpress.com">Upgrade Now</button>
49
				</div>
50
			</div>';
51
		$this->assertEquals( $expected_output, $content );
52
	}
53
}
54