Compare commits

...

49 Commits

Author SHA1 Message Date
1241e929b1 docs: updates changelog 2020-07-01 20:26:18 +02:00
db7c4b174f refactor: thanks 2020-07-01 20:23:00 +02:00
460ce45349 Merge pull request #118 from owenvoke/feature/thanks
Add --thanks option plugin
2020-07-01 18:51:54 +02:00
8e203e914e Add test for --thanks 2020-07-01 10:27:12 +01:00
64a8ed04ff Add --thanks option plugin 2020-07-01 10:25:22 +01:00
234b6847ad Merge pull request #115 from owenvoke/feature/changelog
Add next section link to the CHANGELOG
2020-06-29 23:12:30 +02:00
933820c8d3 Add next section link to the CHANGELOG
See: https://github.com/pestphp/website/pull/66#discussion_r447211656
2020-06-29 21:45:59 +01:00
4e9587da59 Merge pull request #114 from rkozlov95/normalize-changelogs
docs: updates changelog
2020-06-29 01:25:01 +02:00
60a5db14ba docs: updates changelog 2020-06-29 02:23:49 +03:00
7ea3e02afa Merge pull request #112 from rkozlov95/add-pull-request-template
add pull request template
2020-06-28 01:48:18 +02:00
421c52fb74 add pull request template 2020-06-28 02:18:24 +03:00
a3644f7efa tests: fixes windows tests 2020-06-26 18:42:57 +02:00
c7326f430b chore: fixes required version of collision 2020-06-26 18:28:47 +02:00
9ea51caf3f feat: adds --version option 2020-06-26 18:17:11 +02:00
cb4c9563bd Merge pull request #109 from Gummibeer/patch-1
pass calls to overloaded method if possible
2020-06-21 18:53:12 +02:00
fac44d9afe revert to first approach by calling __call directly 2020-06-21 18:46:11 +02:00
6e27c6d85d fix tye check 2020-06-21 18:44:04 +02:00
9a0cfaf339 use shorter beforeEach chain syntax 2020-06-21 18:39:47 +02:00
321b3e8df3 use call_user_func_array instead of direct calling __call
add check for __callStatic
2020-06-21 18:31:09 +02:00
bff97418ed do not return $this 2020-06-21 18:27:43 +02:00
a47ad6a1d3 Merge branch 'master' of https://github.com/pestphp/pest into patch-1
# Conflicts:
#	tests/.snapshots/success.txt
2020-06-21 18:25:57 +02:00
74c14808cf rebuild success.txt 2020-06-21 18:24:49 +02:00
eff2d7f613 fix test and add exception test 2020-06-21 18:23:39 +02:00
e135979f34 revert null old-target logic 2020-06-21 18:22:34 +02:00
15edde8e87 docs: updates changelog 2020-06-21 17:43:28 +02:00
211f5c2433 tests: makes incomplete tests success 2020-06-21 17:40:41 +02:00
5d58d58f71 chore: updates phpstan config 2020-06-21 17:40:29 +02:00
d5a4008d3e chore: bumps dev dependencies 2020-06-21 17:40:17 +02:00
1bf802268f Merge pull request #103 from nuernbergerA/feature/depends
Add support for PHPUnit's @depends
2020-06-21 17:10:58 +02:00
807a4b004f Merge branch 'master' into feature/depends 2020-06-21 17:10:51 +02:00
53a8c7b05e add test for new macro behavior 2020-06-21 14:02:56 +02:00
ef5715ce10 ignore null return values and re-use old target 2020-06-21 14:02:42 +02:00
0c04882389 use long exception variable name 2020-06-21 13:08:06 +02:00
323c5f211f pass calls to overloaded method if possible
fix #108
2020-06-21 11:55:32 +02:00
f7a3fa15f4 Merge pull request #101 from fetzi/bugfix/dataset-name-creation
Fix dataset name creation with objects
2020-06-20 21:42:16 +02:00
6dd3ca20e4 Also handle multiple descriptions within whole dataset 2020-06-20 11:29:07 +02:00
d9ea378819 Only append numbers when data set desc is the same 2020-06-20 09:53:38 +02:00
6aa0356570 add more tests 2020-06-19 23:22:14 +02:00
45b0d5d899 feat(depends): adds phpdocs 2020-06-19 21:39:01 +02:00
5be1edd7b7 added missing return types 2020-06-19 21:25:38 +02:00
75f7ee0acf added feedback from @nunomaduro 2020-06-19 20:39:09 +02:00
d0a74931dd implemented support for PHPUnit's @depends 2020-06-19 19:50:54 +02:00
0738e113ad Fix dataset name creation with objects
fixes #98
2020-06-19 16:03:47 +02:00
283d8f3e03 docs: updates changelog 2020-06-17 18:57:54 +02:00
1c3e820283 Merge pull request #97 from fkraefft/fix-traits
Fix in Test Repository use method.
2020-06-17 18:47:00 +02:00
accd4eb7b4 Multiple global uses registered in the same path test added. 2020-06-17 11:57:08 -03:00
ae7991c7e9 Style fixes. 2020-06-17 11:56:24 -03:00
e9e72d607e vscode folder added to gitignore. 2020-06-17 11:55:48 -03:00
40766f9275 Fix in Test Repository use method. 2020-06-17 09:59:46 -03:00
24 changed files with 378 additions and 36 deletions

