diff --git a/.php_cs b/.php_cs index 725a3035..d163e603 100644 --- a/.php_cs +++ b/.php_cs @@ -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') diff --git a/compiled/.gitkeep b/compiled/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/compiled/globals.php b/compiled/globals.php deleted file mode 100644 index 9f82a842..00000000 --- a/compiled/globals.php +++ /dev/null @@ -1,1926 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -use PHPUnit\Framework\Assert; -use PHPUnit\Framework\Constraint\Constraint; - -/** - * Asserts that an array has a specified key. - * - * @param int|string $key - * @param array|\ArrayAccess $array - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertArrayHasKey - */ -function assertArrayHasKey($key, $array, string $message = ''): void -{ - Assert::assertArrayHasKey(...\func_get_args()); -} - -/** - * Asserts that an array does not have a specified key. - * - * @param int|string $key - * @param array|\ArrayAccess $array - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertArrayNotHasKey - */ -function assertArrayNotHasKey($key, $array, string $message = ''): void -{ - Assert::assertArrayNotHasKey(...\func_get_args()); -} - -/** - * Asserts that a haystack contains a needle. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertContains - */ -function assertContains($needle, iterable $haystack, string $message = ''): void -{ - Assert::assertContains(...\func_get_args()); -} - -function assertContainsEquals($needle, iterable $haystack, string $message = ''): void -{ - Assert::assertContainsEquals(...\func_get_args()); -} - -/** - * Asserts that a haystack does not contain a needle. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertNotContains - */ -function assertNotContains($needle, iterable $haystack, string $message = ''): void -{ - Assert::assertNotContains(...\func_get_args()); -} - -function assertNotContainsEquals($needle, iterable $haystack, string $message = ''): void -{ - Assert::assertNotContainsEquals(...\func_get_args()); -} - -/** - * Asserts that a haystack contains only values of a given type. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertContainsOnly - */ -function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void -{ - Assert::assertContainsOnly(...\func_get_args()); -} - -/** - * Asserts that a haystack contains only instances of a given class name. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertContainsOnlyInstancesOf - */ -function assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void -{ - Assert::assertContainsOnlyInstancesOf(...\func_get_args()); -} - -/** - * Asserts that a haystack does not contain only values of a given type. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotContainsOnly - */ -function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void -{ - Assert::assertNotContainsOnly(...\func_get_args()); -} - -/** - * Asserts the number of elements of an array, Countable or Traversable. - * - * @param \Countable|iterable $haystack - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertCount - */ -function assertCount(int $expectedCount, $haystack, string $message = ''): void -{ - Assert::assertCount(...\func_get_args()); -} - -/** - * Asserts the number of elements of an array, Countable or Traversable. - * - * @param \Countable|iterable $haystack - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertNotCount - */ -function assertNotCount(int $expectedCount, $haystack, string $message = ''): void -{ - Assert::assertNotCount(...\func_get_args()); -} - -/** - * Asserts that two variables are equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertEquals - */ -function assertEquals($expected, $actual, string $message = ''): void -{ - Assert::assertEquals(...\func_get_args()); -} - -/** - * Asserts that two variables are equal (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertEqualsCanonicalizing - */ -function assertEqualsCanonicalizing($expected, $actual, string $message = ''): void -{ - Assert::assertEqualsCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that two variables are equal (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertEqualsIgnoringCase - */ -function assertEqualsIgnoringCase($expected, $actual, string $message = ''): void -{ - Assert::assertEqualsIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that two variables are equal (with delta). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertEqualsWithDelta - */ -function assertEqualsWithDelta($expected, $actual, float $delta, string $message = ''): void -{ - Assert::assertEqualsWithDelta(...\func_get_args()); -} - -/** - * Asserts that two variables are not equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotEquals - */ -function assertNotEquals($expected, $actual, string $message = ''): void -{ - Assert::assertNotEquals(...\func_get_args()); -} - -/** - * Asserts that two variables are not equal (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotEqualsCanonicalizing - */ -function assertNotEqualsCanonicalizing($expected, $actual, string $message = ''): void -{ - Assert::assertNotEqualsCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that two variables are not equal (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotEqualsIgnoringCase - */ -function assertNotEqualsIgnoringCase($expected, $actual, string $message = ''): void -{ - Assert::assertNotEqualsIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that two variables are not equal (with delta). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotEqualsWithDelta - */ -function assertNotEqualsWithDelta($expected, $actual, float $delta, string $message = ''): void -{ - Assert::assertNotEqualsWithDelta(...\func_get_args()); -} - -/** - * Asserts that a variable is empty. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert empty $actual - * - * @see Assert::assertEmpty - */ -function assertEmpty($actual, string $message = ''): void -{ - Assert::assertEmpty(...\func_get_args()); -} - -/** - * Asserts that a variable is not empty. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !empty $actual - * - * @see Assert::assertNotEmpty - */ -function assertNotEmpty($actual, string $message = ''): void -{ - Assert::assertNotEmpty(...\func_get_args()); -} - -/** - * Asserts that a value is greater than another value. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertGreaterThan - */ -function assertGreaterThan($expected, $actual, string $message = ''): void -{ - Assert::assertGreaterThan(...\func_get_args()); -} - -/** - * Asserts that a value is greater than or equal to another value. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertGreaterThanOrEqual - */ -function assertGreaterThanOrEqual($expected, $actual, string $message = ''): void -{ - Assert::assertGreaterThanOrEqual(...\func_get_args()); -} - -/** - * Asserts that a value is smaller than another value. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertLessThan - */ -function assertLessThan($expected, $actual, string $message = ''): void -{ - Assert::assertLessThan(...\func_get_args()); -} - -/** - * Asserts that a value is smaller than or equal to another value. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertLessThanOrEqual - */ -function assertLessThanOrEqual($expected, $actual, string $message = ''): void -{ - Assert::assertLessThanOrEqual(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is equal to the contents of another - * file. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileEquals - */ -function assertFileEquals(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileEquals(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is equal to the contents of another - * file (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileEqualsCanonicalizing - */ -function assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileEqualsCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is equal to the contents of another - * file (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileEqualsIgnoringCase - */ -function assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileEqualsIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is not equal to the contents of - * another file. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileNotEquals - */ -function assertFileNotEquals(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileNotEquals(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is not equal to the contents of another - * file (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileNotEqualsCanonicalizing - */ -function assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileNotEqualsCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that the contents of one file is not equal to the contents of another - * file (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileNotEqualsIgnoringCase - */ -function assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void -{ - Assert::assertFileNotEqualsIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is equal - * to the contents of a file. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringEqualsFile - */ -function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringEqualsFile(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is equal - * to the contents of a file (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringEqualsFileCanonicalizing - */ -function assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringEqualsFileCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is equal - * to the contents of a file (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringEqualsFileIgnoringCase - */ -function assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringEqualsFileIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is not equal - * to the contents of a file. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotEqualsFile - */ -function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringNotEqualsFile(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is not equal - * to the contents of a file (canonicalizing). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotEqualsFileCanonicalizing - */ -function assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringNotEqualsFileCanonicalizing(...\func_get_args()); -} - -/** - * Asserts that the contents of a string is not equal - * to the contents of a file (ignoring case). - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotEqualsFileIgnoringCase - */ -function assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void -{ - Assert::assertStringNotEqualsFileIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that a file/dir is readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertIsReadable - */ -function assertIsReadable(string $filename, string $message = ''): void -{ - Assert::assertIsReadable(...\func_get_args()); -} - -/** - * Asserts that a file/dir exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertIsNotReadable - */ -function assertIsNotReadable(string $filename, string $message = ''): void -{ - Assert::assertIsNotReadable(...\func_get_args()); -} - -/** - * Asserts that a file/dir exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4062 - * @see Assert::assertNotIsReadable - */ -function assertNotIsReadable(string $filename, string $message = ''): void -{ - Assert::assertNotIsReadable(...\func_get_args()); -} - -/** - * Asserts that a file/dir exists and is writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertIsWritable - */ -function assertIsWritable(string $filename, string $message = ''): void -{ - Assert::assertIsWritable(...\func_get_args()); -} - -/** - * Asserts that a file/dir exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertIsNotWritable - */ -function assertIsNotWritable(string $filename, string $message = ''): void -{ - Assert::assertIsNotWritable(...\func_get_args()); -} - -/** - * Asserts that a file/dir exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4065 - * @see Assert::assertNotIsWritable - */ -function assertNotIsWritable(string $filename, string $message = ''): void -{ - Assert::assertNotIsWritable(...\func_get_args()); -} - -/** - * Asserts that a directory exists. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryExists - */ -function assertDirectoryExists(string $directory, string $message = ''): void -{ - Assert::assertDirectoryExists(...\func_get_args()); -} - -/** - * Asserts that a directory does not exist. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryDoesNotExist - */ -function assertDirectoryDoesNotExist(string $directory, string $message = ''): void -{ - Assert::assertDirectoryDoesNotExist(...\func_get_args()); -} - -/** - * Asserts that a directory does not exist. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4068 - * @see Assert::assertDirectoryNotExists - */ -function assertDirectoryNotExists(string $directory, string $message = ''): void -{ - Assert::assertDirectoryNotExists(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryIsReadable - */ -function assertDirectoryIsReadable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryIsReadable(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryIsNotReadable - */ -function assertDirectoryIsNotReadable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryIsNotReadable(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4071 - * @see Assert::assertDirectoryNotIsReadable - */ -function assertDirectoryNotIsReadable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryNotIsReadable(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryIsWritable - */ -function assertDirectoryIsWritable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryIsWritable(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDirectoryIsNotWritable - */ -function assertDirectoryIsNotWritable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryIsNotWritable(...\func_get_args()); -} - -/** - * Asserts that a directory exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4074 - * @see Assert::assertDirectoryNotIsWritable - */ -function assertDirectoryNotIsWritable(string $directory, string $message = ''): void -{ - Assert::assertDirectoryNotIsWritable(...\func_get_args()); -} - -/** - * Asserts that a file exists. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileExists - */ -function assertFileExists(string $filename, string $message = ''): void -{ - Assert::assertFileExists(...\func_get_args()); -} - -/** - * Asserts that a file does not exist. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileDoesNotExist - */ -function assertFileDoesNotExist(string $filename, string $message = ''): void -{ - Assert::assertFileDoesNotExist(...\func_get_args()); -} - -/** - * Asserts that a file does not exist. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4077 - * @see Assert::assertFileNotExists - */ -function assertFileNotExists(string $filename, string $message = ''): void -{ - Assert::assertFileNotExists(...\func_get_args()); -} - -/** - * Asserts that a file exists and is readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileIsReadable - */ -function assertFileIsReadable(string $file, string $message = ''): void -{ - Assert::assertFileIsReadable(...\func_get_args()); -} - -/** - * Asserts that a file exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileIsNotReadable - */ -function assertFileIsNotReadable(string $file, string $message = ''): void -{ - Assert::assertFileIsNotReadable(...\func_get_args()); -} - -/** - * Asserts that a file exists and is not readable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4080 - * @see Assert::assertFileNotIsReadable - */ -function assertFileNotIsReadable(string $file, string $message = ''): void -{ - Assert::assertFileNotIsReadable(...\func_get_args()); -} - -/** - * Asserts that a file exists and is writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileIsWritable - */ -function assertFileIsWritable(string $file, string $message = ''): void -{ - Assert::assertFileIsWritable(...\func_get_args()); -} - -/** - * Asserts that a file exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFileIsNotWritable - */ -function assertFileIsNotWritable(string $file, string $message = ''): void -{ - Assert::assertFileIsNotWritable(...\func_get_args()); -} - -/** - * Asserts that a file exists and is not writable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4083 - * @see Assert::assertFileNotIsWritable - */ -function assertFileNotIsWritable(string $file, string $message = ''): void -{ - Assert::assertFileNotIsWritable(...\func_get_args()); -} - -/** - * Asserts that a condition is true. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert true $condition - * - * @see Assert::assertTrue - */ -function assertTrue($condition, string $message = ''): void -{ - Assert::assertTrue(...\func_get_args()); -} - -/** - * Asserts that a condition is not true. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !true $condition - * - * @see Assert::assertNotTrue - */ -function assertNotTrue($condition, string $message = ''): void -{ - Assert::assertNotTrue(...\func_get_args()); -} - -/** - * Asserts that a condition is false. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert false $condition - * - * @see Assert::assertFalse - */ -function assertFalse($condition, string $message = ''): void -{ - Assert::assertFalse(...\func_get_args()); -} - -/** - * Asserts that a condition is not false. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !false $condition - * - * @see Assert::assertNotFalse - */ -function assertNotFalse($condition, string $message = ''): void -{ - Assert::assertNotFalse(...\func_get_args()); -} - -/** - * Asserts that a variable is null. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert null $actual - * - * @see Assert::assertNull - */ -function assertNull($actual, string $message = ''): void -{ - Assert::assertNull(...\func_get_args()); -} - -/** - * Asserts that a variable is not null. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !null $actual - * - * @see Assert::assertNotNull - */ -function assertNotNull($actual, string $message = ''): void -{ - Assert::assertNotNull(...\func_get_args()); -} - -/** - * Asserts that a variable is finite. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertFinite - */ -function assertFinite($actual, string $message = ''): void -{ - Assert::assertFinite(...\func_get_args()); -} - -/** - * Asserts that a variable is infinite. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertInfinite - */ -function assertInfinite($actual, string $message = ''): void -{ - Assert::assertInfinite(...\func_get_args()); -} - -/** - * Asserts that a variable is nan. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNan - */ -function assertNan($actual, string $message = ''): void -{ - Assert::assertNan(...\func_get_args()); -} - -/** - * Asserts that a class has a specified attribute. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertClassHasAttribute - */ -function assertClassHasAttribute(string $attributeName, string $className, string $message = ''): void -{ - Assert::assertClassHasAttribute(...\func_get_args()); -} - -/** - * Asserts that a class does not have a specified attribute. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertClassNotHasAttribute - */ -function assertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void -{ - Assert::assertClassNotHasAttribute(...\func_get_args()); -} - -/** - * Asserts that a class has a specified static attribute. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertClassHasStaticAttribute - */ -function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void -{ - Assert::assertClassHasStaticAttribute(...\func_get_args()); -} - -/** - * Asserts that a class does not have a specified static attribute. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertClassNotHasStaticAttribute - */ -function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void -{ - Assert::assertClassNotHasStaticAttribute(...\func_get_args()); -} - -/** - * Asserts that an object has a specified attribute. - * - * @param object $object - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertObjectHasAttribute - */ -function assertObjectHasAttribute(string $attributeName, $object, string $message = ''): void -{ - Assert::assertObjectHasAttribute(...\func_get_args()); -} - -/** - * Asserts that an object does not have a specified attribute. - * - * @param object $object - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertObjectNotHasAttribute - */ -function assertObjectNotHasAttribute(string $attributeName, $object, string $message = ''): void -{ - Assert::assertObjectNotHasAttribute(...\func_get_args()); -} - -/** - * Asserts that two variables have the same type and value. - * Used on objects, it asserts that two variables reference - * the same object. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-template ExpectedType - * @psalm-param ExpectedType $expected - * @psalm-assert =ExpectedType $actual - * - * @see Assert::assertSame - */ -function assertSame($expected, $actual, string $message = ''): void -{ - Assert::assertSame(...\func_get_args()); -} - -/** - * Asserts that two variables do not have the same type and value. - * Used on objects, it asserts that two variables do not reference - * the same object. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertNotSame - */ -function assertNotSame($expected, $actual, string $message = ''): void -{ - Assert::assertNotSame(...\func_get_args()); -} - -/** - * Asserts that a variable is of a given type. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @psalm-template ExpectedType of object - * @psalm-param class-string $expected - * @psalm-assert ExpectedType $actual - * - * @see Assert::assertInstanceOf - */ -function assertInstanceOf(string $expected, $actual, string $message = ''): void -{ - Assert::assertInstanceOf(...\func_get_args()); -} - -/** - * Asserts that a variable is not of a given type. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @psalm-template ExpectedType of object - * @psalm-param class-string $expected - * @psalm-assert !ExpectedType $actual - * - * @see Assert::assertNotInstanceOf - */ -function assertNotInstanceOf(string $expected, $actual, string $message = ''): void -{ - Assert::assertNotInstanceOf(...\func_get_args()); -} - -/** - * Asserts that a variable is of type array. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert array $actual - * - * @see Assert::assertIsArray - */ -function assertIsArray($actual, string $message = ''): void -{ - Assert::assertIsArray(...\func_get_args()); -} - -/** - * Asserts that a variable is of type bool. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert bool $actual - * - * @see Assert::assertIsBool - */ -function assertIsBool($actual, string $message = ''): void -{ - Assert::assertIsBool(...\func_get_args()); -} - -/** - * Asserts that a variable is of type float. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert float $actual - * - * @see Assert::assertIsFloat - */ -function assertIsFloat($actual, string $message = ''): void -{ - Assert::assertIsFloat(...\func_get_args()); -} - -/** - * Asserts that a variable is of type int. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert int $actual - * - * @see Assert::assertIsInt - */ -function assertIsInt($actual, string $message = ''): void -{ - Assert::assertIsInt(...\func_get_args()); -} - -/** - * Asserts that a variable is of type numeric. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert numeric $actual - * - * @see Assert::assertIsNumeric - */ -function assertIsNumeric($actual, string $message = ''): void -{ - Assert::assertIsNumeric(...\func_get_args()); -} - -/** - * Asserts that a variable is of type object. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert object $actual - * - * @see Assert::assertIsObject - */ -function assertIsObject($actual, string $message = ''): void -{ - Assert::assertIsObject(...\func_get_args()); -} - -/** - * Asserts that a variable is of type resource. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert resource $actual - * - * @see Assert::assertIsResource - */ -function assertIsResource($actual, string $message = ''): void -{ - Assert::assertIsResource(...\func_get_args()); -} - -/** - * Asserts that a variable is of type string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert string $actual - * - * @see Assert::assertIsString - */ -function assertIsString($actual, string $message = ''): void -{ - Assert::assertIsString(...\func_get_args()); -} - -/** - * Asserts that a variable is of type scalar. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert scalar $actual - * - * @see Assert::assertIsScalar - */ -function assertIsScalar($actual, string $message = ''): void -{ - Assert::assertIsScalar(...\func_get_args()); -} - -/** - * Asserts that a variable is of type callable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert callable $actual - * - * @see Assert::assertIsCallable - */ -function assertIsCallable($actual, string $message = ''): void -{ - Assert::assertIsCallable(...\func_get_args()); -} - -/** - * Asserts that a variable is of type iterable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert iterable $actual - * - * @see Assert::assertIsIterable - */ -function assertIsIterable($actual, string $message = ''): void -{ - Assert::assertIsIterable(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type array. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !array $actual - * - * @see Assert::assertIsNotArray - */ -function assertIsNotArray($actual, string $message = ''): void -{ - Assert::assertIsNotArray(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type bool. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !bool $actual - * - * @see Assert::assertIsNotBool - */ -function assertIsNotBool($actual, string $message = ''): void -{ - Assert::assertIsNotBool(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type float. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !float $actual - * - * @see Assert::assertIsNotFloat - */ -function assertIsNotFloat($actual, string $message = ''): void -{ - Assert::assertIsNotFloat(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type int. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !int $actual - * - * @see Assert::assertIsNotInt - */ -function assertIsNotInt($actual, string $message = ''): void -{ - Assert::assertIsNotInt(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type numeric. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !numeric $actual - * - * @see Assert::assertIsNotNumeric - */ -function assertIsNotNumeric($actual, string $message = ''): void -{ - Assert::assertIsNotNumeric(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type object. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !object $actual - * - * @see Assert::assertIsNotObject - */ -function assertIsNotObject($actual, string $message = ''): void -{ - Assert::assertIsNotObject(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type resource. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !resource $actual - * - * @see Assert::assertIsNotResource - */ -function assertIsNotResource($actual, string $message = ''): void -{ - Assert::assertIsNotResource(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !string $actual - * - * @see Assert::assertIsNotString - */ -function assertIsNotString($actual, string $message = ''): void -{ - Assert::assertIsNotString(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type scalar. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !scalar $actual - * - * @see Assert::assertIsNotScalar - */ -function assertIsNotScalar($actual, string $message = ''): void -{ - Assert::assertIsNotScalar(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type callable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !callable $actual - * - * @see Assert::assertIsNotCallable - */ -function assertIsNotCallable($actual, string $message = ''): void -{ - Assert::assertIsNotCallable(...\func_get_args()); -} - -/** - * Asserts that a variable is not of type iterable. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @psalm-assert !iterable $actual - * - * @see Assert::assertIsNotIterable - */ -function assertIsNotIterable($actual, string $message = ''): void -{ - Assert::assertIsNotIterable(...\func_get_args()); -} - -/** - * Asserts that a string matches a given regular expression. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertMatchesRegularExpression - */ -function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void -{ - Assert::assertMatchesRegularExpression(...\func_get_args()); -} - -/** - * Asserts that a string matches a given regular expression. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4086 - * @see Assert::assertRegExp - */ -function assertRegExp(string $pattern, string $string, string $message = ''): void -{ - Assert::assertRegExp(...\func_get_args()); -} - -/** - * Asserts that a string does not match a given regular expression. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertDoesNotMatchRegularExpression - */ -function assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void -{ - Assert::assertDoesNotMatchRegularExpression(...\func_get_args()); -} - -/** - * Asserts that a string does not match a given regular expression. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4089 - * @see Assert::assertNotRegExp - */ -function assertNotRegExp(string $pattern, string $string, string $message = ''): void -{ - Assert::assertNotRegExp(...\func_get_args()); -} - -/** - * Assert that the size of two arrays (or `Countable` or `Traversable` objects) - * is the same. - * - * @param \Countable|iterable $expected - * @param \Countable|iterable $actual - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertSameSize - */ -function assertSameSize($expected, $actual, string $message = ''): void -{ - Assert::assertSameSize(...\func_get_args()); -} - -/** - * Assert that the size of two arrays (or `Countable` or `Traversable` objects) - * is not the same. - * - * @param \Countable|iterable $expected - * @param \Countable|iterable $actual - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertNotSameSize - */ -function assertNotSameSize($expected, $actual, string $message = ''): void -{ - Assert::assertNotSameSize(...\func_get_args()); -} - -/** - * Asserts that a string matches a given format string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringMatchesFormat - */ -function assertStringMatchesFormat(string $format, string $string, string $message = ''): void -{ - Assert::assertStringMatchesFormat(...\func_get_args()); -} - -/** - * Asserts that a string does not match a given format string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotMatchesFormat - */ -function assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void -{ - Assert::assertStringNotMatchesFormat(...\func_get_args()); -} - -/** - * Asserts that a string matches a given format file. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringMatchesFormatFile - */ -function assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void -{ - Assert::assertStringMatchesFormatFile(...\func_get_args()); -} - -/** - * Asserts that a string does not match a given format string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotMatchesFormatFile - */ -function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void -{ - Assert::assertStringNotMatchesFormatFile(...\func_get_args()); -} - -/** - * Asserts that a string starts with a given prefix. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringStartsWith - */ -function assertStringStartsWith(string $prefix, string $string, string $message = ''): void -{ - Assert::assertStringStartsWith(...\func_get_args()); -} - -/** - * Asserts that a string starts not with a given prefix. - * - * @param string $prefix - * @param string $string - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringStartsNotWith - */ -function assertStringStartsNotWith($prefix, $string, string $message = ''): void -{ - Assert::assertStringStartsNotWith(...\func_get_args()); -} - -/** - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringContainsString - */ -function assertStringContainsString(string $needle, string $haystack, string $message = ''): void -{ - Assert::assertStringContainsString(...\func_get_args()); -} - -/** - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringContainsStringIgnoringCase - */ -function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void -{ - Assert::assertStringContainsStringIgnoringCase(...\func_get_args()); -} - -/** - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotContainsString - */ -function assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void -{ - Assert::assertStringNotContainsString(...\func_get_args()); -} - -/** - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringNotContainsStringIgnoringCase - */ -function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void -{ - Assert::assertStringNotContainsStringIgnoringCase(...\func_get_args()); -} - -/** - * Asserts that a string ends with a given suffix. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringEndsWith - */ -function assertStringEndsWith(string $suffix, string $string, string $message = ''): void -{ - Assert::assertStringEndsWith(...\func_get_args()); -} - -/** - * Asserts that a string ends not with a given suffix. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertStringEndsNotWith - */ -function assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void -{ - Assert::assertStringEndsNotWith(...\func_get_args()); -} - -/** - * Asserts that two XML files are equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlFileEqualsXmlFile - */ -function assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void -{ - Assert::assertXmlFileEqualsXmlFile(...\func_get_args()); -} - -/** - * Asserts that two XML files are not equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlFileNotEqualsXmlFile - */ -function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void -{ - Assert::assertXmlFileNotEqualsXmlFile(...\func_get_args()); -} - -/** - * Asserts that two XML documents are equal. - * - * @param \DOMDocument|string $actualXml - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlStringEqualsXmlFile - */ -function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void -{ - Assert::assertXmlStringEqualsXmlFile(...\func_get_args()); -} - -/** - * Asserts that two XML documents are not equal. - * - * @param \DOMDocument|string $actualXml - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlStringNotEqualsXmlFile - */ -function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void -{ - Assert::assertXmlStringNotEqualsXmlFile(...\func_get_args()); -} - -/** - * Asserts that two XML documents are equal. - * - * @param \DOMDocument|string $expectedXml - * @param \DOMDocument|string $actualXml - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlStringEqualsXmlString - */ -function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = ''): void -{ - Assert::assertXmlStringEqualsXmlString(...\func_get_args()); -} - -/** - * Asserts that two XML documents are not equal. - * - * @param \DOMDocument|string $expectedXml - * @param \DOMDocument|string $actualXml - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * @throws Exception - * - * @see Assert::assertXmlStringNotEqualsXmlString - */ -function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = ''): void -{ - Assert::assertXmlStringNotEqualsXmlString(...\func_get_args()); -} - -/** - * Asserts that a hierarchy of DOMElements matches. - * - * @throws AssertionFailedError - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4091 - * @see Assert::assertEqualXMLStructure - */ -function assertEqualXMLStructure(\DOMElement $expectedElement, \DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void -{ - Assert::assertEqualXMLStructure(...\func_get_args()); -} - -/** - * Evaluates a PHPUnit\Framework\Constraint matcher object. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertThat - */ -function assertThat($value, Constraint $constraint, string $message = ''): void -{ - Assert::assertThat(...\func_get_args()); -} - -/** - * Asserts that a string is a valid JSON string. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJson - */ -function assertJson(string $actualJson, string $message = ''): void -{ - Assert::assertJson(...\func_get_args()); -} - -/** - * Asserts that two given JSON encoded objects or arrays are equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonStringEqualsJsonString - */ -function assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void -{ - Assert::assertJsonStringEqualsJsonString(...\func_get_args()); -} - -/** - * Asserts that two given JSON encoded objects or arrays are not equal. - * - * @param string $expectedJson - * @param string $actualJson - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonStringNotEqualsJsonString - */ -function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, string $message = ''): void -{ - Assert::assertJsonStringNotEqualsJsonString(...\func_get_args()); -} - -/** - * Asserts that the generated JSON encoded object and the content of the given file are equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonStringEqualsJsonFile - */ -function assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void -{ - Assert::assertJsonStringEqualsJsonFile(...\func_get_args()); -} - -/** - * Asserts that the generated JSON encoded object and the content of the given file are not equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonStringNotEqualsJsonFile - */ -function assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void -{ - Assert::assertJsonStringNotEqualsJsonFile(...\func_get_args()); -} - -/** - * Asserts that two JSON files are equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonFileEqualsJsonFile - */ -function assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void -{ - Assert::assertJsonFileEqualsJsonFile(...\func_get_args()); -} - -/** - * Asserts that two JSON files are not equal. - * - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @see Assert::assertJsonFileNotEqualsJsonFile - */ -function assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void -{ - Assert::assertJsonFileNotEqualsJsonFile(...\func_get_args()); -} diff --git a/composer.json b/composer.json index 4d77bb41..dc98600d 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,7 @@ }, "files": [ "src/globals.php", - "src/Pest.php", - "compiled/globals.php" + "src/Pest.php" ] }, "autoload-dev": { @@ -65,7 +64,6 @@ "bin/pest" ], "scripts": { - "compile": "@php ./scripts/compile.php", "lint": "rector process src && php-cs-fixer fix -v", "test:lint": "php-cs-fixer fix -v --dry-run && rector process src --dry-run", "test:types": "phpstan analyse --ansi --memory-limit=0", diff --git a/src/Concerns/TestCase.php b/src/Concerns/TestCase.php index fecd488e..6c1d98ce 100644 --- a/src/Concerns/TestCase.php +++ b/src/Concerns/TestCase.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Pest\Concerns; use Closure; +use Pest\Expectation; use Pest\Support\ExceptionTrace; use Pest\TestSuite; use PHPUnit\Util\Test; @@ -87,6 +88,16 @@ trait TestCase parent::tearDownAfterClass(); } + /** + * Creates a new expectation. + * + * @param mixed $value + */ + public function expect($value): Expectation + { + return new Expectation($value); + } + /** * Gets executed before the test. */ diff --git a/src/Expectation.php b/src/Expectation.php new file mode 100644 index 00000000..1e0f34ba --- /dev/null +++ b/src/Expectation.php @@ -0,0 +1,425 @@ +value = $value; + } + + /** + * Creates a new expectation. + * + * @param mixed $value + */ + public function and($value): Expectation + { + return new self($value); + } + + /** + * Creates the opposite expectation for the value. + */ + public function not(): OppositeExpectation + { + return new OppositeExpectation($this); + } + + /** + * Asserts that two variables have the same type and + * value. Used on objects, it asserts that two + * variables reference the same object. + * + * @param mixed $value + */ + public function toBe($value): Expectation + { + Assert::assertSame($value, $this->value); + + return $this; + } + + /** + * Assert the value is empty. + */ + public function toBeEmpty(): Expectation + { + Assert::assertEmpty($this->value); + + return $this; + } + + /** + * Assert the value is true. + */ + public function toBeTrue(): Expectation + { + Assert::assertTrue($this->value); + + return $this; + } + + /** + * Assert the value is false. + */ + public function toBeFalse(): Expectation + { + Assert::assertFalse($this->value); + + return $this; + } + + /** + * Assert the value is greater than expected one. + * + * @param int|float $value + */ + public function toBeGreaterThan($value): Expectation + { + Assert::assertGreaterThan($value, $this->value); + + return $this; + } + + /** + * Assert that value is greater than or equal to the expected one. + * + * @param int|float $value + */ + public function toBeGreaterThanOrEqual($value): Expectation + { + Assert::assertGreaterThanOrEqual($value, $this->value); + + return $this; + } + + /** + * Assert that value is less than or equal to the expected one. + * + * @param int|float $value + */ + public function toBeLessThan($value): Expectation + { + Assert::assertLessThan($value, $this->value); + + return $this; + } + + /** + * Assert that value is less than the expected one. + * + * @param int|float $value + */ + public function toBeLessThanOrEqual($value): Expectation + { + Assert::assertLessThanOrEqual($value, $this->value); + + return $this; + } + + /** + * Assert that needles is an element of value. + * + * @param mixed $value + */ + public function toContain($value): Expectation + { + if (is_string($this->value)) { + Assert::assertStringContainsString($value, $this->value); + } else { + Assert::assertContains($value, $this->value); + } + + return $this; + } + + /** + * Assert that $count matches the number of elements of $value. + */ + public function toHaveCount(int $count): Expectation + { + Assert::assertCount($count, $this->value); + + return $this; + } + + /** + * Assert that the $value contains the property $name. + */ + public function toHaveProperty(string $name): Expectation + { + Assert::assertTrue(property_exists($this->value, $name)); + + return $this; + } + + /** + * Asserts that two variables have the same value. + * + * @param mixed $value + */ + public function toEqual($value): Expectation + { + Assert::assertEquals($value, $this->value); + + return $this; + } + + /** + * Asserts that two variables have the same value. + * The contents of $expected and $actual are canonicalized before + * they are compared. For instance, when the two variables $value and + * $this->value are arrays, then these arrays are sorted before they are + * compared. When $value and $this->value are objects, + * each object is converted to an array containing all private, + * protected and public attributes. + * + * @param mixed $value + */ + public function toEqualCanonicalizing($value): Expectation + { + Assert::assertEqualsCanonicalizing($value, $this->value); + + return $this; + } + + /** + * Assert that the absolute difference between $value and $this->value + * is greater than $delta. + * + * @param mixed $value + */ + public function toEqualWithDelta($value, float $delta): Expectation + { + Assert::assertEqualsWithDelta($value, $this->value, $delta); + + return $this; + } + + /** + * Assert that the value infinite. + */ + public function toBeInfinite(): Expectation + { + Assert::assertInfinite($this->value); + + return $this; + } + + /** + * Assert that the value is an instance of $value. + * + * @param string $class + */ + public function toBeInstanceOf($class): Expectation + { + /* @phpstan-ignore-next-line */ + Assert::assertInstanceOf($class, $this->value); + + return $this; + } + + /** + * Assert that the value is an array. + */ + public function toBeArray(): Expectation + { + Assert::assertIsArray($this->value); + + return $this; + } + + /** + * Assert that the value is of type bool. + */ + public function toBeBool(): Expectation + { + Assert::assertIsBool($this->value); + + return $this; + } + + /** + * Assert that the value is of type callable. + */ + public function toBeCallable(): Expectation + { + Assert::assertIsCallable($this->value); + + return $this; + } + + /** + * Assert that the value is type of float. + */ + public function toBeFloat(): Expectation + { + Assert::assertIsFloat($this->value); + + return $this; + } + + /** + * Assert that the value is type of int. + */ + public function toBeInt(): Expectation + { + Assert::assertIsInt($this->value); + + return $this; + } + + /** + * Assert that the value is type of iterable. + */ + public function toBeIterable(): Expectation + { + Assert::assertIsIterable($this->value); + + return $this; + } + + /** + * Assert that the value is type of numeric. + */ + public function toBeNumeric(): Expectation + { + Assert::assertIsNumeric($this->value); + + return $this; + } + + /** + * Assert that the value is type of object. + */ + public function toBeObject(): Expectation + { + Assert::assertIsObject($this->value); + + return $this; + } + + /** + * Assert that the value is type of resource. + */ + public function toBeResource(): Expectation + { + Assert::assertIsResource($this->value); + + return $this; + } + + /** + * Assert that the value is type of scalar. + */ + public function toBeScalar(): Expectation + { + Assert::assertIsScalar($this->value); + + return $this; + } + + /** + * Assert that the value is type of string. + */ + public function toBeString(): Expectation + { + Assert::assertIsString($this->value); + + return $this; + } + + /** + * Assert that the value is NAN. + */ + public function toBeNan(): Expectation + { + Assert::assertNan($this->value); + + return $this; + } + + /** + * Assert that the value is null. + */ + public function toBeNull(): Expectation + { + Assert::assertNull($this->value); + + return $this; + } + + /** + * Assert that the value array has the key. + */ + public function toHaveKey(string $key): Expectation + { + Assert::assertArrayHasKey($key, $this->value); + + return $this; + } + + /** + * Assert that the value is a directory. + */ + public function toBeDirectory(): Expectation + { + Assert::assertDirectoryExists($this->value); + + return $this; + } + + /** + * Assert that the value is a directory and is readable. + */ + public function toBeReadableDirectory(): Expectation + { + Assert::assertDirectoryIsReadable($this->value); + + return $this; + } + + /** + * Assert that the value is a directory and is writable. + */ + public function toBeWritableDirectory(): Expectation + { + Assert::assertDirectoryIsWritable($this->value); + + return $this; + } + + /** + * Dynamically calls methods on the class without any arguments. + * + * @return Expectation + */ + public function __get(string $name) + { + /* @phpstan-ignore-next-line */ + return $this->{$name}(); + } +} diff --git a/src/OppositeExpectation.php b/src/OppositeExpectation.php new file mode 100644 index 00000000..4ab4449d --- /dev/null +++ b/src/OppositeExpectation.php @@ -0,0 +1,60 @@ +original = $original; + } + + /** + * Handle dynamic method calls into the original expectation. + * + * @param array $arguments + */ + public function __call(string $name, array $arguments): Expectation + { + try { + /* @phpstan-ignore-next-line */ + $this->original->{$name}(...$arguments); + } catch (ExpectationFailedException $e) { + return $this->original; + } + + throw new ExpectationFailedException(sprintf('@todo')); + } + + /** + * Handle dynamic properties gets into the original expectation. + */ + public function __get(string $name): Expectation + { + try { + /* @phpstan-ignore-next-line */ + $this->original->{$name}; + } catch (ExpectationFailedException $e) { + return $this->original; + } + + throw new ExpectationFailedException(sprintf('@todo')); + } +} diff --git a/src/PendingObjects/TestCall.php b/src/PendingObjects/TestCall.php index e0b7f1c4..613a4a97 100644 --- a/src/PendingObjects/TestCall.php +++ b/src/PendingObjects/TestCall.php @@ -12,6 +12,8 @@ use Pest\TestSuite; use SebastianBergmann\Exporter\Exporter; /** + * @method \Pest\Expectation expect(mixed $value) + * * @internal */ final class TestCall diff --git a/src/globals.php b/src/globals.php index a15f6bea..7e85e9a6 100644 --- a/src/globals.php +++ b/src/globals.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Pest\Datasets; +use Pest\Expectation; use Pest\PendingObjects\AfterEachCall; use Pest\PendingObjects\BeforeEachCall; use Pest\PendingObjects\TestCall; @@ -104,3 +105,15 @@ function afterAll(Closure $closure = null): void { TestSuite::getInstance()->afterAll->set($closure); } + +/** + * Creates a new expectation. + * + * @param mixed $value the Value + * + * @return Expectation + */ +function expect($value) +{ + return test()->expect($value); +} diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 09e41270..ebc40173 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -2,6 +2,176 @@ PASS Tests\CustomTestCase\ExecutedTest ✓ that gets executed + PASS Tests\Expect\not + ✓ not property calls + + PASS Tests\Expect\toBe + ✓ expect true → toBeTrue → and false → toBeFalse + ✓ strict comparisons + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeArray + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeBool + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeCallable + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeDirectory + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeEmpty + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeFalse + ✓ strict comparisons + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeFloat + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeGreatherThan + ✓ passes + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeGreatherThanOrEqual + ✓ passes + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeInfinite + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeInstanceOf + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeInt + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeIterable + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeLessThan + ✓ passes + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeLessThanOrEqual + ✓ passes + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeNAN + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeNull + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeNumeric + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeObject + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeReadableDirectory + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeResource + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeScalar + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeString + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeTrue + ✓ strict comparisons + ✓ failures + ✓ not failures + + PASS Tests\Expect\toBeWritableDirectory + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toContain + ✓ passes strings + ✓ passes arrays + ✓ failures + ✓ not failures + + PASS Tests\Expect\toEqual + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toEqualCanonicalizing + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toEqualWithDelta + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toHaveCount + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toHaveKey + ✓ pass + ✓ failures + ✓ not failures + + PASS Tests\Expect\toHaveProperty + ✓ pass + ✓ failures + ✓ not failures + PASS Tests\Features\AfterAll ✓ deletes file after all @@ -83,8 +253,8 @@ ✓ it has bar PASS Tests\Features\PendingHigherOrderTests - ✓ get 'foo' → get 'bar' → assertTrue true - ✓ get 'foo' → assertTrue true + ✓ get 'foo' → get 'bar' → expect true → toBeTrue + ✓ get 'foo' → expect true → toBeTrue WARN Tests\Features\Skip ✓ it do not skips @@ -167,5 +337,5 @@ WARN Tests\Visual\Success - visual snapshot of test suite on success - Tests: 6 skipped, 96 passed - Time: 3.43s + Tests: 6 skipped, 198 passed + Time: 5.46s diff --git a/tests/Autoload.php b/tests/Autoload.php index 9283dbad..1e181ad2 100644 --- a/tests/Autoload.php +++ b/tests/Autoload.php @@ -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); } } diff --git a/tests/Expect/not.php b/tests/Expect/not.php new file mode 100644 index 00000000..79220b19 --- /dev/null +++ b/tests/Expect/not.php @@ -0,0 +1,10 @@ +toBeTrue() + ->not()->toBeFalse() + ->not->toBeFalse + ->and(false) + ->toBeFalse(); +}); diff --git a/tests/Expect/toBe.php b/tests/Expect/toBe.php new file mode 100644 index 00000000..ef2bce5a --- /dev/null +++ b/tests/Expect/toBe.php @@ -0,0 +1,20 @@ +toBeTrue()->and(false)->toBeFalse(); + +test('strict comparisons', function () { + $nuno = new stdClass(); + $dries = new stdClass(); + + expect($nuno)->toBe($nuno)->not->toBe($dries); +}); + +test('failures', function () { + expect(1)->toBe(2); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(1)->not->toBe(1); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeArray.php b/tests/Expect/toBeArray.php new file mode 100644 index 00000000..3fcec231 --- /dev/null +++ b/tests/Expect/toBeArray.php @@ -0,0 +1,16 @@ +toBeArray(); + expect('1, 2, 3')->not->toBeArray(); +}); + +test('failures', function () { + expect(null)->toBeArray(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(['a', 'b', 'c'])->not->toBeArray(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeBool.php b/tests/Expect/toBeBool.php new file mode 100644 index 00000000..5dc37b21 --- /dev/null +++ b/tests/Expect/toBeBool.php @@ -0,0 +1,16 @@ +toBeBool(); + expect(0)->not->toBeBool(); +}); + +test('failures', function () { + expect(null)->toBeBool(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(false)->not->toBeBool(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeCallable.php b/tests/Expect/toBeCallable.php new file mode 100644 index 00000000..2bd8f139 --- /dev/null +++ b/tests/Expect/toBeCallable.php @@ -0,0 +1,18 @@ +toBeCallable(); + expect(null)->not->toBeCallable(); +}); + +test('failures', function () { + $hello = 5; + + expect($hello)->toBeCallable(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(function () { return 42; })->not->toBeCallable(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeDirectory.php b/tests/Expect/toBeDirectory.php new file mode 100644 index 00000000..f30df144 --- /dev/null +++ b/tests/Expect/toBeDirectory.php @@ -0,0 +1,17 @@ +toBeDirectory(); +}); + +test('failures', function () { + expect('/random/path/whatever')->toBeDirectory(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect('.')->not->toBeDirectory(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeEmpty.php b/tests/Expect/toBeEmpty.php new file mode 100644 index 00000000..05e5180a --- /dev/null +++ b/tests/Expect/toBeEmpty.php @@ -0,0 +1,18 @@ +toBeEmpty(); + expect(null)->toBeEmpty(); +}); + +test('failures', function () { + expect([1, 2])->toBeEmpty(); + expect(' ')->toBeEmpty(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect([])->not->toBeEmpty(); + expect(null)->not->toBeEmpty(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeFalse.php b/tests/Expect/toBeFalse.php new file mode 100644 index 00000000..1371c86e --- /dev/null +++ b/tests/Expect/toBeFalse.php @@ -0,0 +1,15 @@ +toBeFalse(); +}); + +test('failures', function () { + expect('')->toBeFalse(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(false)->not->toBe(false); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeFloat.php b/tests/Expect/toBeFloat.php new file mode 100644 index 00000000..69aa2306 --- /dev/null +++ b/tests/Expect/toBeFloat.php @@ -0,0 +1,16 @@ +toBeFloat(); + expect(1)->not->toBeFloat(); +}); + +test('failures', function () { + expect(42)->toBeFloat(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(log(3))->not->toBeFloat(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeGreatherThan.php b/tests/Expect/toBeGreatherThan.php new file mode 100644 index 00000000..ed840ed6 --- /dev/null +++ b/tests/Expect/toBeGreatherThan.php @@ -0,0 +1,16 @@ +toBeGreaterThan(41); + expect(4)->toBeGreaterThan(3.9); +}); + +test('failures', function () { + expect(4)->toBeGreaterThan(4); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(5)->not->toBeGreaterThan(4); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeGreatherThanOrEqual.php b/tests/Expect/toBeGreatherThanOrEqual.php new file mode 100644 index 00000000..3b1cd029 --- /dev/null +++ b/tests/Expect/toBeGreatherThanOrEqual.php @@ -0,0 +1,16 @@ +toBeGreaterThanOrEqual(41); + expect(4)->toBeGreaterThanOrEqual(4); +}); + +test('failures', function () { + expect(4)->toBeGreaterThanOrEqual(4.1); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(5)->not->toBeGreaterThanOrEqual(5); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeInfinite.php b/tests/Expect/toBeInfinite.php new file mode 100644 index 00000000..ebcb0a36 --- /dev/null +++ b/tests/Expect/toBeInfinite.php @@ -0,0 +1,16 @@ +toBeInfinite(); + expect(log(1))->not->toBeInfinite(); +}); + +test('failures', function () { + expect(asin(2))->toBeInfinite(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(INF)->not->toBeInfinite(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeInstanceOf.php b/tests/Expect/toBeInstanceOf.php new file mode 100644 index 00000000..03b3e881 --- /dev/null +++ b/tests/Expect/toBeInstanceOf.php @@ -0,0 +1,16 @@ +toBeInstanceOf(Exception::class); + expect(new Exception())->not->toBeInstanceOf(RuntimeException::class); +}); + +test('failures', function () { + expect(new Exception())->toBeInstanceOf(RuntimeException::class); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(new Exception())->not->toBeInstanceOf(Exception::class); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeInt.php b/tests/Expect/toBeInt.php new file mode 100644 index 00000000..9eb1b3db --- /dev/null +++ b/tests/Expect/toBeInt.php @@ -0,0 +1,16 @@ +toBeInt(); + expect(42.0)->not->toBeInt(); +}); + +test('failures', function () { + expect(42.0)->toBeInt(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(6 * 7)->not->toBeInt(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeIterable.php b/tests/Expect/toBeIterable.php new file mode 100644 index 00000000..fca23688 --- /dev/null +++ b/tests/Expect/toBeIterable.php @@ -0,0 +1,23 @@ +toBeIterable(); + expect(null)->not->toBeIterable(); +}); + +test('failures', function () { + expect(42)->toBeIterable(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + function gen(): iterable + { + yield 1; + yield 2; + yield 3; + } + + expect(gen())->not->toBeIterable(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeLessThan.php b/tests/Expect/toBeLessThan.php new file mode 100644 index 00000000..08db8545 --- /dev/null +++ b/tests/Expect/toBeLessThan.php @@ -0,0 +1,16 @@ +toBeLessThan(42); + expect(4)->toBeLessThan(5); +}); + +test('failures', function () { + expect(4)->toBeLessThan(4); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(5)->not->toBeLessThan(6); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeLessThanOrEqual.php b/tests/Expect/toBeLessThanOrEqual.php new file mode 100644 index 00000000..c9f00577 --- /dev/null +++ b/tests/Expect/toBeLessThanOrEqual.php @@ -0,0 +1,16 @@ +toBeLessThanOrEqual(42); + expect(4)->toBeLessThanOrEqual(4); +}); + +test('failures', function () { + expect(4)->toBeLessThanOrEqual(3.9); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(5)->not->toBeLessThanOrEqual(5); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeNAN.php b/tests/Expect/toBeNAN.php new file mode 100644 index 00000000..0767f1ad --- /dev/null +++ b/tests/Expect/toBeNAN.php @@ -0,0 +1,16 @@ +toBeNan(); + expect(log(0))->not->toBeNan(); +}); + +test('failures', function () { + expect(1)->toBeNan(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(acos(1.5))->not->toBeNan(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeNull.php b/tests/Expect/toBeNull.php new file mode 100644 index 00000000..2bd7d987 --- /dev/null +++ b/tests/Expect/toBeNull.php @@ -0,0 +1,16 @@ +toBeNull(); + expect('')->not->toBeNull(); +}); + +test('failures', function () { + expect('hello')->toBeNull(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(null)->not->toBeNull(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeNumeric.php b/tests/Expect/toBeNumeric.php new file mode 100644 index 00000000..710ca236 --- /dev/null +++ b/tests/Expect/toBeNumeric.php @@ -0,0 +1,16 @@ +toBeNumeric(); + expect('A')->not->toBeNumeric(); +}); + +test('failures', function () { + expect(null)->toBeNumeric(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(6 * 7)->not->toBeNumeric(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeObject.php b/tests/Expect/toBeObject.php new file mode 100644 index 00000000..e227b4cb --- /dev/null +++ b/tests/Expect/toBeObject.php @@ -0,0 +1,16 @@ + 1])->toBeObject(); + expect(['a' => 1])->not->toBeObject(); +}); + +test('failures', function () { + expect(null)->toBeObject(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect((object) 'ciao')->not->toBeObject(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeReadableDirectory.php b/tests/Expect/toBeReadableDirectory.php new file mode 100644 index 00000000..88f96019 --- /dev/null +++ b/tests/Expect/toBeReadableDirectory.php @@ -0,0 +1,15 @@ +toBeWritableDirectory(); +}); + +test('failures', function () { + expect('/random/path/whatever')->toBeWritableDirectory(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(sys_get_temp_dir())->not->toBeWritableDirectory(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeResource.php b/tests/Expect/toBeResource.php new file mode 100644 index 00000000..575fabe3 --- /dev/null +++ b/tests/Expect/toBeResource.php @@ -0,0 +1,22 @@ +toBeResource(); + expect(null)->not->toBeResource(); +}); + +test('failures', function () { + expect(null)->toBeResource(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () use ($resource) { + expect($resource)->not->toBeResource(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeScalar.php b/tests/Expect/toBeScalar.php new file mode 100644 index 00000000..236c0e0b --- /dev/null +++ b/tests/Expect/toBeScalar.php @@ -0,0 +1,15 @@ +toBeScalar(); +}); + +test('failures', function () { + expect(null)->toBeScalar(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(42)->not->toBeScalar(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeString.php b/tests/Expect/toBeString.php new file mode 100644 index 00000000..91c31881 --- /dev/null +++ b/tests/Expect/toBeString.php @@ -0,0 +1,16 @@ +toBeString(); + expect(1.1)->not->toBeString(); +}); + +test('failures', function () { + expect(null)->toBeString(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect('42')->not->toBeString(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeTrue.php b/tests/Expect/toBeTrue.php new file mode 100644 index 00000000..8e998f9b --- /dev/null +++ b/tests/Expect/toBeTrue.php @@ -0,0 +1,15 @@ +toBeTrue(); +}); + +test('failures', function () { + expect('')->toBeTrue(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(false)->not->toBe(false); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toBeWritableDirectory.php b/tests/Expect/toBeWritableDirectory.php new file mode 100644 index 00000000..88f96019 --- /dev/null +++ b/tests/Expect/toBeWritableDirectory.php @@ -0,0 +1,15 @@ +toBeWritableDirectory(); +}); + +test('failures', function () { + expect('/random/path/whatever')->toBeWritableDirectory(); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(sys_get_temp_dir())->not->toBeWritableDirectory(); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toContain.php b/tests/Expect/toContain.php new file mode 100644 index 00000000..04d586ff --- /dev/null +++ b/tests/Expect/toContain.php @@ -0,0 +1,19 @@ +toContain(42); +}); + +test('passes arrays', function () { + expect('Nuno')->toContain('Nu'); +}); + +test('failures', function () { + expect([1, 2, 42])->toContain(3); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect([1, 2, 42])->not->toContain(42); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toEqual.php b/tests/Expect/toEqual.php new file mode 100644 index 00000000..de0b7e50 --- /dev/null +++ b/tests/Expect/toEqual.php @@ -0,0 +1,15 @@ +toEqual(123); +}); + +test('failures', function () { + expect(['a', 'b', 'c'])->toEqual(['a', 'b']); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect('042')->not->toEqual(42); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toEqualCanonicalizing.php b/tests/Expect/toEqualCanonicalizing.php new file mode 100644 index 00000000..5e1178b9 --- /dev/null +++ b/tests/Expect/toEqualCanonicalizing.php @@ -0,0 +1,16 @@ +toEqualCanonicalizing([3, 1, 2]); + expect(['g', 'a', 'z'])->not->toEqualCanonicalizing(['a', 'z']); +}); + +test('failures', function () { + expect([3, 2, 1])->toEqualCanonicalizing([1, 2]); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(['a', 'b', 'c'])->not->toEqualCanonicalizing(['b', 'a', 'c']); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toEqualWithDelta.php b/tests/Expect/toEqualWithDelta.php new file mode 100644 index 00000000..bb78b86d --- /dev/null +++ b/tests/Expect/toEqualWithDelta.php @@ -0,0 +1,15 @@ +toEqualWithDelta(1.3, .4); +}); + +test('failures', function () { + expect(1.0)->toEqualWithDelta(1.5, .1); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(1.0)->not->toEqualWithDelta(1.6, .7); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toHaveCount.php b/tests/Expect/toHaveCount.php new file mode 100644 index 00000000..a1948260 --- /dev/null +++ b/tests/Expect/toHaveCount.php @@ -0,0 +1,15 @@ +toHaveCount(3); +}); + +test('failures', function () { + expect([1, 2, 3])->toHaveCount(4); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect([1, 2, 3])->not->toHaveCount(3); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toHaveKey.php b/tests/Expect/toHaveKey.php new file mode 100644 index 00000000..1695688b --- /dev/null +++ b/tests/Expect/toHaveKey.php @@ -0,0 +1,15 @@ + 1, 'b', 'c' => 'world'])->toHaveKey('c'); +}); + +test('failures', function () { + expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKey('hello'); +})->throws(ExpectationFailedException::class); + +test('not failures', function () { + expect(['a' => 1, 'hello' => 'world', 'c'])->not->toHaveKey('hello'); +})->throws(ExpectationFailedException::class); diff --git a/tests/Expect/toHaveProperty.php b/tests/Expect/toHaveProperty.php new file mode 100644 index 00000000..a7c0c649 --- /dev/null +++ b/tests/Expect/toHaveProperty.php @@ -0,0 +1,18 @@ +foo = 'bar'; + +test('pass', function () use ($obj) { + expect($obj)->toHaveProperty('foo'); +}); + +test('failures', function () use ($obj) { + expect($obj)->toHaveProperty('bar'); +})->throws(ExpectationFailedException::class); + +test('not failures', function () use ($obj) { + expect($obj)->not->toHaveProperty('foo'); +})->throws(ExpectationFailedException::class); diff --git a/tests/Features/AfterAll.php b/tests/Features/AfterAll.php index e78e12a5..1b66792e 100644 --- a/tests/Features/AfterAll.php +++ b/tests/Features/AfterAll.php @@ -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); }); }); diff --git a/tests/Features/AfterEach.php b/tests/Features/AfterEach.php index 4563e717..e16f8529 100644 --- a/tests/Features/AfterEach.php +++ b/tests/Features/AfterEach.php @@ -11,10 +11,10 @@ afterEach(function () use ($state) { }); it('does not get executed before the test', function () { - assertFalse(property_exists($this->state, 'bar')); + expect($this->state)->not->toHaveProperty('bar'); }); it('gets executed after the test', function () { - assertTrue(property_exists($this->state, 'bar')); - assertEquals(2, $this->state->bar); + expect($this->state)->toHaveProperty('bar'); + expect($this->state->bar)->toBe(2); }); diff --git a/tests/Features/BeforeAll.php b/tests/Features/BeforeAll.php index 4095e68a..e8e458bc 100644 --- a/tests/Features/BeforeAll.php +++ b/tests/Features/BeforeAll.php @@ -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'); }); diff --git a/tests/Features/BeforeEach.php b/tests/Features/BeforeEach.php index 94c5adc3..a2e70d61 100644 --- a/tests/Features/BeforeEach.php +++ b/tests/Features/BeforeEach.php @@ -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); }); diff --git a/tests/Features/Datasets.php b/tests/Features/Datasets.php index 35764433..81f41b34 100644 --- a/tests/Features/Datasets.php +++ b/tests/Features/Datasets.php @@ -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); }); diff --git a/tests/Features/Depends.php b/tests/Features/Depends.php index 0e7ed5ea..edab5956 100644 --- a/tests/Features/Depends.php +++ b/tests/Features/Depends.php @@ -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'); diff --git a/tests/Features/Helpers.php b/tests/Features/Helpers.php index 24377e00..163ede9d 100644 --- a/tests/Features/Helpers.php +++ b/tests/Features/Helpers.php @@ -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 () { @@ -27,15 +27,14 @@ function mockUser() $mock = test()->createMock(User::class); $mock->method('getName') - ->willReturn('maduro'); + ->willReturn('maduro'); return $mock; } 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 () { diff --git a/tests/Features/It.php b/tests/Features/It.php index 9ab6e384..384e12bd 100644 --- a/tests/Features/It.php +++ b/tests/Features/It.php @@ -1,7 +1,7 @@ '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(); diff --git a/tests/Features/Macro.php b/tests/Features/Macro.php index fa9f63ee..c0893355 100644 --- a/tests/Features/Macro.php +++ b/tests/Features/Macro.php @@ -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(); diff --git a/tests/Features/PendingHigherOrderTests.php b/tests/Features/PendingHigherOrderTests.php index de178c51..cf68dcc6 100644 --- a/tests/Features/PendingHigherOrderTests.php +++ b/tests/Features/PendingHigherOrderTests.php @@ -1,11 +1,12 @@ 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(); diff --git a/tests/Features/Test.php b/tests/Features/Test.php index d2e53ed0..e3334305 100644 --- a/tests/Features/Test.php +++ b/tests/Features/Test.php @@ -1,7 +1,7 @@ 'foo']); + $this->assertArrayHasKey('key', ['key' => 'foo']); }); -test('higher order message test')->assertTrue(true); +test('higher order message test')->expect(true)->toBeTrue(); diff --git a/tests/Features/TestCycle.php b/tests/Features/TestCycle.php index d941dcf2..7d3b785d 100644 --- a/tests/Features/TestCycle.php +++ b/tests/Features/TestCycle.php @@ -1,5 +1,7 @@ beforeAll = false; $foo->beforeEach = false; diff --git a/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder/CustomTestCaseInSubFolder.php b/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder/CustomTestCaseInSubFolder.php index 2cd2999d..ee6b1489 100644 --- a/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder/CustomTestCaseInSubFolder.php +++ b/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder/CustomTestCaseInSubFolder.php @@ -10,6 +10,6 @@ class CustomTestCaseInSubFolder extends TestCase { public function assertCustomInSubFolderTrue() { - assertTrue(true); + $this->assertTrue(true); } } diff --git a/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder2/UsesPerFile.php b/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder2/UsesPerFile.php index e0673174..8e582bcf 100644 --- a/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder2/UsesPerFile.php +++ b/tests/PHPUnit/CustomTestCaseInSubFolders/SubFolder2/UsesPerFile.php @@ -12,7 +12,7 @@ class MyCustomClass extends PHPUnit\Framework\TestCase { public function assertTrueIsTrue() { - assertTrue(true); + $this->assertTrue(true); } } diff --git a/tests/Playground.php b/tests/Playground.php index e24277b1..be30ae7d 100644 --- a/tests/Playground.php +++ b/tests/Playground.php @@ -1,5 +1,5 @@ toBeTrue(); }); diff --git a/tests/Unit/Actions/AddsDefaults.php b/tests/Unit/Actions/AddsDefaults.php index 7a55adc5..eef7b027 100644 --- a/tests/Unit/Actions/AddsDefaults.php +++ b/tests/Unit/Actions/AddsDefaults.php @@ -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, ]); }); diff --git a/tests/Unit/Actions/AddsTests.php b/tests/Unit/Actions/AddsTests.php index 925e3574..9f1beec0 100644 --- a/tests/Unit/Actions/AddsTests.php +++ b/tests/Unit/Actions/AddsTests.php @@ -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); }); diff --git a/tests/Unit/Actions/ValidatesConfiguration.php b/tests/Unit/Actions/ValidatesConfiguration.php index 24edc4f0..a26a4105 100644 --- a/tests/Unit/Actions/ValidatesConfiguration.php +++ b/tests/Unit/Actions/ValidatesConfiguration.php @@ -38,5 +38,5 @@ it('do not throws exception when `process isolation` is false', function () { 'configuration' => $filename, ]); - assertTrue(true); + expect(true)->toBeTrue(); }); diff --git a/tests/Unit/Plugins/Version.php b/tests/Unit/Plugins/Version.php index 0bd19052..0bd5feb7 100644 --- a/tests/Unit/Plugins/Version.php +++ b/tests/Unit/Plugins/Version.php @@ -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(''); }); diff --git a/tests/Unit/Support/Backtrace.php b/tests/Unit/Support/Backtrace.php index 55886512..6dba0ed5 100644 --- a/tests/Unit/Support/Backtrace.php +++ b/tests/Unit/Support/Backtrace.php @@ -7,5 +7,5 @@ it('gets file name from called file', function () { return Backtrace::file(); }; - assertEquals(__FILE__, $a()); + expect($a())->toBe(__FILE__); }); diff --git a/tests/Unit/Support/Container.php b/tests/Unit/Support/Container.php index 13a369ff..f42ba030 100644 --- a/tests/Unit/Support/Container.php +++ b/tests/Unit/Support/Container.php @@ -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 () { diff --git a/tests/Unit/Support/Reflection.php b/tests/Unit/Support/Reflection.php index 56d5515a..7ad76b0d 100644 --- a/tests/Unit/Support/Reflection.php +++ b/tests/Unit/Support/Reflection.php @@ -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'); }); diff --git a/tests/Visual/SingleTestOrDirectory.php b/tests/Visual/SingleTestOrDirectory.php index 893caf3a..ef5ab6fa 100644 --- a/tests/Visual/SingleTestOrDirectory.php +++ b/tests/Visual/SingleTestOrDirectory.php @@ -10,7 +10,7 @@ $run = function (string $target, $decorated = false) { return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput()); }; -$snapshot = function ($name) { +$snapshot = function ($name) { $testsPath = dirname(__DIR__); return file_get_contents(implode(DIRECTORY_SEPARATOR, [ @@ -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'); diff --git a/tests/Visual/Success.php b/tests/Visual/Success.php index 97cbee6a..14af013e 100644 --- a/tests/Visual/Success.php +++ b/tests/Visual/Success.php @@ -22,7 +22,8 @@ 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');