Last active
August 29, 2015 14:24
-
-
Save dnaber-de/b3fcda263ae319042e73 to your computer and use it in GitHub Desktop.
Some example on a simple PHPUnit Mock. Meant as answer to this question: https://twitter.com/Rarst/status/618880034145718272
This file contains hidden or 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 ReleaseTest \PHPUnit_Framework_TestCase { | |
public function testConstructor() { | |
$splFileInfoMock = $this->getMockBuilder( 'SplFileInfo' ) | |
->disableOriginalConstructor() | |
->getMock(); | |
//define the behaviour of the mock | |
$splFileInfoMock->expects( $this->any() ) | |
->method( 'getRelativePath' ) | |
->willReturn( 'your/testing/path' ); | |
$testee = new Rarst\ReleaseBelt\Release( $splFileMock ); | |
// now test the public properties with assertions. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment