feat(expect): updates test suite to use expectation api

This commit is contained in:
Nuno Maduro
2020-07-14 23:15:14 +02:00
parent e03d015120
commit 832882160f
37 changed files with 151 additions and 257 deletions

View File

@ -3,7 +3,6 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'bin')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'compiled')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'scripts')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'stubs')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')

View File

@ -62,6 +62,16 @@ final class Expectation
return $this;
}
/**
* Assert the value is true.
*/
public function toBeTrue(): Expectation
{
Assert::assertTrue($this->value);
return $this;
}
/**
* Assert the value is false.
*/
@ -123,62 +133,23 @@ final class Expectation
/**
* Assert that needles is an element of value.
*
* @param mixed $needle
* @param mixed $value
*/
public function toContain($needle): Expectation
public function toContain($value): Expectation
{
Assert::assertContains($needle, $this->value);
return $this;
if (is_string($value)) {
Assert::assertStringContainsString($value, $this->value);
} else {
Assert::assertContains($value, $this->value);
}
/**
* Assert the value contains only variables of type.
*
* @param mixed $type
*/
public function toContainOnly($type): Expectation
{
Assert::assertContainsOnly($type, $this->value);
return $this;
}
/**
* Assert the value contains only instances of $instance.
*/
public function toContainOnlyInstancesOf(string $instance): Expectation
{
Assert::assertContainsOnlyInstancesOf($instance, $this->value);
return $this;
}
/**
* Assert that needles is a substring of value.
*/
public function toContainString(string $needle): Expectation
{
Assert::assertStringContainsString($needle, $this->value);
return $this;
}
/**
* Assert that needles is a substring of value, ignoring the
* difference in casing.
*/
public function toContainStringIgnoringCase(string $needle): Expectation
{
Assert::assertStringContainsStringIgnoringCase($needle, $this->value);
return $this;
}
/**
* Assert that $count matches the number of elements of $value.
*/
public function toCount(int $count): Expectation
public function toHaveCount(int $count): Expectation
{
Assert::assertCount($count, $this->value);
@ -234,7 +205,7 @@ final class Expectation
*
* @param mixed $value
*/
public function toEqualWithDelta($value, float $delta): Expectation
public function toBeEqualWithDelta($value, float $delta): Expectation
{
Assert::assertEqualsWithDelta($value, $this->value, $delta);
@ -254,11 +225,12 @@ final class Expectation
/**
* Assert that the value is an instance of $value.
*
* @param mixed $value
* @param string $class
*/
public function toBeInstanceOf($value): Expectation
public function toBeInstanceOf($class): Expectation
{
Assert::assertInstanceOf($value, $this->value);
/* @phpstan-ignore-next-line */
Assert::assertInstanceOf($class, $this->value);
return $this;
}
@ -384,7 +356,7 @@ final class Expectation
}
/**
* Assert that the value is NAN.
* Assert that the value is null.
*/
public function toBeNull(): Expectation
{

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest\PendingObjects;
use Closure;
use Pest\Expectation;
use Pest\Factories\TestCaseFactory;
use Pest\Support\Backtrace;
use Pest\Support\NullClosure;
@ -84,6 +85,16 @@ final class TestCall
return $this;
}
/**
* Creates a new expectation.
*
* @param mixed $value the Value
*/
public function expect($value): Expectation
{
return expect($value);
}
/**
* Sets the test depends.
*/

View File

@ -108,6 +108,8 @@ function afterAll(Closure $closure = null): void
/**
* Creates a new expectation.
*
* @param mixed $value the Value
*/
function expect($value): Expectation
{

View File

@ -110,31 +110,16 @@
PASS Tests\Expect\toBeString
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toBeTrue
✓ strict comparisons
✓ failures
✓ not failures
PASS Tests\Expect\toContain
✓ passes
✓ failures
✓ not failures
PASS Tests\Expect\toContainOnly
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toContainOnlyInstancesOf
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toContainString
✓ is case sensitive
✓ failures
✓ not failures
PASS Tests\Expect\toContainStringIgnoringCase
✓ ignore difference in casing
✓ failures
✓ not failures
PASS Tests\Expect\toCount
@ -231,9 +216,9 @@
PASS Tests\Features\HigherOrderTests
✓ it proxies calls to object
PASS Tests\Features\It
WARN Tests\Features\It
✓ it is a test
it is a higher order message test
! it is a higher order message test → This test did not perform any assertions /Users/nunomaduro/pestphp/pest/src/Factories/TestCaseFactory.php(204) : eval()'d code:4
PASS Tests\Features\Macro
✓ it can call chained macro method
@ -243,8 +228,8 @@
✓ it has bar
PASS Tests\Features\PendingHigherOrderTests
✓ get 'foo' → get 'bar' → assertTrue true
✓ get 'foo' → assertTrue true
✓ get 'foo' → get 'bar'
✓ get 'foo'
WARN Tests\Features\Skip
✓ it do not skips
@ -255,9 +240,9 @@
✓ it do not skips with falsy closure condition
- it skips with condition and message → skipped because foo
PASS Tests\Features\Test
WARN Tests\Features\Test
✓ a test
higher order message test
! higher order message test → This test did not perform any assertions /Users/nunomaduro/pestphp/pest/src/Factories/TestCaseFactory.php(204) : eval()'d code:4
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
✓ it example 1
@ -327,5 +312,5 @@
WARN Tests\Visual\Success
- visual snapshot of test suite on success
Tests: 6 skipped, 192 passed
Time: 5.20s
Tests: 2 risked, 6 skipped, 181 passed
Time: 5.72s

View File

@ -8,7 +8,7 @@ trait PluginTrait
{
public function assertPluginTraitGotRegistered(): void
{
assertTrue(true);
$this->assertTrue(true);
}
}
@ -16,7 +16,7 @@ trait SecondPluginTrait
{
public function assertSecondPluginTraitGotRegistered(): void
{
assertTrue(true);
$this->assertTrue(true);
}
}

15
tests/Expect/toBeTrue.php Normal file
View File

@ -0,0 +1,15 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('strict comparisons', function () {
expect(true)->toBeTrue();
});
test('failures', function () {
expect('')->toBeTrue();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(false)->not->toBe(false);
})->throws(ExpectationFailedException::class);

View File

@ -1,17 +0,0 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toContainOnly('int');
expect(['hello', 'world'])->toContainOnly('string');
});
test('failures', function () {
expect([1, 2, '3'])->toContainOnly('string');
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect([1, 2, 3])->not->toContainOnly('int');
expect(['hello', 'world'])->not->toContainOnly('string');
})->throws(ExpectationFailedException::class);

View File

@ -1,23 +0,0 @@
<?php
use Pest\Actions\AddsTests;
use Pest\Expectation;
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
$expected = [new Expectation('whatever')];
expect($expected)->toContainOnlyInstancesOf(Expectation::class);
});
test('failures', function () {
$expected = [new Expectation('whatever')];
expect($expected)->toContainOnlyInstancesOf(AddsTests::class);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
$expected = [new Expectation('whatever')];
expect($expected)->not->toContainOnlyInstancesOf(Expectation::class);
})->throws(ExpectationFailedException::class);

