Skip to content

Instantly share code, notes, and snippets.

@hrs-o
Created January 28, 2017 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrs-o/ce935925fb273e33d7005c4d46191831 to your computer and use it in GitHub Desktop.
Save hrs-o/ce935925fb273e33d7005c4d46191831 to your computer and use it in GitHub Desktop.
PHPUnitのtestWithを使ってみる
<?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