10
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,10 @@
| Q | A
| ------------- | ---
| Bug fix? | yes/no
| New feature? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
<!--
- Replace this comment by a description of what your PR is solving.
-->

View File

@ -38,6 +38,8 @@ jobs:
section: content section: content
--- ---
${{ steps.package.outputs.content }} ${{ steps.package.outputs.content }}
Next section: [Upgrade Guide →](/docs/upgrade-guide)
write-mode: overwrite write-mode: overwrite
- name: Copy CHANGELOG to website repository - name: Copy CHANGELOG to website repository
run: cp CHANGELOG.md pestphp-website/source/docs/changelog.md run: cp CHANGELOG.md pestphp-website/source/docs/changelog.md

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ coverage.xml
.temp/coverage.php .temp/coverage.php
*.swp *.swp
*.swo *.swo
.vscode/

View File

@ -5,6 +5,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### Added
- `--init` and `pest:install` artisan command output changes ([#118](https://github.com/pestphp/pest/pull/118), [db7c4b1](https://github.com/pestphp/pest/commit/db7c4b174f0974969450dda71dcd649ef0c073a3))
- `--version` option to view the current version of Pest ([9ea51ca](https://github.com/pestphp/pest/commit/9ea51caf3f74569debb1e465992e9ea916cb80fe))
## [v0.2.2 (2020-06-21)](https://github.com/pestphp/pest/compare/v0.2.1...v0.2.2)
### Added
- `depends` phpunit feature ([#103](https://github.com/pestphp/pest/pull/103))
### Fixes
- datasets name conflit ([#101](https://github.com/pestphp/pest/pull/101))
## [v0.2.1 (2020-06-17)](https://github.com/pestphp/pest/compare/v0.2.0...v0.2.1)
### Fixes
- Multiple `uses` in the same path override previous `uses` ([#97](https://github.com/pestphp/pest/pull/97))
## [v0.2.0 (2020-06-14)](https://github.com/pestphp/pest/compare/v0.1.5...v0.2.0) ## [v0.2.0 (2020-06-14)](https://github.com/pestphp/pest/compare/v0.1.5...v0.2.0)
### Adds ### Adds

View File

@ -18,7 +18,7 @@
], ],
"require": { "require": {
"php": "^7.3", "php": "^7.3",
"nunomaduro/collision": "^5.0.0-BETA2", "nunomaduro/collision": "^5.0.0-BETA3",
"pestphp/pest-plugin": "^0.2", "pestphp/pest-plugin": "^0.2",
"pestphp/pest-plugin-coverage": "^0.2", "pestphp/pest-plugin-coverage": "^0.2",
"pestphp/pest-plugin-init": "^0.2", "pestphp/pest-plugin-init": "^0.2",
@ -31,6 +31,7 @@
}, },
"files": [ "files": [
"src/globals.php", "src/globals.php",
"src/Pest.php",
"compiled/globals.php" "compiled/globals.php"
] ]
}, },
@ -43,15 +44,15 @@
] ]
}, },
"require-dev": { "require-dev": {
"ergebnis/phpstan-rules": "^0.14.4", "ergebnis/phpstan-rules": "^0.15.0",
"friendsofphp/php-cs-fixer": "^2.16.3", "friendsofphp/php-cs-fixer": "^2.16.3",
"illuminate/console": "^7.10.3", "illuminate/console": "^7.16.1",
"illuminate/support": "^7.10.3", "illuminate/support": "^7.16.1",
"mockery/mockery": "^1.3.1", "mockery/mockery": "^1.4.0",
"phpstan/phpstan": "^0.12.25", "phpstan/phpstan": "^0.12.30",
"phpstan/phpstan-strict-rules": "^0.12.2", "phpstan/phpstan-strict-rules": "^0.12.2",
"rector/rector": "^0.7.25", "rector/rector": "^0.7.37",
"symfony/var-dumper": "^5.0.8", "symfony/var-dumper": "^5.1.2",
"thecodingmachine/phpstan-strict-rules": "^0.12.0" "thecodingmachine/phpstan-strict-rules": "^0.12.0"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
@ -67,10 +68,10 @@
"compile": "@php ./scripts/compile.php", "compile": "@php ./scripts/compile.php",
"lint": "rector process src && php-cs-fixer fix -v", "lint": "rector process src && php-cs-fixer fix -v",
"test:lint": "php-cs-fixer fix -v --dry-run && rector process src --dry-run", "test:lint": "php-cs-fixer fix -v --dry-run && rector process src --dry-run",
"test:types": "phpstan analyse --ansi", "test:types": "phpstan analyse --ansi --memory-limit=0",
"test:unit": "php bin/pest --colors=always --exclude-group=integration", "test:unit": "php bin/pest --colors=always --exclude-group=integration",
"test:integration": "php bin/pest --colors=always --group=integration", "test:integration": "php bin/pest --colors=always --group=integration",
"test:update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always", "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
"test": [ "test": [
"@test:lint", "@test:lint",
"@test:types", "@test:types",
@ -82,6 +83,11 @@
"branch-alias": { "branch-alias": {
"dev-master": "0.2.x-dev" "dev-master": "0.2.x-dev"
}, },
"pest": {
"plugins": [
"Pest\\Plugins\\Version"
]
},
"laravel": { "laravel": {
"providers": [ "providers": [
"Pest\\Laravel\\PestServiceProvider" "Pest\\Laravel\\PestServiceProvider"

View File

@ -15,9 +15,9 @@ parameters:
reportUnmatchedIgnoredErrors: true reportUnmatchedIgnoredErrors: true
ignoreErrors: ignoreErrors:
- "#Undefined variable: \\$this#"
- "#is not allowed to extend#" - "#is not allowed to extend#"
- "#Language construct eval#" - "#Language construct eval#"
- "# with null as default value#" - "# with null as default value#"
- "#Using \\$this in static method#"
- "#has parameter \\$closure with default value.#" - "#has parameter \\$closure with default value.#"
- "#has parameter \\$description with default value.#" - "#has parameter \\$description with default value.#"

View File

@ -129,16 +129,25 @@ trait TestCase
/** /**
* Runs the test. * Runs the test.
*
* @return mixed
*
* @throws \Throwable
*/ */
public function __test(): void public function __test()
{ {
$this->__callClosure($this->__test, func_get_args()); return $this->__callClosure($this->__test, func_get_args());
} }
private function __callClosure(Closure $closure, array $arguments): void /**
* @return mixed
*
* @throws \Throwable
*/
private function __callClosure(Closure $closure, array $arguments)
{ {
ExceptionTrace::ensure(function () use ($closure, $arguments) { return ExceptionTrace::ensure(function () use ($closure, $arguments) {
call_user_func_array(Closure::bind($closure, $this, get_class($this)), $arguments); return call_user_func_array(Closure::bind($closure, $this, get_class($this)), $arguments);
}); });
} }

66
src/Console/Thanks.php Normal file
View File

@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Pest\Console;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* @internal
*/
final class Thanks
{
/** @var array<int, string> */
private const FUNDING_MESSAGES = [
'',
' - Star or contribute to Pest:',
' <options=bold>https://github.com/pestphp/pest</>',
' - Tweet something about Pest on Twitter:',
' <options=bold>https://twitter.com/pestphp</>',
' - Sponsor the creator:',
' <options=bold>https://github.com/sponsors/nunomaduro</>',
];
/** @var OutputInterface */
private $output;
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
/**
* Asks the user to support Pest.
*/
public function __invoke(): void
{
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
new ArrayInput([]),
$this->output,
new ConfirmationQuestion(
'Can you quickly <options=bold>star our GitHub repository</>? 🙏🏻',
true,
)
);
if ($wantsToSupport === true) {
if (PHP_OS_FAMILY == 'Darwin') {
exec('open https://github.com/pestphp/pest');
}
if (PHP_OS_FAMILY == 'Windows') {
exec('start https://github.com/pestphp/pest');
}
if (PHP_OS_FAMILY == 'Linux') {
exec('xdg-open https://github.com/pestphp/pest');
}
}
foreach (self::FUNDING_MESSAGES as $message) {
$this->output->writeln($message);
}
}
}

View File

@ -74,12 +74,30 @@ final class Datasets
$data = iterator_to_array($data); $data = iterator_to_array($data);
} }
$namedData = []; $dataSetDescriptions = [];
$dataSetValues = [];
foreach ($data as $values) { foreach ($data as $values) {
$values = is_array($values) ? $values : [$values]; $values = is_array($values) ? $values : [$values];
$name = $description . self::getDataSetDescription($values); $dataSetDescriptions[] = $description . self::getDataSetDescription($values);
$namedData[$name] = $values; $dataSetValues[] = $values;
}
foreach (array_count_values($dataSetDescriptions) as $descriptionToCheck => $count) {
if ($count > 1) {
$index = 1;
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
if ($dataSetDescription === $descriptionToCheck) {
$dataSetDescriptions[$i] .= sprintf(' #%d', $index++);
}
}
}
}
$namedData = [];
foreach ($dataSetDescriptions as $i => $dataSetDescription) {
$namedData[$dataSetDescription] = $dataSetValues[$i];
} }
return $namedData; return $namedData;

View File

@ -132,10 +132,14 @@ final class TestCaseFactory
$proxies = $this->proxies; $proxies = $this->proxies;
$factoryTest = $this->test; $factoryTest = $this->test;
$test = function () use ($chains, $proxies, $factoryTest): void { /**
* @return mixed
*/
$test = function () use ($chains, $proxies, $factoryTest) {
$proxies->proxy($this); $proxies->proxy($this);
$chains->chain($this); $chains->chain($this);
call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
return call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
}; };
$className = $this->makeClassFromFilename($this->filename); $className = $this->makeClassFromFilename($this->filename);

View File

@ -59,6 +59,8 @@ final class PestInstallCommand extends Command
$this->output->success('`tests/Pest.php` created successfully.'); $this->output->success('`tests/Pest.php` created successfully.');
$this->output->success('`tests/Helpers.php` created successfully.'); $this->output->success('`tests/Helpers.php` created successfully.');
(new \Pest\Console\Thanks($this->output))();
} }
/** /**

View File

@ -84,6 +84,18 @@ final class TestCall
return $this; return $this;
} }
/**
* Sets the test depends.
*/
public function depends(string ...$tests): TestCall
{
$this->testCaseFactory
->factoryProxies
->add(Backtrace::file(), Backtrace::line(), 'setDependencies', [$tests]);
return $this;
}
/** /**
* Makes the test suite only this test case. * Makes the test suite only this test case.
*/ */
@ -95,7 +107,7 @@ final class TestCall
} }
/** /**
* Sets the test groups(s). * Sets the test group(s).
*/ */
public function group(string ...$groups): TestCall public function group(string ...$groups): TestCall
{ {

10
src/Pest.php Normal file
View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Pest;
function version(): string
{
return '0.2.2';
}

39
src/Plugins/Version.php Normal file
View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
use function Pest\version;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @internal
*/
final class Version implements HandlesArguments
{
/**
* @var OutputInterface
*/
private $output;
/**
* Creates a new instance of the plugin.
*/
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
public function handleArguments(array $arguments): array
{
if (in_array('--version', $arguments, true)) {
$this->output->writeln(
sprintf('Pest %s', version()),
);
}
return $arguments;
}
}

View File

@ -104,7 +104,14 @@ final class TestRepository
} }
foreach ($paths as $path) { foreach ($paths as $path) {
$this->uses[$path] = [$classOrTraits, $groups]; if (array_key_exists($path, $this->uses)) {
$this->uses[$path] = [
array_merge($this->uses[$path][0], $classOrTraits),
array_merge($this->uses[$path][1], $groups),
];
} else {
$this->uses[$path] = [$classOrTraits, $groups];
}
} }
} }