View File

@ -1,16 +0,0 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('is case sensitive', function () {
expect('hello world')->toContainString('world');
expect('hello world')->not->toContainString('World');
});
test('failures', function () {
expect('hello world')->toContainString('Hello');
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('hello world')->not->toContainString('hello');
})->throws(ExpectationFailedException::class);

View File

@ -1,17 +0,0 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('ignore difference in casing', function () {
expect('hello world')->toContainStringIgnoringCase('world');
expect('hello world')->toContainStringIgnoringCase('World');
});
test('failures', function () {
expect('hello world')->toContainStringIgnoringCase('hi');
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect('hello world')->not->toContainStringIgnoringCase('Hello');
expect('hello world')->not->toContainStringIgnoringCase('hello');
})->throws(ExpectationFailedException::class);

View File

@ -3,13 +3,13 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toCount(3);
expect([1, 2, 3])->toHaveCount(3);
});
test('failures', function () {
expect([1, 2, 3])->toCount(4);
expect([1, 2, 3])->toHaveCount(4);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect([1, 2, 3])->not->toCount(3);
expect([1, 2, 3])->not->toHaveCount(3);
})->throws(ExpectationFailedException::class);

View File

@ -3,13 +3,13 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(1.0)->toEqualWithDelta(1.3, .4);
expect(1.0)->toBeEqualWithDelta(1.3, .4);
});
test('failures', function () {
expect(1.0)->toEqualWithDelta(1.5, .1);
expect(1.0)->toBeEqualWithDelta(1.5, .1);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(1.0)->not->toEqualWithDelta(1.6, .7);
expect(1.0)->not->toBeEqualWithDelta(1.6, .7);
})->throws(ExpectationFailedException::class);

