Today, I found a test method in learning phpunit, but I don"t quite understand its principle. This is a test class that failed the test. How should I write the testConsumer method and let the test pass?
A strange thing happened here. When I passed the first test, I reported an error the second time (under thinkphp 5.0). It was very strange.
<?php
namespace tests;
class QuestionTest extends TestCase
{
public function provider()
{
return array(array("provider1"), array("provider2"));
}
public function testProducerFirst()
{
$this->assertTrue(true);
return "first";
}
public function testProducerSecond()
{
$this->assertTrue(true);
return "second";
}
/**
* @depends testProducerFirst
* @depends testProducerSecond
* @dataProvider provider
*/
public function testConsumer()
{
$this->assertEquals(
array("provider1", "first", "second"),
func_get_args()
);
}
}