-
Notifications
You must be signed in to change notification settings - Fork 2
/
HookAwareOracleTest.php
74 lines (59 loc) · 1.33 KB
/
HookAwareOracleTest.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
<?php # -*- coding: utf-8 -*-
use Brain\Monkey;
use Brain\Monkey\WP\Filters;
/**
* Test case for the HookAwareOracle class.
*/
class HookAwareOracleTest extends PHPUnit_Framework_TestCase {
/**
* Sets up Brain Monkey.
*
* @return void
*/
public function setUp() {
Monkey::setUpWP();
}
/**
* Tears down Brain Monkey.
*
* @return void
*/
public function tearDown() {
Monkey::tearDownWP();
}
/**
* Tests if the unfiltered answer is returned.
*
* @covers HookAwareOracle::answer()
*
* @return void
*/
public function test_return_unfiltered_answer() {
$this->assertSame(
'42',
( new HookAwareOracle() )->answer(),
'answer() should return the unfiltered answer.'
);
$this->assertSame( 1, did_action( HookAwareOracle::ACTION ) );
$this->assertSame( 1, Monkey::filters()->applied( HookAwareOracle::FILTER ) );
}
/**
* Tests if the filtered answer is returned.
*
* @covers HookAwareOracle::answer()
*
* @return void
*/
public function test_return_filtered_answer() {
$answer = 'some answer here';
Filters::expectApplied( HookAwareOracle::FILTER )
->once()
->andReturn( $answer );
$this->assertSame(
$answer,
( new HookAwareOracle() )->answer(),
'answer() should return the filtered answer.'
);
$this->assertSame( 1, did_action( HookAwareOracle::ACTION ) );
}
}