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 | |
public function testEchoLyric() | |
{ | |
$mockLyric = new \MockLyric('foobar'); | |
$hello = new helloTestable($mockLyric); | |
$this->expectOutputRegex('/.*foobar*./'); | |
$hello->echoLyric(); | |
} |
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 MockLyric | |
{ | |
public function __construct($lyric) | |
{ | |
$this->lyric = $lyric; | |
} | |
public function getLyric() |
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 | |
public function testInit() | |
{ | |
$dummy = new \stdClass(); | |
$hello = new helloTestable($dummy); | |
\WP_Mock::expectActionAdded('admin_notices', array($hello, 'echoLyric')); | |
\WP_Mock::expectActionAdded('admin_head', array($hello, 'echoCss')); |
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 | |
public function testGetLyric() | |
{ | |
$file = dirname(__DIR__) . '/fixtures/lyrics.txt'; | |
$lyrics = new Lyrics($file); | |
\WP_Mock::userFunction('wptexturize', array( | |
'return' => function($s) { | |
return $s . ' wptexturize'; |
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 | |
/** | |
* Output the lyric string | |
*/ | |
public function echoLyric() | |
{ | |
$lyricString = $this->lyrics->getLyric(); | |
echo "<p id='dolly'>$lyricString</p>"; | |
} |
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 | |
/** | |
* Hook up our plugin with WordPress | |
*/ | |
public function init() | |
{ | |
add_action('admin_notices', array($this, 'echoLyric')); | |
add_action('admin_head', array($this, 'echoCss')); | |
} |
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 | |
/** | |
* helloTestable constructor. | |
* | |
* @param Lyrics $lyrics | |
*/ | |
public function __construct($lyrics) | |
{ | |
$this->lyrics = $lyrics; |
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 Lyrics | |
* A class to encapsulate lyrics for a song | |
* | |
* @package helloTestable | |
*/ | |
class Lyrics | |
{ | |
/** |
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 RuntimeProvider | |
* | |
* Use Pimple as dependency injection container | |
* | |
*/ | |
class RuntimeProvider implements ServiceProviderInterface | |
{ | |
/** |
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 | |
/** | |
* The main plugin function. Checks php version | |
* and initialize our classes | |
*/ | |
function helloTestableBootstrap() | |
{ | |
$pluginVersion = '0.1.0'; | |
if (defined('DOING_AJAX') && DOING_AJAX) { | |
return; |