Created
January 28, 2017 14:41
-
-
Save hrs-o/ce935925fb273e33d7005c4d46191831 to your computer and use it in GitHub Desktop.
PHPUnitのtestWithを使ってみる
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 TestWithExample extends \PHPUnit\Framework\TestCase | |
{ | |
/** | |
* @testWith [1, 2, 3] | |
* [1.1, 2.2, 3.3] | |
*/ | |
public function testNum($a, $b, $expected) | |
{ | |
$this->assertEquals($expected, $a + $b); | |
} | |
/** | |
* @testWith ["a", "b", "ab"] | |
*/ | |
public function testStr($a, $b, $expected) | |
{ | |
$this->assertEquals($expected, $a . $b); | |
} | |
/** | |
* @testWith [["a"], ["b"], ["a","b"]] | |
*/ | |
public function testAry($a, $b, $expected) | |
{ | |
$this->assertEquals($expected, array_merge($a, $b)); | |
} | |
// /** | |
// * @testWith [["a"=>1], ["b"=>2], ["a"=>1,"b"=>2]] | |
// */ | |
// public function testHash($a, $b, $expected) | |
// { | |
// $this->assertEquals($expected, array_merge($a, $b)); | |
// } | |
/** | |
* @testWith [{"a": 1}, {"b": 2}, {"a": 1, "b": 2}] | |
*/ | |
public function testHash($a, $b, $expected) | |
{ | |
$this->assertEquals($expected, array_merge($a, $b)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment