Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a strict mode #75

Merged
merged 22 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5b1916e
Add a method to indicate strict mode
johnpbloch Oct 8, 2016
e5072fa
Reformat test
johnpbloch Oct 8, 2016
7e268fa
Add a method to activate strict mode
johnpbloch Oct 8, 2016
156b4c4
Strict mode should only be activated prior to bootstrap
johnpbloch Oct 8, 2016
c7e182b
If strict mode is on, throw an exception for undefined uses in the Ha…
johnpbloch Oct 8, 2016
c11f5b9
Reformat behat test fixtures
johnpbloch Oct 8, 2016
ee60f74
Add a test for strict mode forcing failure for sloppy use
johnpbloch Oct 8, 2016
4a0fd9a
Reformat some yaml
johnpbloch Oct 8, 2016
e0e718f
Add a test to make sure defined but unexpected tests don't fail in re…
johnpbloch Oct 9, 2016
7667de0
Move strict mode controls into the feature context class
johnpbloch Oct 9, 2016
598aec3
Add tests for unexpected action/filters in strict mode
johnpbloch Oct 9, 2016
3005bb5
Make forceStrictModeOff always turn strict mode off
johnpbloch Oct 9, 2016
e332cce
Actions fail on add_action() when strict mode is on and there's no co…
johnpbloch Oct 9, 2016
0a0cde3
Reformat some code
johnpbloch Oct 17, 2016
1eab201
Move strict_check() into HookedCallback
johnpbloch Oct 17, 2016
5f7f176
Improve add_action/filter strict error message
johnpbloch Oct 17, 2016
fe7fd42
Move some methods around to make better reuse of code
johnpbloch Oct 17, 2016
8649cb3
Reformat
johnpbloch Oct 29, 2016
5f2260c
Add a strict check to do_action()
johnpbloch Oct 29, 2016
c85bd66
Add a strict check for unexpected uses of apply_filters()
johnpbloch Oct 29, 2016
e0d080f
Add documentation for strict mode to the readme
johnpbloch Oct 29, 2016
8568683
For internal tests, require phpunit 4.0+
johnpbloch Oct 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add a method to indicate strict mode
  • Loading branch information
johnpbloch committed Oct 8, 2016
commit 5b1916e36440c2f6043c6513837a3b23d2138e2d
11 changes: 11 additions & 0 deletions php/WP_Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class WP_Mock {

protected static $__use_patchwork = false;

protected static $__strict_mode = false;

/**
* @param boolean $use_patchwork
*/
Expand All @@ -61,6 +63,15 @@ public static function usingPatchwork() {
return (bool) self::$__use_patchwork;
}

/**
* Check whether strict mode is turned on
*
* @return bool
*/
public static function strictMode() {
return (bool) self::$__strict_mode;
}

/**
* Bootstrap WP_Mock
*/
Expand Down
9 changes: 9 additions & 0 deletions tests/WP_MockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
class WP_MockTest extends PHPUnit_Framework_TestCase
{

/**
* @runInSeparateProcess
*/
public function test_strictMode_off_by_default()
{
WP_Mock::bootstrap();
$this->assertFalse(WP_Mock::strictMode());
}

public function test_userFunction_returns_expectation()
{
$this->assertInstanceOf(
Expand Down