mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 09:47:23 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99205c4aa8 | |||
| 1268384fb3 | |||
| c97fd17120 |
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [v0.1.2 (2020-05-15)](https://github.com/pestphp/pest/compare/v0.1.1...v0.1.2)
|
||||||
|
### Added
|
||||||
|
- Support to custom helpers ([#7](https://github.com/pestphp/pest/pull/7))
|
||||||
|
|
||||||
## [v0.1.1 (2020-05-14)](https://github.com/pestphp/pest/compare/v0.1.0...v0.1.1)
|
## [v0.1.1 (2020-05-14)](https://github.com/pestphp/pest/compare/v0.1.0...v0.1.1)
|
||||||
### Added
|
### Added
|
||||||
- `test` function without any arguments returns the current test case ([6fc55be](https://github.com/pestphp/pest/commit/6fc55becc8aecff685a958617015be1a4c118b01))
|
- `test` function without any arguments returns the current test case ([6fc55be](https://github.com/pestphp/pest/commit/6fc55becc8aecff685a958617015be1a4c118b01))
|
||||||
|
|||||||
@ -22,6 +22,7 @@ final class LoadStructure
|
|||||||
*/
|
*/
|
||||||
private const STRUCTURE = [
|
private const STRUCTURE = [
|
||||||
'Datasets.php',
|
'Datasets.php',
|
||||||
|
'Helpers.php',
|
||||||
'Pest.php',
|
'Pest.php',
|
||||||
'Datasets',
|
'Datasets',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -33,18 +33,29 @@ final class PestInstallCommand extends Command
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$target = base_path('tests/Pest.php');
|
$pest = base_path('tests/Pest.php');
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
$helpers = base_path('tests/Helpers.php');
|
||||||
|
|
||||||
if (File::exists($target)) {
|
foreach ([$pest, $helpers] as $file) {
|
||||||
throw new InvalidConsoleArgument(sprintf('%s already exist', $target));
|
if (File::exists($file)) {
|
||||||
|
throw new InvalidConsoleArgument(sprintf('%s already exist', $file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File::copy(implode(DIRECTORY_SEPARATOR, [
|
File::copy(implode(DIRECTORY_SEPARATOR, [
|
||||||
dirname(__DIR__, 3),
|
dirname(__DIR__, 3),
|
||||||
'stubs',
|
'stubs',
|
||||||
'Pest.php',
|
'Pest.php',
|
||||||
]), $target);
|
]), $pest);
|
||||||
|
|
||||||
|
File::copy(implode(DIRECTORY_SEPARATOR, [
|
||||||
|
dirname(__DIR__, 3),
|
||||||
|
'stubs',
|
||||||
|
'Helpers.php',
|
||||||
|
]), $helpers);
|
||||||
|
|
||||||
$this->output->success('`tests/Pest.php` created successfully.');
|
$this->output->success('`tests/Pest.php` created successfully.');
|
||||||
|
$this->output->success('`tests/Helpers.php` created successfully.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
stubs/Helpers.php
Normal file
12
stubs/Helpers.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currently logged in user for the application.
|
||||||
|
*/
|
||||||
|
function actingAs(Authenticatable $user, string $driver = null): TestCase
|
||||||
|
{
|
||||||
|
return test()->actingAs($user, $driver);
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@ interface Foo
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('has bar', function () {
|
it('has bar', function () {
|
||||||
$mock = Mockery::mock(Foo::class);
|
$mock = mock(Foo::class);
|
||||||
$mock->shouldReceive('bar')
|
$mock->shouldReceive('bar')
|
||||||
->times(1)
|
->times(1)
|
||||||
->andReturn(2);
|
->andReturn(2);
|
||||||
|
|||||||
8
tests/Helpers.php
Normal file
8
tests/Helpers.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Mockery\MockInterface;
|
||||||
|
|
||||||
|
function mock(string $class): MockInterface
|
||||||
|
{
|
||||||
|
return Mockery::mock($class);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user