View File

@ -17,11 +17,15 @@ final class ExceptionTrace
/** /**
* Ensures the given closure reports * Ensures the given closure reports
* the good execution context. * the good execution context.
*
* @return mixed
*
* @throws \Throwable
*/ */
public static function ensure(Closure $closure): void public static function ensure(Closure $closure)
{ {
try { try {
$closure(); return $closure();
} catch (Throwable $throwable) { } catch (Throwable $throwable) {
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) { if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) {
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message); $message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);

View File

@ -27,11 +27,19 @@ final class Reflection
{ {
$reflectionClass = new ReflectionClass($object); $reflectionClass = new ReflectionClass($object);
$reflectionMethod = $reflectionClass->getMethod($method); try {
$reflectionMethod = $reflectionClass->getMethod($method);
$reflectionMethod->setAccessible(true); $reflectionMethod->setAccessible(true);
return $reflectionMethod->invoke($object, ...$args); return $reflectionMethod->invoke($object, ...$args);
} catch (ReflectionException $exception) {
if (method_exists($object, '__call')) {
return $object->__call($method, $args);
}
throw $exception;
}
} }
/** /**

View File

@ -41,6 +41,21 @@
✓ eager wrapped registered datasets with (2) ✓ eager wrapped registered datasets with (2)
✓ eager registered wrapped datasets did the job right ✓ eager registered wrapped datasets did the job right
✓ lazy named datasets with (Bar Object (...)) ✓ lazy named datasets with (Bar Object (...))
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #1
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #2
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), false)
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), false)
✓ it creates unique test case names with ('Name 2', Pest\Plugin Object (), true)
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #3
✓ it creates unique test case names - count
PASS Tests\Features\Depends
✓ first
✓ second
✓ depends
✓ depends with ...params
✓ depends with defined arguments
✓ depends run test only once
PASS Tests\Features\Exceptions PASS Tests\Features\Exceptions
✓ it gives access the the underlying expectException ✓ it gives access the the underlying expectException
@ -60,6 +75,10 @@
✓ it is a test ✓ it is a test
✓ it is a higher order message test ✓ it is a higher order message test
PASS Tests\Features\Macro
✓ it can call chained macro method
✓ it will throw exception from call if no macro exists
PASS Tests\Features\Mocks PASS Tests\Features\Mocks
✓ it has bar ✓ it has bar
@ -69,12 +88,12 @@
WARN Tests\Features\Skip WARN Tests\Features\Skip
✓ it do not skips ✓ it do not skips
s it skips with truthy - it skips with truthy
s it skips with truthy condition by default - it skips with truthy condition by default
s it skips with message → skipped because bar - it skips with message → skipped because bar
s it skips with truthy closure condition - it skips with truthy closure condition
✓ it do not skips with falsy closure condition ✓ it do not skips with falsy closure condition
s it skips with condition and message → skipped because foo - it skips with condition and message → skipped because foo
PASS Tests\Features\Test PASS Tests\Features\Test
✓ a test ✓ a test
@ -101,6 +120,7 @@
PASS Tests\Plugins\Traits PASS Tests\Plugins\Traits
✓ it allows global uses ✓ it allows global uses
✓ it allows multiple global uses registered in the same path
PASS Tests\Unit\Actions\AddsDefaults PASS Tests\Unit\Actions\AddsDefaults
✓ it sets defaults ✓ it sets defaults
@ -115,6 +135,10 @@
✓ it throws exception when `process isolation` is true ✓ it throws exception when `process isolation` is true
✓ it do not throws exception when `process isolation` is false ✓ it do not throws exception when `process isolation` is false
PASS Tests\Unit\Plugins\Version
✓ it outputs the version when --version is used
✓ it do not outputs version when --version is not used
PASS Tests\Unit\Support\Backtrace PASS Tests\Unit\Support\Backtrace
✓ it gets file name from called file ✓ it gets file name from called file
@ -141,7 +165,7 @@
✓ it disable decorating printer when colors is set to never ✓ it disable decorating printer when colors is set to never
WARN Tests\Visual\Success WARN Tests\Visual\Success
s visual snapshot of test suite on success - visual snapshot of test suite on success
Tests: 6 skipped, 78 passed Tests: 6 skipped, 96 passed
Time: 3.09s Time: 3.43s

View File

@ -12,4 +12,13 @@ trait PluginTrait
} }
} }
trait SecondPluginTrait
{
public function assertSecondPluginTraitGotRegistered(): void
{
assertTrue(true);
}
}
Pest\Plugin::uses(PluginTrait::class); Pest\Plugin::uses(PluginTrait::class);
Pest\Plugin::uses(SecondPluginTrait::class);

View File

@ -3,6 +3,7 @@
use Pest\Datasets; use Pest\Datasets;
use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\DatasetDoesNotExist;
use Pest\Plugin;
it('throws exception if dataset does not exist', function () { it('throws exception if dataset does not exist', function () {
$this->expectException(DatasetDoesNotExist::class); $this->expectException(DatasetDoesNotExist::class);
@ -106,3 +107,21 @@ $namedDatasets = [
test('lazy named datasets', function ($text) use ($state, $datasets) { test('lazy named datasets', function ($text) use ($state, $datasets) {
assertTrue(true); assertTrue(true);
})->with($namedDatasets); })->with($namedDatasets);
$counter = 0;
it('creates unique test case names', function (string $name, Plugin $plugin, bool $bool) use (&$counter) {
assertTrue(true);
$counter++;
})->with([
['Name 1', new Plugin(), true],
['Name 1', new Plugin(), true],
['Name 1', new Plugin(), false],
['Name 2', new Plugin(), false],
['Name 2', new Plugin(), true],
['Name 1', new Plugin(), true],
]);
it('creates unique test case names - count', function () use (&$counter) {
assertEquals(6, $counter);
});

View File

@ -0,0 +1,40 @@
<?php
$runCounter = 0;
test('first', function () use (&$runCounter) {
assertTrue(true);
$runCounter++;
return 'first';
});
test('second', function () use (&$runCounter) {
assertTrue(true);
$runCounter++;
return 'second';
});
test('depends', function () {
assertEquals(
['first', 'second'],
func_get_args()
);
})->depends('first', 'second');
test('depends with ...params', function (string ...$params) {
assertEquals(
['first', 'second'],
$params
);
})->depends('first', 'second');
test('depends with defined arguments', function (string $first, string $second) {
assertEquals('first', $first);
assertEquals('second', $second);
})->depends('first', 'second');
test('depends run test only once', function () use (&$runCounter) {
assertEquals(2, $runCounter);
})->depends('first', 'second');

16
tests/Features/Macro.php Normal file
View File

@ -0,0 +1,16 @@
<?php
use Illuminate\Support\Traits\Macroable;
use PHPUnit\Framework\TestCase;
uses(Macroable::class);
beforeEach()->macro('bar', function () {
assertInstanceOf(TestCase::class, $this);
});
it('can call chained macro method')->bar();
it('will throw exception from call if no macro exists')
->throws(BadMethodCallException::class)
->foo();

View File

@ -1,3 +1,5 @@
<?php <?php
it('allows global uses')->assertPluginTraitGotRegistered(); it('allows global uses')->assertPluginTraitGotRegistered();
it('allows multiple global uses registered in the same path')->assertSecondPluginTraitGotRegistered();

View File

@ -0,0 +1,20 @@
<?php
use Pest\Plugins\Version;
use Symfony\Component\Console\Output\BufferedOutput;
it('outputs the version when --version is used', function () {
$output = new BufferedOutput();
$plugin = new Version($output);
$plugin->handleArguments(['foo', '--version']);
assertStringContainsString('Pest 0.2.2', $output->fetch());
});
it('do not outputs version when --version is not used', function () {
$output = new BufferedOutput();
$plugin = new Version($output);
$plugin->handleArguments(['foo', 'bar']);
assertEquals('', $output->fetch());
});