mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 10:47:25 +01:00
Merge pull request #562 from fabio-ivona/1.x-dynamic-properties
Fix tests
This commit is contained in:
@ -5,7 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Actions;
|
namespace Pest\Actions;
|
||||||
|
|
||||||
use Pest\Support\Str;
|
use Pest\Support\Str;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use PHPUnit\Util\FileLoader;
|
use PHPUnit\Util\FileLoader;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Pest\Console\Thanks;
|
use Pest\Console\Thanks;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -8,7 +8,9 @@ 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;
|
use Pest\Support\Str;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -13,11 +13,14 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Logging;
|
namespace Pest\Logging;
|
||||||
|
|
||||||
use function class_exists;
|
use function class_exists;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function method_exists;
|
use function method_exists;
|
||||||
|
|
||||||
use Pest\Concerns\Testable;
|
use Pest\Concerns\Testable;
|
||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\ExceptionWrapper;
|
use PHPUnit\Framework\ExceptionWrapper;
|
||||||
@ -32,9 +35,12 @@ use PHPUnit\Util\Printer;
|
|||||||
use PHPUnit\Util\Xml;
|
use PHPUnit\Util\Xml;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function str_replace;
|
use function str_replace;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -5,10 +5,13 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Logging;
|
namespace Pest\Logging;
|
||||||
|
|
||||||
use function getmypid;
|
use function getmypid;
|
||||||
|
|
||||||
use Pest\Concerns\Logging\WritesToConsole;
|
use Pest\Concerns\Logging\WritesToConsole;
|
||||||
use Pest\Concerns\Testable;
|
use Pest\Concerns\Testable;
|
||||||
use Pest\Support\ExceptionTrace;
|
use Pest\Support\ExceptionTrace;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\Test;
|
use PHPUnit\Framework\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -16,9 +19,11 @@ use PHPUnit\Framework\TestResult;
|
|||||||
use PHPUnit\Framework\TestSuite;
|
use PHPUnit\Framework\TestSuite;
|
||||||
use PHPUnit\Framework\Warning;
|
use PHPUnit\Framework\Warning;
|
||||||
use PHPUnit\TextUI\DefaultResultPrinter;
|
use PHPUnit\TextUI\DefaultResultPrinter;
|
||||||
|
|
||||||
use function round;
|
use function round;
|
||||||
use function str_replace;
|
use function str_replace;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
final class TeamCity extends DefaultResultPrinter
|
final class TeamCity extends DefaultResultPrinter
|
||||||
|
|||||||
@ -5,7 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Plugins;
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,9 +9,15 @@ test('an exception is thrown if the the type is not iterable', function () {
|
|||||||
test('allows for sequences of checks to be run on iterable data', function () {
|
test('allows for sequences of checks to be run on iterable data', function () {
|
||||||
expect([1, 2, 3])
|
expect([1, 2, 3])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(6);
|
expect(static::getCount())->toBe(6);
|
||||||
@ -20,9 +26,15 @@ test('allows for sequences of checks to be run on iterable data', function () {
|
|||||||
test('loops back to the start if it runs out of sequence items', function () {
|
test('loops back to the start if it runs out of sequence items', function () {
|
||||||
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(16);
|
expect(static::getCount())->toBe(16);
|
||||||
@ -31,17 +43,29 @@ test('loops back to the start if it runs out of sequence items', function () {
|
|||||||
test('fails if the number of iterable items is greater than the number of expectations', function () {
|
test('fails if the number of iterable items is greater than the number of expectations', function () {
|
||||||
expect([1, 2])
|
expect([1, 2])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('it works with associative arrays', function () {
|
test('it works with associative arrays', function () {
|
||||||
expect(['foo' => 'bar', 'baz' => 'boom'])
|
expect(['foo' => 'bar', 'baz' => 'boom'])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation, $key) { $expectation->toEqual('bar'); $key->toEqual('foo'); },
|
function ($expectation, $key) {
|
||||||
function ($expectation, $key) { $expectation->toEqual('boom'); $key->toEqual('baz'); },
|
$expectation->toEqual('bar');
|
||||||
|
$key->toEqual('foo');
|
||||||
|
},
|
||||||
|
function ($expectation, $key) {
|
||||||
|
$expectation->toEqual('boom');
|
||||||
|
$key->toEqual('baz');
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +78,9 @@ test('it can be passed non-callable values', function () {
|
|||||||
test('it can be passed a mixture of value types', function () {
|
test('it can be passed a mixture of value types', function () {
|
||||||
expect(['foo', 'bar', 'baz'])->sequence(
|
expect(['foo', 'bar', 'baz'])->sequence(
|
||||||
'foo',
|
'foo',
|
||||||
function ($expectation) { $expectation->toEqual('bar')->toBeString(); },
|
function ($expectation) {
|
||||||
|
$expectation->toEqual('bar')->toBeString();
|
||||||
|
},
|
||||||
'baz'
|
'baz'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\CustomTestCase;
|
namespace Tests\CustomTestCase;
|
||||||
|
|
||||||
use function PHPUnit\Framework\assertTrue;
|
use function PHPUnit\Framework\assertTrue;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class CustomTestCase extends TestCase
|
class CustomTestCase extends TestCase
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\CustomTestCase;
|
namespace Tests\CustomTestCase;
|
||||||
|
|
||||||
use function PHPUnit\Framework\assertTrue;
|
use function PHPUnit\Framework\assertTrue;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ExecutedTest extends TestCase
|
class ExecutedTest extends TestCase
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Pest\Plugins\Version;
|
use Pest\Plugins\Version;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
|
||||||
it('outputs the version when --version is used', function () {
|
it('outputs the version when --version is used', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user