View File

@ -8,8 +8,8 @@ afterAll(function () use ($file) {
test('deletes file after all', function () use ($file) {
file_put_contents($file, 'foo');
assertFileExists($file);
$this->assertFileExists($file);
register_shutdown_function(function () use ($file) {
assertFileNotExists($file);
$this->assertFileNotExists($file);
});
});

View File

@ -11,10 +11,10 @@ afterEach(function () use ($state) {
});
it('does not get executed before the test', function () {
assertFalse(property_exists($this->state, 'bar'));
expect(property_exists($this->state, 'bar'))->toBeFalse();
});
it('gets executed after the test', function () {
assertTrue(property_exists($this->state, 'bar'));
assertEquals(2, $this->state->bar);
expect(property_exists($this->state, 'bar'))->toBeTrue();
expect($this->state->bar)->toBe(2);
});

View File

@ -8,11 +8,11 @@ beforeAll(function () use ($foo) {
});
it('gets executed before tests', function () use ($foo) {
assertEquals($foo->bar, 1);
expect($foo->bar)->toBe(1);
$foo->bar = 'changed';
});
it('do not get executed before each test', function () use ($foo) {
assertEquals($foo->bar, 'changed');
expect($foo->bar)->toBe('changed');
});

View File

@ -5,11 +5,11 @@ beforeEach(function () {
});
it('gets executed before each test', function () {
assertEquals($this->bar, 2);
expect($this->bar)->toBe(2);
$this->bar = 'changed';
});
it('gets executed before each test once again', function () {
assertEquals($this->bar, 2);
expect($this->bar)->toBe(2);
});

View File

@ -23,13 +23,13 @@ it('sets closures', function () {
yield [1];
});
assertEquals([[1]], iterator_to_array(Datasets::get('foo')()));
expect(iterator_to_array(Datasets::get('foo')()))->toBe([[1]]);
});
it('sets arrays', function () {
Datasets::set('bar', [[2]]);
assertEquals([[2]], Datasets::get('bar'));
expect(Datasets::get('bar'))->toBe([[2]]);
});
it('gets bound to test case object', function () {
@ -37,7 +37,7 @@ it('gets bound to test case object', function () {
})->with([['a'], ['b']]);
test('it truncates the description', function () {
assertTrue(true);
expect(true)->toBe(true);
// it gets tested by the integration test
})->with([str_repeat('Fooo', 10000000)]);
@ -48,51 +48,51 @@ $datasets = [[1], [2]];
test('lazy datasets', function ($text) use ($state, $datasets) {
$state->text .= $text;
assertTrue(in_array([$text], $datasets));
expect(in_array([$text], $datasets))->toBe(true);
})->with($datasets);
test('lazy datasets did the job right', function () use ($state) {
assertEquals('12', $state->text);
expect($state->text)->toBe('12');
});
$state->text = '';
test('eager datasets', function ($text) use ($state, $datasets) {
$state->text .= $text;
assertTrue(in_array([$text], $datasets));
expect($datasets)->toContain([$text]);
})->with(function () use ($datasets) {
return $datasets;
});
test('eager datasets did the job right', function () use ($state) {
assertEquals('1212', $state->text);
expect($state->text)->toBe('1212');
});
test('lazy registered datasets', function ($text) use ($state, $datasets) {
$state->text .= $text;
assertTrue(in_array([$text], $datasets));
expect($datasets)->toContain([$text]);
})->with('numbers.array');
test('lazy registered datasets did the job right', function () use ($state) {
assertEquals('121212', $state->text);
expect($state->text)->toBe('121212');
});
test('eager registered datasets', function ($text) use ($state, $datasets) {
$state->text .= $text;
assertTrue(in_array([$text], $datasets));
expect($datasets)->toContain([$text]);
})->with('numbers.closure');
test('eager registered datasets did the job right', function () use ($state) {
assertEquals('12121212', $state->text);
expect($state->text)->toBe('12121212');
});
test('eager wrapped registered datasets', function ($text) use ($state, $datasets) {
$state->text .= $text;
assertTrue(in_array([$text], $datasets));
expect($datasets)->toContain([$text]);
})->with('numbers.closure.wrapped');
test('eager registered wrapped datasets did the job right', function () use ($state) {
assertEquals('1212121212', $state->text);
expect($state->text)->toBe('1212121212');
});
class Bar
@ -105,13 +105,13 @@ $namedDatasets = [
];
test('lazy named datasets', function ($text) use ($state, $datasets) {
assertTrue(true);
expect(true)->toBeTrue();
})->with($namedDatasets);
$counter = 0;
it('creates unique test case names', function (string $name, Plugin $plugin, bool $bool) use (&$counter) {
assertTrue(true);
expect(true)->toBeTrue();
$counter++;
})->with([
['Name 1', new Plugin(), true],
@ -123,5 +123,5 @@ it('creates unique test case names', function (string $name, Plugin $plugin, boo
]);
it('creates unique test case names - count', function () use (&$counter) {
assertEquals(6, $counter);
expect($counter)->toBe(6);
});

View File

@ -3,38 +3,32 @@
$runCounter = 0;
test('first', function () use (&$runCounter) {
assertTrue(true);
expect(true)->toBeTrue();
$runCounter++;
return 'first';
});
test('second', function () use (&$runCounter) {
assertTrue(true);
expect(true)->toBeTrue();
$runCounter++;
return 'second';
});
test('depends', function () {
assertEquals(
['first', 'second'],
func_get_args()
);
expect(func_get_args())->toBe(['first', 'second']);
})->depends('first', 'second');
test('depends with ...params', function (string ...$params) {
assertEquals(
['first', 'second'],
$params
);
expect(func_get_args())->toBe($params);
})->depends('first', 'second');
test('depends with defined arguments', function (string $first, string $second) {
assertEquals('first', $first);
assertEquals('second', $second);
expect($first)->toBe('first');
expect($second)->toBe('second');
})->depends('first', 'second');
test('depends run test only once', function () use (&$runCounter) {
assertEquals(2, $runCounter);
expect($runCounter)->toBe(2);
})->depends('first', 'second');

View File

@ -7,7 +7,7 @@ function addUser()
it('can set/get properties on $this', function () {
addUser();
assertEquals('nuno', $this->user);
expect($this->user)->toBe('nuno');
});
it('throws error if property do not exist', function () {
@ -34,8 +34,7 @@ function mockUser()
it('allows to call underlying protected/private methods', function () {
$user = mockUser();
assertEquals('maduro', $user->getName());
expect($user->getName())->toBe('maduro');
});
it('throws error if method do not exist', function () {

View File

@ -1,7 +1,7 @@
<?php
it('is a test', function () {
assertArrayHasKey('key', ['key' => 'foo']);
$this->assertArrayHasKey('key', ['key' => 'foo']);
});
it('is a higher order message test')->assertTrue(true);
it('is a higher order message test')->expect(true)->toBeTrue();

View File

@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
uses(Macroable::class);
beforeEach()->macro('bar', function () {
assertInstanceOf(TestCase::class, $this);
expect($this)->toBeInstanceOf(TestCase::class);
});
it('can call chained macro method')->bar();

View File

@ -1,11 +1,12 @@
<?php
use Pest\PendingObjects\TestCall;
use PHPUnit\Framework\TestCase;
uses(Gettable::class);
/**
* @return TestCase|Gettable
* @return TestCase|TestCall|Gettable
*/
function get(string $route)
{
@ -15,15 +16,15 @@ function get(string $route)
trait Gettable
{
/**
* @return TestCase|Gettable
* @return TestCase|TestCall|Gettable
*/
public function get(string $route)
{
assertNotEmpty($route);
expect($route)->not->toBeEmpty();
return $this;
}
}
get('foo')->get('bar')->assertTrue(true);
get('foo')->assertTrue(true);
get('foo')->get('bar')->expect(true)->toBeTrue();
get('foo')->expect(true)->toBeTrue();

View File

@ -1,7 +1,7 @@
<?php
test('a test', function () {
assertArrayHasKey('key', ['key' => 'foo']);
$this->assertArrayHasKey('key', ['key' => 'foo']);
});
test('higher order message test')->assertTrue(true);
test('higher order message test')->expect(true)->toBeTrue();

View File

@ -20,8 +20,8 @@ afterAll(function () {
});
register_shutdown_function(function () use ($foo) {
assertFalse($foo->beforeAll);
assertFalse($foo->beforeEach);
assertFalse($foo->afterEach);
assertFalse($foo->afterAll);
expect($foo->beforeAll)->toBeFalse();
expect($foo->beforeEach)->toBeFalse();
expect($foo->afterEach)->toBeFalse();
expect($foo->afterAll)->toBeFalse();
});

View File

@ -10,6 +10,6 @@ class CustomTestCaseInSubFolder extends TestCase
{
public function assertCustomInSubFolderTrue()
{
assertTrue(true);
$this->assertTrue(true);
}
}

View File

@ -12,7 +12,7 @@ class MyCustomClass extends PHPUnit\Framework\TestCase
{
public function assertTrueIsTrue()
{
assertTrue(true);
$this->assertTrue(true);
}
}

View File

@ -1,5 +1,5 @@
<?php
test('basic', function () {
assertTrue(true);
expect(true)->toBeTrue();
});

View File

@ -7,14 +7,14 @@ use PHPUnit\TextUI\DefaultResultPrinter;
it('sets defaults', function () {
$arguments = AddsDefaults::to(['bar' => 'foo']);
assertInstanceOf(Printer::class, $arguments['printer']);
assertEquals($arguments['bar'], 'foo');
expect($arguments['printer'])->toBeInstanceOf(Printer::class);
expect($arguments['bar'])->toBe('foo');
});
it('does not override options', function () {
$defaultResultPrinter = new DefaultResultPrinter();
assertEquals(AddsDefaults::to(['printer' => $defaultResultPrinter]), [
expect(AddsDefaults::to(['printer' => $defaultResultPrinter]))->tobe([
'printer' => $defaultResultPrinter,
]);
});

View File

@ -16,10 +16,10 @@ test('default php unit tests', function () {
$phpUnitTestCase = new class() extends PhpUnitTestCase {
};
$testSuite->addTest($phpUnitTestCase);
assertCount(1, $testSuite->tests());
expect($testSuite->tests())->toHaveCount(1);
AddsTests::to($testSuite, new \Pest\TestSuite(getcwd()));
assertCount(1, $testSuite->tests());
expect($testSuite->tests())->toHaveCount(1);
});
it('removes warnings', function () use ($pestTestCase) {
@ -28,5 +28,5 @@ it('removes warnings', function () use ($pestTestCase) {
$testSuite->addTest($warningTestCase);
AddsTests::to($testSuite, new \Pest\TestSuite(getcwd()));
assertCount(0, $testSuite->tests());
expect($testSuite->tests())->toHaveCount(0);
});

View File

@ -38,5 +38,5 @@ it('do not throws exception when `process isolation` is false', function () {
'configuration' => $filename,
]);
assertTrue(true);
expect(true)->toBeTrue();
});

View File

@ -8,7 +8,7 @@ it('outputs the version when --version is used', function () {
$plugin = new Version($output);
$plugin->handleArguments(['foo', '--version']);
assertStringContainsString('Pest 0.2.2', $output->fetch());
expect($output->fetch())->toContain('Pest 0.2.2');
});
it('do not outputs version when --version is not used', function () {
@ -16,5 +16,5 @@ it('do not outputs version when --version is not used', function () {
$plugin = new Version($output);
$plugin->handleArguments(['foo', 'bar']);
assertEquals('', $output->fetch());
expect($output->fetch())->toBe('');
});

View File

@ -7,5 +7,5 @@ it('gets file name from called file', function () {
return Backtrace::file();
};
assertEquals(__FILE__, $a());
expect($a())->toBe(__FILE__);
});

View File

@ -15,32 +15,32 @@ it('exists')
it('gets an instance', function () {
$this->container->add(Container::class, $this->container);
assertSame($this->container, $this->container->get(Container::class));
expect($this->container->get(Container::class))->toBe($this->container);
});
test('autowire', function () {
assertInstanceOf(Container::class, $this->container->get(Container::class));
expect($this->container->get(Container::class))->toBeInstanceOf(Container::class);
});
it('creates an instance and resolves parameters', function () {
$this->container->add(Container::class, $this->container);
$instance = $this->container->get(ClassWithDependency::class);
assertInstanceOf(ClassWithDependency::class, $instance);
expect($instance)->toBeInstanceOf(ClassWithDependency::class);
});
it('creates an instance and resolves also sub parameters', function () {
$this->container->add(Container::class, $this->container);
$instance = $this->container->get(ClassWithSubDependency::class);
assertInstanceOf(ClassWithSubDependency::class, $instance);
expect($instance)->toBeInstanceOf(ClassWithSubDependency::class);
});
it('can resolve builtin value types', function () {
$this->container->add('rootPath', getcwd());
$instance = $this->container->get(TestSuite::class);
assertInstanceOf(TestSuite::class, $instance);
expect($instance)->toBeInstanceOf(TestSuite::class);
});
it('cannot resolve a parameter without type', function () {

View File

@ -3,9 +3,10 @@
use Pest\Support\Reflection;
it('gets file name from closure', function () {
$fileName = Reflection::getFileNameFromClosure(function () {});
$fileName = Reflection::getFileNameFromClosure(function () {
});
assertEquals(__FILE__, $fileName);
expect($fileName)->toBe(__FILE__);
});
it('gets property values', function () {
@ -15,5 +16,5 @@ it('gets property values', function () {
$value = Reflection::getPropertyValue($class, 'foo');
assertEquals('bar', $value);
expect($value)->toBe('bar');
});

View File

@ -21,23 +21,15 @@ $snapshot = function ($name) {
};
test('allows to run a single test', function () use ($run, $snapshot) {
assertStringContainsString(
$snapshot('allows-to-run-a-single-test'),
$run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'));
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php'))->toContain($snapshot('allows-to-run-a-single-test'));
})->skip(PHP_OS_FAMILY === 'Windows');
test('allows to run a directory', function () use ($run, $snapshot) {
assertStringContainsString(
$snapshot('allows-to-run-a-directory'),
$run('tests/Fixtures')
);
expect($run('tests/Fixtures'))->toContain($snapshot('allows-to-run-a-directory'));
})->skip(PHP_OS_FAMILY === 'Windows');
it('has ascii chars', function () use ($run, $snapshot) {
assertStringContainsString(
$snapshot('has-ascii-chars'),
$run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true)
);
expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true))->toContain($snapshot('has-ascii-chars'));
})->skip(PHP_OS_FAMILY === 'Windows');
it('disable decorating printer when colors is set to never', function () use ($snapshot) {
@ -49,9 +41,5 @@ it('disable decorating printer when colors is set to never', function () use ($s
], dirname(__DIR__, 2));
$process->run();
$output = $process->getOutput();
assertStringContainsString(
$snapshot('disable-decorating-printer'),
$output
);
expect($output)->toContain($snapshot('disable-decorating-printer'));
})->skip(PHP_OS_FAMILY === 'Windows');

View File

@ -22,7 +22,7 @@ test('visual snapshot of test suite on success', function () {
$output = explode("\n", $output());
array_pop($output);
array_pop($output);
assertStringContainsString(implode("\n", $output), file_get_contents($snapshot));
expect(file_get_contents($snapshot))->toContain(implode("\n", $output));
}
})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
->skip(PHP_OS_FAMILY === 'Windows');