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
Given there is a short-code 'first-testable-shortcode' | |
When the shortcode is rendered | |
Then it should return 'Hello world!'. |
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
<?php | |
class ShortcodeHelloWorldTest extends \Codeception\TestCase\WPTestCase{ | |
/** | |
* @test | |
* it should render the shortcode | |
*/ | |
public function it_should_render_the_shortcode(){ | |
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
function helloWorld(){ | |
return "Hello World!"; | |
} | |
add_shortcode( 'first-testable-shortcode', 'helloWorld' ); |
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
<?php | |
/** | |
* ARRANGE / GIVEN | |
*/ | |
$I = /*am a */ new AcceptanceTester($scenario); | |
$I->loginAsAdmin(); | |
$I->amOnPage("/wp-admin/post-new.php"); | |
$I->fillField('#content', "[first-testable-shortcode]"); | |
$I->click('#publish'); |
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
actor: UnitTester | |
modules: | |
enabled: | |
- WPLoader | |
- WPQueries | |
- Asserts | |
config: | |
WPLoader: | |
wpRootFolder: /var/www/html | |
dbName: wordpress_unit_test |
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
actor: AcceptanceTester | |
modules: | |
enabled: | |
- WPDb | |
- WPWebDriver | |
- Asserts | |
- \Helper\Acceptance | |
config: | |
WPDb: | |
dsn: 'mysql:host=localhost;dbname=wordpress' |
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
<?php | |
namespace myNamespace; | |
//To use this class add this line to your plugin file: | |
// add_shortcode('helloWorld', array(new $SystemActionEnableShortcodeHelloWorld, 'returnShortcode')); | |
class SystemActionEnableShortcodeHelloWorld{ | |
public function returnShortcode(){ |
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
class_name: AcceptanceTester | |
modules: | |
enabled: | |
- WPDb | |
- WPWebDriver | |
- Asserts | |
- \Helper\Acceptance | |
config: | |
WPDb: | |
dsn: 'mysql:host=localhost;dbname=wordpress' |