Skip to content

Instantly share code, notes, and snippets.

@cideveloper
Created February 17, 2014 18:18
Show Gist options
  • Save cideveloper/9056069 to your computer and use it in GitHub Desktop.
Save cideveloper/9056069 to your computer and use it in GitHub Desktop.
phpunit: Sample Test
<?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