mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 09:17:23 +01:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1241e929b1 | |||
| db7c4b174f | |||
| 460ce45349 | |||
| 8e203e914e | |||
| 64a8ed04ff | |||
| 234b6847ad | |||
| 933820c8d3 | |||
| 4e9587da59 | |||
| 60a5db14ba | |||
| 7ea3e02afa | |||
| 421c52fb74 | |||
| a3644f7efa | |||
| c7326f430b | |||
| 9ea51caf3f | |||
| cb4c9563bd | |||
| fac44d9afe | |||
| 6e27c6d85d | |||
| 9a0cfaf339 | |||
| 321b3e8df3 | |||
| bff97418ed | |||
| a47ad6a1d3 | |||
| 74c14808cf | |||
| eff2d7f613 | |||
| e135979f34 | |||
| 53a8c7b05e | |||
| ef5715ce10 | |||
| 0c04882389 | |||
| 323c5f211f |
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal 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.
|
||||||
|
-->
|
||||||
|
|
||||||
2
.github/workflows/changelog.yml
vendored
2
.github/workflows/changelog.yml
vendored
@ -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
|
||||||
|
|||||||
@ -5,6 +5,9 @@ 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)
|
## [v0.2.2 (2020-06-21)](https://github.com/pestphp/pest/compare/v0.2.1...v0.2.2)
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -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"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -67,7 +68,7 @@
|
|||||||
"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",
|
||||||
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
|
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always",
|
||||||
@ -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"
|
||||||
|
|||||||
66
src/Console/Thanks.php
Normal file
66
src/Console/Thanks.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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))();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
10
src/Pest.php
Normal file
10
src/Pest.php
Normal 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
39
src/Plugins/Version.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -75,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
|
||||||
|
|
||||||
@ -84,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
|
||||||
@ -131,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
|
||||||
|
|
||||||
@ -157,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, 92 passed
|
Tests: 6 skipped, 96 passed
|
||||||
Time: 3.40s
|
Time: 3.43s
|
||||||
|
|||||||
16
tests/Features/Macro.php
Normal file
16
tests/Features/Macro.php
Normal 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();
|
||||||
20
tests/Unit/Plugins/Version.php
Normal file
20
tests/Unit/Plugins/Version.php
Normal 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());
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user