-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for Carbon_Breadcrumb_Admin::is_enabled()
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
tests/unit-tests/Carbon_Breadcrumb_Admin/CarbonBreadcrumbAdminIsEnabledTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* @group admin | ||
*/ | ||
class CarbonBreadcrumbAdminIsEnabledTest extends WP_UnitTestCase { | ||
|
||
public function setUp() { | ||
$this->admin = $this->getMock('Carbon_Breadcrumb_Admin', array('current_dir'), array(), '', false); | ||
} | ||
|
||
public function tearDown() { | ||
unset( $this->admin ); | ||
} | ||
|
||
/** | ||
* @covers Carbon_Breadcrumb_Admin::is_enabled | ||
*/ | ||
public function testWhenInstalledAsPlugin() { | ||
$plugins_path = untrailingslashit( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins'; | ||
$this->admin->expects($this->any()) | ||
->method('current_dir') | ||
->will($this->returnValue($plugins_path)); | ||
|
||
$this->assertTrue( $this->admin->is_enabled() ); | ||
} | ||
|
||
/** | ||
* @covers Carbon_Breadcrumb_Admin::is_enabled | ||
* @runInSeparateProcess | ||
*/ | ||
public function testWithAdminConstantDefined() { | ||
$this->admin->expects($this->any()) | ||
->method('current_dir') | ||
->will($this->returnValue(ABSPATH)); | ||
|
||
define('CARBON_BREADCRUMB_ENABLE_ADMIN', true); | ||
|
||
$this->assertTrue( $this->admin->is_enabled() ); | ||
} | ||
|
||
/** | ||
* @covers Carbon_Breadcrumb_Admin::is_enabled | ||
*/ | ||
public function testWithEnablingFilter() { | ||
$this->admin->expects($this->any()) | ||
->method('current_dir') | ||
->will($this->returnValue(ABSPATH)); | ||
|
||
add_filter( 'carbon_breadcrumb_enable_admin', array( $this, '__return_true' ) ); | ||
|
||
$this->assertTrue( $this->admin->is_enabled() ); | ||
|
||
remove_filter( 'carbon_breadcrumb_enable_admin', array( $this, '__return_true' ) ); | ||
} | ||
|
||
/** | ||
* @covers Carbon_Breadcrumb_Admin::is_enabled | ||
*/ | ||
public function testWithNoEnabledConditions() { | ||
$this->admin->expects($this->any()) | ||
->method('current_dir') | ||
->will($this->returnValue(ABSPATH)); | ||
|
||
$this->assertFalse( $this->admin->is_enabled() ); | ||
} | ||
|
||
public function __return_true() { | ||
return true; | ||
} | ||
|
||
} |