Skip to content

Commit

Permalink
refactor(testing)!: Removed deprecated `\LastDragon_ru\LaraASP\Testin…
Browse files Browse the repository at this point in the history
…g\Assertions\ResponseAssertions::assertThatResponse()`, `\LastDragon_ru\LaraASP\Testing\Database\RefreshDatabaseIfEmpty`, `\LastDragon_ru\LaraASP\Testing\TestCase`.
  • Loading branch information
LastDragon-ru committed Jan 11, 2025
1 parent 710ce90 commit f026fc7
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 377 deletions.
6 changes: 0 additions & 6 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php declare(strict_types = 1);

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\RefreshDatabaseState;
use Illuminate\Foundation\Testing\TestCase;
use Orchestra\Testbench\TestCase as TestbenchTestCase;
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
Expand All @@ -16,9 +13,6 @@
->ignoreErrorsOnPackage('bamarni/composer-bin-plugin', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('laravel/scout', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreUnknownClasses([
RefreshDatabase::class,
RefreshDatabaseState::class,
TestCase::class,
TestbenchTestCase::class,
]);

Expand Down
42 changes: 3 additions & 39 deletions packages/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,36 +135,6 @@ Makes comparison of scalars strict.

## PHPUnit `TestCase`

### [`RefreshDatabaseIfEmpty`](./src/Database/RefreshDatabaseIfEmpty.php) 💀

[include:docblock]: ./src/Database/RefreshDatabaseIfEmpty.php
[//]: # (start: preprocess/94562f6acfa81b98)
[//]: # (warning: Generated automatically. Do not edit.)

The trait is very similar to standard `\Illuminate\Foundation\Testing\RefreshDatabase` but there is one
difference: it will refresh the database only if it is empty. This is very
useful for local testing and allow significantly reduce bootstrap time.

[//]: # (end: preprocess/94562f6acfa81b98)

```php
<?php declare(strict_types = 1);

namespace Tests;

use LastDragon_ru\LaraASP\Testing\Database\RefreshDatabaseIfEmpty;
use LastDragon_ru\LaraASP\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase {
use CreatesApplication;
use RefreshDatabaseIfEmpty;

protected function shouldSeed() {
return true;
}
}
```

### [`WithTempDirectory`](./src/Utils/WithTempDirectory.php)

[include:docblock]: ./src/Utils/WithTempDirectory.php
Expand Down Expand Up @@ -250,9 +220,9 @@ Disable models events during make/create.

| Name | Description |
|-----------------------------------------------------------------------------|----------------------------------------------------------------|
| [`assertThat()`](./docs/Assertions/AssertThatResponse.md) | Asserts that response satisfies given constraint. |
| [`assertContentType()`](./docs/Assertions/AssertThatResponse.md) | Asserts that a response has a specified content type. |
| [`assertStatusCode()`](./docs/Assertions/AssertThatResponse.md) | Asserts that a response has a specified status code. |
| [`assertThat()`](./docs/Assertions/AssertPsrResponse.md) | Asserts that response satisfies given constraint. |
| [`assertContentType()`](./docs/Assertions/AssertPsrResponse.md) | Asserts that a response has a specified content type. |
| [`assertStatusCode()`](./docs/Assertions/AssertPsrResponse.md) | Asserts that a response has a specified status code. |
| [`assertJsonMatchesSchema()`](./docs/Assertions/AssertJsonMatchesSchema.md) | Asserts that a response contains JSON that matches the schema. |
| [`assertXmlMatchesSchema()`](./docs/Assertions/AssertXmlMatchesSchema.md) | Asserts that a response contains XML that matches the schema. |

Expand Down Expand Up @@ -298,12 +268,6 @@ Asserts that Scout Query equals Scout Query.

[Read more](<docs/Assertions/AssertScoutQueryEquals.md>).

## [`assertThatResponse` 💀](<docs/Assertions/AssertThatResponse.md>)

Asserts that PSR Response satisfies given constraint (we have a lot of built-in [constraints](src/Constraints/Response) and [responses](src/Responses), but, of course, you can create a custom).

[Read more](<docs/Assertions/AssertThatResponse.md>).

## [`assertXmlMatchesSchema`](<docs/Assertions/AssertXmlMatchesSchema.md>)

Asserts that XML matches schema [XSD](https://en.wikipedia.org/wiki/XML_Schema_(W3C)) or [Relax NG](https://en.wikipedia.org/wiki/RELAX_NG). Validation based on the standard methods of [`DOMDocument`](https://www.php.net/manual/en/class.domdocument.php) class.
Expand Down
5 changes: 1 addition & 4 deletions packages/testing/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
* [`ScheduleAssertions`][code-links/5bf3a6e818e8ec48]
* [`Override`][code-links/a5e57679c3a947a6]
* [`WithQueryLog`][code-links/e6637d2e31bd9516]
* [`💀RefreshDatabaseIfEmpty`][code-links/1e9b6004b06c7c68]
* `💀\LastDragon_ru\LaraASP\Testing\Database\RefreshDatabaseIfEmpty`
* [`WithTranslations`][code-links/733eb8fbc4b211a5]

```php
Expand Down Expand Up @@ -89,9 +89,6 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
[code-links/e6637d2e31bd9516]: src/Database/QueryLog/WithQueryLog.php
"\LastDragon_ru\LaraASP\Testing\Database\QueryLog\WithQueryLog"

[code-links/1e9b6004b06c7c68]: src/Database/RefreshDatabaseIfEmpty.php
"\LastDragon_ru\LaraASP\Testing\Database\RefreshDatabaseIfEmpty"

[code-links/733eb8fbc4b211a5]: src/Utils/WithTranslations.php
"\LastDragon_ru\LaraASP\Testing\Utils\WithTranslations"

Expand Down
4 changes: 1 addition & 3 deletions packages/testing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"psr/http-message": "^1.0.0|^2.0.0",
"sebastian/comparator": "^5.0|^6.0.0",
"sebastian/exporter": "^5.0|^6.0.0",
"symfony/deprecation-contracts": "^3.0.0",
"symfony/filesystem": "^7.0.0",
"symfony/http-foundation": "^7.0.0",
"symfony/mime": "^7.0.0",
Expand All @@ -52,8 +51,7 @@
"illuminate/http": "^11.0.8",
"laravel/scout": "^10.8.0",
"orchestra/testbench": "^9.0.0",
"symfony/console": "^7.0.0",
"symfony/http-kernel": "^7.0.0"
"symfony/console": "^7.0.0"
},
"autoload": {
"files": [
Expand Down
104 changes: 0 additions & 104 deletions packages/testing/docs/Assertions/AssertThatResponse.md

This file was deleted.

88 changes: 0 additions & 88 deletions packages/testing/docs/Assertions/AssertThatResponseTest.php

This file was deleted.

19 changes: 0 additions & 19 deletions packages/testing/src/Assertions/ResponseAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,13 @@
namespace LastDragon_ru\LaraASP\Testing\Assertions;

use LastDragon_ru\LaraASP\Testing\Constraints\Response\Response;
use LastDragon_ru\LaraASP\Testing\Package;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Constraint\Constraint;
use Psr\Http\Message\ResponseInterface;

use function trigger_deprecation;

/**
* @mixin Assert
*/
trait ResponseAssertions {
/**
* Asserts that PSR Response satisfies given constraint.
*
* @deprecated 6.0.0 Please use {@see static::assertPsrResponse()}
*/
public static function assertThatResponse(
ResponseInterface $response,
Constraint $constraint,
string $message = '',
): void {
trigger_deprecation(Package::Name, '6.0.0', 'Please use `static::assertPsrResponse()` instead.');

static::assertThat($response, $constraint, $message);
}

/**
* Asserts that PSR Response satisfies given constraint.
*/
Expand Down
46 changes: 0 additions & 46 deletions packages/testing/src/Database/RefreshDatabaseIfEmpty.php

This file was deleted.

Loading

0 comments on commit f026fc7

Please sign in to comment.