mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 18:57:22 +01:00
test: use throws method instead of assert
This commit is contained in:
@ -8,15 +8,17 @@ it('does not allow to add the same test description twice', function () {
|
|||||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||||
$test = function () {};
|
$test = function () {};
|
||||||
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
$this->expectException(TestAlreadyExist::class);
|
|
||||||
$this->expectExceptionMessage(sprintf('A test with the description `%s` already exist in the filename `%s`.', 'foo', __FILE__));
|
|
||||||
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
});
|
})->throws(
|
||||||
|
TestAlreadyExist::class,
|
||||||
|
sprintf('A test with the description `%s` already exist in the filename `%s`.', 'foo', __FILE__),
|
||||||
|
);
|
||||||
|
|
||||||
it('alerts users about tests with arguments but no input', function () {
|
it('alerts users about tests with arguments but no input', function () {
|
||||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||||
$test = function (int $arg) {};
|
$test = function (int $arg) {};
|
||||||
$this->expectException(DatasetMissing::class);
|
|
||||||
$this->expectExceptionMessage(sprintf("A test with the description '%s' has %d argument(s) ([%s]) and no dataset(s) provided in %s", 'foo', 1, 'int $arg', __FILE__));
|
|
||||||
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new \Pest\Factories\TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
});
|
})->throws(
|
||||||
|
DatasetMissing::class,
|
||||||
|
sprintf("A test with the description '%s' has %d argument(s) ([%s]) and no dataset(s) provided in %s", 'foo', 1, 'int $arg', __FILE__),
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user