Created
February 17, 2014 18:18
-
-
Save cideveloper/9056069 to your computer and use it in GitHub Desktop.
phpunit: Sample Test
This file contains 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 SampleTest extends PHPUnit_Framework_TestCase | |
{ | |
public function setUp() | |
{ | |
} | |
public function tearDown() | |
{ | |
} | |
public function testSuccess() | |
{ | |
$this->assertTrue(true, 'message'); | |
} | |
public function testFail() | |
{ | |
$this->assertTrue(false, 'message'); | |
} | |
/** | |
* @expectedException InvalidArgumentException | |
* @expectedExceptionMessage Exception Message | |
* @expectedExceptionCode 20 | |
*/ | |
public function testExceptions() | |
{ | |
throw new InvalidArgumentException('Exception Message', 20); | |
} | |
/** | |
* @dataProvider provider | |
*/ | |
public function testAdd($a, $b, $c) | |
{ | |
$this->assertEquals($c, $a + $b); | |
} | |
public function provider() | |
{ | |
return array( | |
array(0, 0, 0), | |
array(0, 1, 1), | |
array(1, 0, 1), | |
array(1, 1, 3) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment