mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 09:47:23 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd02196950 | |||
| 4de6019206 | |||
| 85630b0aa2 | |||
| 0fda39467c | |||
| 415f571910 | |||
| 8284219035 | |||
| d0d34c7872 | |||
| 2869f11ae5 | |||
| 340c7ca04e | |||
| 81a646d64e | |||
| c23f2e4bd6 | |||
| 4496e9d9ee | |||
| ce14ffd49a | |||
| c18c481628 | |||
| 0695ea5d33 | |||
| 2e321f5465 | |||
| cbeec31bfc |
@ -1,18 +1,19 @@
|
|||||||
name: Continuous Integration
|
name: Formats
|
||||||
|
|
||||||
on: ['push', 'pull_request']
|
on: ['push', 'pull_request']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
php: [7.3, 7.4]
|
os: [ubuntu-latest]
|
||||||
|
php: [7.4]
|
||||||
dependency-version: [prefer-lowest, prefer-stable]
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
|
|
||||||
name: CI - PHP ${{ matrix.php }} (${{ matrix.dependency-version }})
|
name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@ -43,9 +44,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Type Checks
|
- name: Type Checks
|
||||||
run: vendor/bin/phpstan analyse --ansi
|
run: vendor/bin/phpstan analyse --ansi
|
||||||
|
|
||||||
- name: Unit Tests
|
|
||||||
run: bin/pest --colors=always --exclude-group=integration
|
|
||||||
|
|
||||||
- name: Integration Tests
|
|
||||||
run: bin/pest --colors=always --group=integration
|
|
||||||
42
.github/workflows/tests.yml
vendored
Normal file
42
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on: ['push', 'pull_request']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
php: [7.3, 7.4]
|
||||||
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
|
|
||||||
|
name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.composer/cache/files
|
||||||
|
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
extensions: mbstring, zip
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
- name: Unit Tests
|
||||||
|
run: bin/pest --colors=always --exclude-group=integration
|
||||||
|
|
||||||
|
- name: Integration Tests
|
||||||
|
run: bin/pest --colors=always --group=integration
|
||||||
@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [v0.1.4 (2020-05-24)](https://github.com/pestphp/pest/compare/v0.1.3...v0.1.4)
|
||||||
|
### Added
|
||||||
|
- Support to Lumen on artisan commands ([#18](https://github.com/pestphp/pest/pull/18))
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Mockery tests without assertions being considered risky ([415f571](https://github.com/pestphp/pest/commit/415f5719101b30c11d87f74810a71686ef2786c6))
|
||||||
|
|
||||||
## [v0.1.3 (2020-05-21)](https://github.com/pestphp/pest/compare/v0.1.2...v0.1.3)
|
## [v0.1.3 (2020-05-21)](https://github.com/pestphp/pest/compare/v0.1.2...v0.1.3)
|
||||||
### Added
|
### Added
|
||||||
- `Plugin::uses()` method for making traits globally available ([6c4be01](https://github.com/pestphp/pest/commit/6c4be0190e9493702a976b996bbbf5150cc6bb53))
|
- `Plugin::uses()` method for making traits globally available ([6c4be01](https://github.com/pestphp/pest/commit/6c4be0190e9493702a976b996bbbf5150cc6bb53))
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
------
|
------
|
||||||
**Pest** it's an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP.
|
**Pest** is an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP.
|
||||||
|
|
||||||
- Explore the docs: **[pestphp.com »](https://pestphp.com)**
|
- Explore the docs: **[pestphp.com »](https://pestphp.com)**
|
||||||
- Follow us on Twitter: **[@pestphp »](https://twitter.com/pestphp)**
|
- Follow us on Twitter: **[@pestphp »](https://twitter.com/pestphp)**
|
||||||
|
|||||||
@ -7,6 +7,7 @@ namespace Pest\Laravel\Commands;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
|
use Pest\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -36,6 +37,7 @@ final class PestInstallCommand extends Command
|
|||||||
$pest = base_path('tests/Pest.php');
|
$pest = base_path('tests/Pest.php');
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$helpers = base_path('tests/Helpers.php');
|
$helpers = base_path('tests/Helpers.php');
|
||||||
|
$stubs = $this->isLumen() ? 'stubs/Lumen' : 'stubs/Laravel';
|
||||||
|
|
||||||
foreach ([$pest, $helpers] as $file) {
|
foreach ([$pest, $helpers] as $file) {
|
||||||
if (File::exists($file)) {
|
if (File::exists($file)) {
|
||||||
@ -45,17 +47,26 @@ final class PestInstallCommand extends Command
|
|||||||
|
|
||||||
File::copy(implode(DIRECTORY_SEPARATOR, [
|
File::copy(implode(DIRECTORY_SEPARATOR, [
|
||||||
dirname(__DIR__, 3),
|
dirname(__DIR__, 3),
|
||||||
'stubs',
|
$stubs,
|
||||||
'Pest.php',
|
'Pest.php',
|
||||||
]), $pest);
|
]), $pest);
|
||||||
|
|
||||||
File::copy(implode(DIRECTORY_SEPARATOR, [
|
File::copy(implode(DIRECTORY_SEPARATOR, [
|
||||||
dirname(__DIR__, 3),
|
dirname(__DIR__, 3),
|
||||||
'stubs',
|
$stubs,
|
||||||
'Helpers.php',
|
'Helpers.php',
|
||||||
]), $helpers);
|
]), $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.');
|
$this->output->success('`tests/Helpers.php` created successfully.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this is a Lumen application.
|
||||||
|
*/
|
||||||
|
private function isLumen(): bool
|
||||||
|
{
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
return Str::startsWith(app()->version(), 'Lumen');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,12 @@ final class AfterEachRepository
|
|||||||
|
|
||||||
return ChainableClosure::from(function (): void {
|
return ChainableClosure::from(function (): void {
|
||||||
if (class_exists(Mockery::class)) {
|
if (class_exists(Mockery::class)) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
if ($container = Mockery::getContainer()) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
$this->addToAssertionCount($container->mockery_getExpectationCount());
|
||||||
|
}
|
||||||
|
|
||||||
Mockery::close();
|
Mockery::close();
|
||||||
}
|
}
|
||||||
}, $afterEach);
|
}, $afterEach);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use Pest\TestSuite;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the given closure after all tests in the current file.
|
* Runs the given closure before all tests in the current file.
|
||||||
*/
|
*/
|
||||||
function beforeAll(Closure $closure): void
|
function beforeAll(Closure $closure): void
|
||||||
{
|
{
|
||||||
|
|||||||
11
stubs/Lumen/Helpers.php
Normal file
11
stubs/Lumen/Helpers.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currently logged in user for the application.
|
||||||
|
*/
|
||||||
|
function actingAs(Authenticatable $user, string $driver = null): TestCase
|
||||||
|
{
|
||||||
|
return test()->actingAs($user, $driver);
|
||||||
|
}
|
||||||
3
stubs/Lumen/Pest.php
Normal file
3
stubs/Lumen/Pest.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
uses(TestCase::class)->in(__DIR__);
|
||||||
17
stubs/Lumen/phpunit.xml
Normal file
17
stubs/Lumen/phpunit.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Application Test Suite">
|
||||||
|
<directory suffix="Test.php">./tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">./app</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
s it skips with message → skipped because bar
|
s it skips with message → skipped because bar
|
||||||
s it skips with truthy closure condition
|
s 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 messsage → skipped because foo
|
s it skips with condition and message → skipped because foo
|
||||||
|
|
||||||
PASS Tests\Features\Test
|
PASS Tests\Features\Test
|
||||||
✓ a test
|
✓ a test
|
||||||
|
|||||||
@ -11,5 +11,5 @@ it('has bar', function () {
|
|||||||
->times(1)
|
->times(1)
|
||||||
->andReturn(2);
|
->andReturn(2);
|
||||||
|
|
||||||
assertEquals(2, $mock->bar());
|
$mock->bar();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -24,6 +24,6 @@ it('do not skips with falsy closure condition')
|
|||||||
->skip(function () { return false; })
|
->skip(function () { return false; })
|
||||||
->assertTrue(true);
|
->assertTrue(true);
|
||||||
|
|
||||||
it('skips with condition and messsage')
|
it('skips with condition and message')
|
||||||
->skip(true, 'skipped because foo')
|
->skip(true, 'skipped because foo')
|
||||||
->assertTrue(false);
|
->assertTrue(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user