Skip to content

Instantly share code, notes, and snippets.

@rtuin
Created July 19, 2015 14:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rtuin/95e9248d437aabf23909 to your computer and use it in GitHub Desktop.
Simplified PHPSpec + Wordpress approach
<?php
namespace MyApp
{
class Foo
{
public function interactWithWordpress()
{
return get_option('my_option_name');
}
}
}
<?php
namespace spec\MyApp
{
class FooSpec
{
function it_shows()
{
WordpressOptions::$options['my_option_name'] = 'bar';
$this->interactWithWordpress()->shouldReturn('bar');
}
}
class WordpressOptions
{
public static $options = [];
}
}
namespace MyApp
{
use spec\MyApp\WordpressOptions;
function get_option($optionName)
{
return WordpressOptions::$options[$optionName];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment