Skip to content

Instantly share code, notes, and snippets.

View JohnDeeBDD's full-sized avatar

John Dee JohnDeeBDD

View GitHub Profile
@JohnDeeBDD
JohnDeeBDD / ShortcodeHelloWorld.feature
Last active November 2, 2017 00:08 — forked from Hitman007/ShortcodeHelloWorld.feature
This is part of a tutorial on WordPress related Behavior Driven Development (BDD). The full tutorial can be found at: https://wordpress-bdd.com/your-first-test/
Given there is a short-code 'first-testable-shortcode'
When the shortcode is rendered
Then it should return 'Hello world!'.
@JohnDeeBDD
JohnDeeBDD / ShortcodeHellowWordTest.php
Last active October 31, 2017 19:36
This is part of a tutorial on WordPress related Behavior Driven Development (BDD). The full tutorial can be found at: https://wordpress-bdd.com/your-first-test/
<?php
class ShortcodeHelloWorldTest extends \Codeception\TestCase\WPTestCase{
/**
* @test
* it should render the shortcode
*/
public function it_should_render_the_shortcode(){
@JohnDeeBDD
JohnDeeBDD / ShortCodeHelloWord.php
Last active October 23, 2017 01:41
This is part of a tutorial on WordPress related Behavior Driven Development (BDD). The full tutorial can be found at: https://wordpress-bdd.com/your-first-test/
function helloWorld(){
return "Hello World!";
}
add_shortcode( 'first-testable-shortcode', 'helloWorld' );
<?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');
@JohnDeeBDD
JohnDeeBDD / unit.suite.yml
Created November 3, 2017 21:44
Codeception sample unit test YML
actor: UnitTester
modules:
enabled:
- WPLoader
- WPQueries
- Asserts
config:
WPLoader:
wpRootFolder: /var/www/html
dbName: wordpress_unit_test
@JohnDeeBDD
JohnDeeBDD / acceptance.suite.yml
Last active November 3, 2017 21:51
A sample YML configuation for acceptance testing WordPress Codeception
actor: AcceptanceTester
modules:
enabled:
- WPDb
- WPWebDriver
- Asserts
- \Helper\Acceptance
config:
WPDb:
dsn: 'mysql:host=localhost;dbname=wordpress'
<?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(){
@JohnDeeBDD
JohnDeeBDD / acceptance.yml
Created March 14, 2018 00:39
WordPress Codeception acceptance YML for multiple environments
class_name: AcceptanceTester
modules:
enabled:
- WPDb
- WPWebDriver
- Asserts
- \Helper\Acceptance
config:
WPDb:
dsn: 'mysql:host=localhost;dbname=wordpress'