|
1
|
|
|
<?php |
|
2
|
|
|
/*! |
|
3
|
|
|
* WordPress Social Login |
|
4
|
|
|
* |
|
5
|
|
|
* https://miled.github.io/wordpress-social-login/ | https://github.com/miled/wordpress-social-login |
|
6
|
|
|
* (c) 2011-2020 Mohamed Mrassi and contributors | https://wordpress.org/plugins/wordpress-social-login/ |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
class WSL_Test_Widget extends WP_UnitTestCase |
|
10
|
|
|
{ |
|
11
|
|
|
function setUp() |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
parent::setUp(); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
function tearDown() |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
parent::tearDown(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
function test_has_action() |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
$test = has_action( 'wordpress_social_login', 'wsl_action_wordpress_social_login' ); |
|
24
|
|
|
$this->assertTrue( (bool) $test ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function test_shortcode_exists() |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$test = shortcode_exists( 'wordpress_social_login' ); |
|
30
|
|
|
$this->assertTrue( (bool) $test ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function test_did_actions() |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
wsl_render_auth_widget(); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertEquals( 1, did_action( 'wsl_render_auth_widget_start' ) ); |
|
38
|
|
|
$this->assertEquals( 1, did_action( 'wsl_render_auth_widget_end' ) ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/* |
|
42
|
|
|
* hacky way of checking for correct css selectors |
|
43
|
|
|
*/ |
|
44
|
|
|
function test_has_content() |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$test = wsl_render_auth_widget(); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertTrue( (bool) $test ); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertEquals( 1, substr_count( $test, '"wp-social-login-widget"' ) ); |
|
51
|
|
|
$this->assertEquals( 1, substr_count( $test, '"wp-social-login-connect-with"' ) ); |
|
52
|
|
|
$this->assertEquals( 1, substr_count( $test, '"wp-social-login-provider-list"' ) ); |
|
53
|
|
|
$this->assertEquals( 3, substr_count( $test, '"wp-social-login-provider ' ) ); |
|
54
|
|
|
$this->assertEquals( 1, substr_count( $test, ' wp-social-login-provider-google' ) ); |
|
55
|
|
|
$this->assertEquals( 1, substr_count( $test, '"wp-social-login-widget-clearing"' ) ); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
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.