fp / fumocker
A php function mocker
Installs: 1 198
Dependents: 3
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 1
Open Issues: 4
Requires
- php: >=5.3.2
This package is auto-updated.
Last update: 2024-07-06 23:44:53 UTC
README
Fumocker ![Build Status](https://camo.githubusercontent.com/2f68467b01f7b2facb6fd235ac6bf163e1e5bb0bff323d5f82fe845443ed62e2/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f666f726d6170726f2f46756d6f636b65722e706e673f6272616e63683d6d6173746572)
Are you wonna mock mail function?
<?php class FooTestCase extends \PHPUnit_Framework_TestCase { /** * @var Fumocker\Fumocker */ protected $fumocker; public function setUp() { $this->fumocker = new \Fumocker\Fumocker; } public function tearDown() { $this->fumocker->cleanup(); } public function testMailNeverCalled() { /** * @var $mock \PHPUnit_Framework_MockObject_MockObject */ $mock = $this->fumocker->getMock('Namespace\Where\Tested\Class\Is', 'mail'); $mock ->expects($this->never()) ->method('mail') ; //test your Namespace\Where\Tested\Class\Is\Foo } public function testMailSendToAdminWithStatisticSubject() { $expectedEmailTo = 'admin@example.com'; /** * @var $mock \PHPUnit_Framework_MockObject_MockObject */ $mock = $this->fumocker->getMock('Namespace\Where\Tested\Class\Is', 'mail'); $mock ->expects($this->once()) ->method('mail') ->with( $this->equalTo($expectedEmailTo), $this->equalTo('Statisitic of money earned by a week') ) ; //test your Namespace\Where\Tested\Class\Is\Foo } public function testRealMailSend() { /** * Dont do a mock and real function will be called */ } }