Last active
August 29, 2015 14:02
-
-
Save adamelso/94082070925eddbb5c32 to your computer and use it in GitHub Desktop.
Creating a fake Translator with Spec Behaviour Driven Development using PhpSpec
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 spec\FakeTranslator; | |
use PhpSpec\ObjectBehavior; | |
use Prophecy\Argument; | |
class GreekTranslatorSpec extends ObjectBehavior | |
{ | |
function it_is_a_translator() | |
{ | |
$this->shouldImplement('FakeTranslator\Translator'); | |
} | |
function it_translates_the_word_Welcome_to_Greek() | |
{ | |
$this->translate('Welcome')->shouldReturn('Μαλάκα'); | |
} | |
function it_translates_the_word_Anything_to_Greek() | |
{ | |
$this->translate('Anything')->shouldReturn('Μαλάκα'); | |
} | |
function it_translates_the_word_Yourself_to_Greek() | |
{ | |
$this->translate('Yourself')->shouldReturn('Μαλάκα'); | |
} | |
function it_translates_the_word_Okay_to_Greek() | |
{ | |
$this->translate('Okay')->shouldReturn('Μαλάκα'); | |
} | |
} | |
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 spec\FakeTranslator; | |
use PhpSpec\ObjectBehavior; | |
use Prophecy\Argument; | |
class PolishTranslatorSpec extends ObjectBehavior | |
{ | |
function it_is_a_translator() | |
{ | |
$this->shouldImplement('FakeTranslator\Translator'); | |
} | |
function it_translates_the_word_Hello_to_Polish() | |
{ | |
$this->translate('Hello')->shouldReturn('Kurwa'); | |
} | |
function it_translates_the_word_Something_to_Polish() | |
{ | |
$this->translate('Something')->shouldReturn('Kurwa'); | |
} | |
function it_translates_the_word_Mother_to_Polish() | |
{ | |
$this->translate('Mother')->shouldReturn('Kurwa'); | |
} | |
function it_translates_the_word_Okay_to_Polish() | |
{ | |
$this->translate('Okay')->shouldReturn('Kurwa'); | |
} | |
} |
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 FakeTranslator; | |
interface Translator | |
{ | |
/** | |
* @param string $phrase | |
* | |
* @return string | |
*/ | |
public function translate($phrase); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment