Created
October 2, 2010 12:20
-
-
Save nissuk/607598 to your computer and use it in GitHub Desktop.
PHPUnitの単純な例
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 | |
require_once 'PHPUnit/Framework.php'; | |
class ExampleTest extends PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @dataProvider dataDataProvider | |
*/ | |
function testDataProvider($expected, $input) | |
{ | |
$this->assertEquals($expected, $input); | |
} | |
function dataDataProvider() | |
{ | |
return array( | |
array( array(1 => 1), array('1' => 1) ), | |
); | |
} | |
function testFloat() | |
{ | |
$this->assertEquals(0.101, 0.1, '', 0.01); // true | |
} | |
/** | |
* @expectedException Exception | |
*/ | |
function testException() | |
{ | |
throw new Exception(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment