-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The previous commit introduced some changes that caused codeception unit tests to break. This commit fixes this by introducing a new service class Transifex_Live_Integration_WP_Services to wrap WP API functionality. This refactoring enables mocking the WP API in the tests. Also a new test class, BaseTestCase, is introduced to cater for different PHPUnit versions between production and development environment.
- Loading branch information
Showing
9 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
<?php | ||
|
||
/* | ||
* Language rewrites | ||
* @package TransifexLiveIntegration | ||
*/ | ||
|
||
/** | ||
* Provides WP services to other classes. | ||
*/ | ||
class Transifex_Live_Integration_WP_Services { | ||
|
||
/* | ||
* Wraps WP site_url(). | ||
* @return string Site URL link with optional path appended. | ||
*/ | ||
function get_site_url() { | ||
return site_url(); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
/* | ||
* This class caters for the different PHPUnit versions between production | ||
* and development. | ||
* To execute unit tests especially during development set an environment | ||
* variable TEST_ENV=<environment> either as 'dev' or 'prod' : | ||
* | ||
* export TEST_ENV=<environment> | ||
* php codecept.phar run unit --debug | ||
*/ | ||
$test_env = null !== getenv('TEST_ENV') ? getenv('TEST_ENV') : 'prod'; | ||
|
||
if ($test_env !== 'dev') { | ||
// php 5.6, production environment | ||
class BaseTestCase extends \PHPUnit_Framework_TestCase {} | ||
} else { | ||
// php 7+, dev environment | ||
class BaseTestCase extends PHPunit\Framework\TestCase {} | ||
} |
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
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
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
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
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
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