Skip to content

Instantly share code, notes, and snippets.

@danscotton
Last active August 29, 2015 13:57
Show Gist options
  • Save danscotton/9787202 to your computer and use it in GitHub Desktop.
Save danscotton/9787202 to your computer and use it in GitHub Desktop.
<?php
class MyClassTest extends PHPUnit_Framework_TestCase
{
public function setup()
{
$this->dependency = Phake::mock('Dependency');
$this->myClass = new MyClassOne($this->dependency);
}
public function testAddNumberSendsAddNumberMessageToDependency()
{
$this->myClass->addNumber('one');
Phake::verify($this->dependency)->addNumber('one');
}
public function testGetNumbersReturnsDependencyGetListOfNumbers()
{
$expected = array('one', 'two');
Phake::when($this->dependency)->getListOfNumbers()->thenReturn($expected);
$this->assertEquals($expected, $this->myClass->getNumbers());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment