Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inline and shared datasets for Pest
- Loading branch information
1 parent
acf45a9
commit 9f29d95
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Total: 5 | ||
Total: 11 | ||
|
||
Killed: 4 | ||
Killed: 9 | ||
Errored: 0 | ||
Escaped: 1 | ||
Escaped: 2 | ||
Timed Out: 0 | ||
Skipped: 0 | ||
Not Covered: 0 |
15 changes: 15 additions & 0 deletions
15
tests/e2e/PestTestFramework/src/ForPestWithDataProvider.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace PestTestFramework; | ||
|
||
|
||
final class ForPestWithDataProvider | ||
{ | ||
public function div(float $a, float $b): float | ||
{ | ||
return $a / $b; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
dataset('floats', [ | ||
[1.0, 2.0, 0.5], | ||
[3.0, 3.0, 1.0], | ||
]); |
17 changes: 17 additions & 0 deletions
17
tests/e2e/PestTestFramework/tests/ForPestWithDataProviderTest.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use PestTestFramework\ForPestWithDataProvider; | ||
|
||
test('tests division with inline dataset', function (float $a, float $b, float $expectedResult) { | ||
$sourceClass = new ForPestWithDataProvider(); | ||
|
||
expect($sourceClass->div($a, $b))->toBe($expectedResult); | ||
})->with([ | ||
[2.0, 4.0, 0.5] | ||
]); | ||
|
||
test('tests division with shared dataset', function (float $a, float $b, float $expectedResult) { | ||
$sourceClass = new ForPestWithDataProvider(); | ||
|
||
expect($sourceClass->div($a, $b))->toBe($expectedResult); | ||
})->with('floats'); |