Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created October 2, 2010 12:20
Show Gist options
  • Save nissuk/607598 to your computer and use it in GitHub Desktop.
Save nissuk/607598 to your computer and use it in GitHub Desktop.
PHPUnitの単純な例
<?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