first commit
This commit is contained in:
30
vendor/codeception/module-asserts/.github/workflows/main.yml
vendored
Normal file
30
vendor/codeception/module-asserts/.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: [8.1, 8.2, 8.3, 8.4]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
|
||||
|
||||
- name: Run test suite
|
||||
run: php vendor/bin/codecept run
|
||||
21
vendor/codeception/module-asserts/LICENSE
vendored
Normal file
21
vendor/codeception/module-asserts/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 Michael Bodnarchuk and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
41
vendor/codeception/module-asserts/composer.json
vendored
Normal file
41
vendor/codeception/module-asserts/composer.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "codeception/module-asserts",
|
||||
"description": "Codeception module containing various assertions",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"codeception",
|
||||
"asserts",
|
||||
"assertions"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Bodnarchuk"
|
||||
},
|
||||
{
|
||||
"name": "Gintautas Miselis"
|
||||
},
|
||||
{
|
||||
"name": "Gustavo Nieves",
|
||||
"homepage": "https://medium.com/@ganieves"
|
||||
}
|
||||
],
|
||||
"homepage": "https://codeception.com/",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"codeception/codeception": "*@dev",
|
||||
"codeception/lib-asserts": "^2.0"
|
||||
},
|
||||
"conflict": {
|
||||
"codeception/codeception": "<5.0"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"classmap-authoritative": true
|
||||
}
|
||||
}
|
||||
150
vendor/codeception/module-asserts/src/Codeception/Module/AbstractAsserts.php
vendored
Normal file
150
vendor/codeception/module-asserts/src/Codeception/Module/AbstractAsserts.php
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Module;
|
||||
|
||||
use Codeception\Module;
|
||||
use Codeception\Util\Shared\Asserts;
|
||||
|
||||
abstract class AbstractAsserts extends Module
|
||||
{
|
||||
use Asserts {
|
||||
assertArrayHasKey as public;
|
||||
assertArrayNotHasKey as public;
|
||||
assertClassHasAttribute as public;
|
||||
assertClassHasStaticAttribute as public;
|
||||
assertClassNotHasAttribute as public;
|
||||
assertClassNotHasStaticAttribute as public;
|
||||
assertContains as public;
|
||||
assertContainsEquals as public;
|
||||
assertContainsOnly as public;
|
||||
assertContainsOnlyInstancesOf as public;
|
||||
assertCount as public;
|
||||
assertDirectoryDoesNotExist as public;
|
||||
assertDirectoryExists as public;
|
||||
assertDirectoryIsNotReadable as public;
|
||||
assertDirectoryIsNotWritable as public;
|
||||
assertDirectoryIsReadable as public;
|
||||
assertDirectoryIsWritable as public;
|
||||
assertDoesNotMatchRegularExpression as public;
|
||||
assertEmpty as public;
|
||||
assertEquals as public;
|
||||
assertEqualsCanonicalizing as public;
|
||||
assertEqualsIgnoringCase as public;
|
||||
assertEqualsWithDelta as public;
|
||||
assertFalse as public;
|
||||
assertFileDoesNotExist as public;
|
||||
assertFileEquals as public;
|
||||
assertFileEqualsCanonicalizing as public;
|
||||
assertFileEqualsIgnoringCase as public;
|
||||
assertFileExists as public;
|
||||
assertFileIsNotReadable as public;
|
||||
assertFileIsNotWritable as public;
|
||||
assertFileIsReadable as public;
|
||||
assertFileIsWritable as public;
|
||||
assertFileNotEquals as public;
|
||||
assertFileNotEqualsCanonicalizing as public;
|
||||
assertFileNotEqualsIgnoringCase as public;
|
||||
assertFileNotExists as public;
|
||||
assertFinite as public;
|
||||
assertGreaterOrEquals as public;
|
||||
assertGreaterThan as public;
|
||||
assertGreaterThanOrEqual as public;
|
||||
assertInfinite as public;
|
||||
assertInstanceOf as public;
|
||||
assertIsArray as public;
|
||||
assertIsBool as public;
|
||||
assertIsCallable as public;
|
||||
assertIsClosedResource as public;
|
||||
assertIsEmpty as public;
|
||||
assertIsFloat as public;
|
||||
assertIsInt as public;
|
||||
assertIsIterable as public;
|
||||
assertIsNotArray as public;
|
||||
assertIsNotBool as public;
|
||||
assertIsNotCallable as public;
|
||||
assertIsNotClosedResource as public;
|
||||
assertIsNotFloat as public;
|
||||
assertIsNotInt as public;
|
||||
assertIsNotIterable as public;
|
||||
assertIsNotNumeric as public;
|
||||
assertIsNotObject as public;
|
||||
assertIsNotReadable as public;
|
||||
assertIsNotResource as public;
|
||||
assertIsNotScalar as public;
|
||||
assertIsNotString as public;
|
||||
assertIsNotWritable as public;
|
||||
assertIsNumeric as public;
|
||||
assertIsObject as public;
|
||||
assertIsReadable as public;
|
||||
assertIsResource as public;
|
||||
assertIsScalar as public;
|
||||
assertIsString as public;
|
||||
assertIsWritable as public;
|
||||
assertJson as public;
|
||||
assertJsonFileEqualsJsonFile as public;
|
||||
assertJsonFileNotEqualsJsonFile as public;
|
||||
assertJsonStringEqualsJsonFile as public;
|
||||
assertJsonStringEqualsJsonString as public;
|
||||
assertJsonStringNotEqualsJsonFile as public;
|
||||
assertJsonStringNotEqualsJsonString as public;
|
||||
assertLessOrEquals as public;
|
||||
assertLessThan as public;
|
||||
assertLessThanOrEqual as public;
|
||||
assertMatchesRegularExpression as public;
|
||||
assertNan as public;
|
||||
assertNotContains as public;
|
||||
assertNotContainsEquals as public;
|
||||
assertNotContainsOnly as public;
|
||||
assertNotCount as public;
|
||||
assertNotEmpty as public;
|
||||
assertNotEquals as public;
|
||||
assertNotEqualsCanonicalizing as public;
|
||||
assertNotEqualsIgnoringCase as public;
|
||||
assertNotEqualsWithDelta as public;
|
||||
assertNotFalse as public;
|
||||
assertNotInstanceOf as public;
|
||||
assertNotNull as public;
|
||||
assertNotRegExp as public;
|
||||
assertNotSame as public;
|
||||
assertNotSameSize as public;
|
||||
assertNotTrue as public;
|
||||
assertNull as public;
|
||||
assertObjectHasAttribute as public;
|
||||
assertObjectNotHasAttribute as public;
|
||||
assertRegExp as public;
|
||||
assertSame as public;
|
||||
assertSameSize as public;
|
||||
assertStringContainsString as public;
|
||||
assertStringContainsStringIgnoringCase as public;
|
||||
assertStringEndsNotWith as public;
|
||||
assertStringEndsWith as public;
|
||||
assertStringEqualsFile as public;
|
||||
assertStringEqualsFileCanonicalizing as public;
|
||||
assertStringEqualsFileIgnoringCase as public;
|
||||
assertStringMatchesFormat as public;
|
||||
assertStringMatchesFormatFile as public;
|
||||
assertStringNotContainsString as public;
|
||||
assertStringNotContainsStringIgnoringCase as public;
|
||||
assertStringNotEqualsFile as public;
|
||||
assertStringNotEqualsFileCanonicalizing as public;
|
||||
assertStringNotEqualsFileIgnoringCase as public;
|
||||
assertStringNotMatchesFormat as public;
|
||||
assertStringNotMatchesFormatFile as public;
|
||||
assertStringStartsNotWith as public;
|
||||
assertStringStartsWith as public;
|
||||
assertThat as public;
|
||||
assertThatItsNot as public;
|
||||
assertTrue as public;
|
||||
assertXmlFileEqualsXmlFile as public;
|
||||
assertXmlFileNotEqualsXmlFile as public;
|
||||
assertXmlStringEqualsXmlFile as public;
|
||||
assertXmlStringEqualsXmlString as public;
|
||||
assertXmlStringNotEqualsXmlFile as public;
|
||||
assertXmlStringNotEqualsXmlString as public;
|
||||
fail as public;
|
||||
markTestIncomplete as public;
|
||||
markTestSkipped as public;
|
||||
}
|
||||
}
|
||||
93
vendor/codeception/module-asserts/src/Codeception/Module/Asserts.php
vendored
Normal file
93
vendor/codeception/module-asserts/src/Codeception/Module/Asserts.php
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Module;
|
||||
|
||||
/**
|
||||
* Special module for using asserts in your tests.
|
||||
*/
|
||||
class Asserts extends AbstractAsserts
|
||||
{
|
||||
/**
|
||||
* Handles and checks throwables (Exceptions/Errors) called inside the callback function.
|
||||
* Either throwable class name or throwable instance should be provided.
|
||||
*
|
||||
* ```php
|
||||
* <?php
|
||||
* $I->expectThrowable(MyThrowable::class, function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
*
|
||||
* $I->expectThrowable(new MyException(), function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
* ```
|
||||
* If you want to check message or throwable code, you can pass them with throwable instance:
|
||||
* ```php
|
||||
* <?php
|
||||
* // will check that throwable MyError is thrown with "Don't do bad things" message
|
||||
* $I->expectThrowable(new MyError("Don't do bad things"), function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param \Throwable|string $throwable
|
||||
*/
|
||||
public function expectThrowable($throwable, callable $callback): void
|
||||
{
|
||||
if (is_object($throwable)) {
|
||||
$class = get_class($throwable);
|
||||
$msg = $throwable->getMessage();
|
||||
$code = $throwable->getCode();
|
||||
} else {
|
||||
$class = $throwable;
|
||||
$msg = null;
|
||||
$code = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$callback();
|
||||
} catch (\Throwable $t) {
|
||||
$this->checkThrowable($t, $class, $msg, $code);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail("Expected throwable of class '{$class}' to be thrown, but nothing was caught");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given throwable matches the expected data,
|
||||
* fail (throws an exception) if it does not.
|
||||
*/
|
||||
protected function checkThrowable(\Throwable $throwable, string $expectedClass, ?string $expectedMsg, $expectedCode = null): void
|
||||
{
|
||||
if (!($throwable instanceof $expectedClass)) {
|
||||
$this->fail(sprintf(
|
||||
"Exception of class '%s' expected to be thrown, but class '%s' was caught",
|
||||
$expectedClass,
|
||||
get_class($throwable)
|
||||
));
|
||||
}
|
||||
|
||||
if (null !== $expectedMsg && $throwable->getMessage() !== $expectedMsg) {
|
||||
$this->fail(sprintf(
|
||||
"Exception of class '%s' expected to have message '%s', but actual message was '%s'",
|
||||
$expectedClass,
|
||||
$expectedMsg,
|
||||
$throwable->getMessage()
|
||||
));
|
||||
}
|
||||
|
||||
if (null !== $expectedCode && $throwable->getCode() !== $expectedCode) {
|
||||
$this->fail(sprintf(
|
||||
"Exception of class '%s' expected to have code '%s', but actual code was '%s'",
|
||||
$expectedClass,
|
||||
$expectedCode,
|
||||
$throwable->getCode()
|
||||
));
|
||||
}
|
||||
|
||||
$this->assertTrue(true); // increment assertion counter
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user