Skip to content

Commit

Permalink
Only support latest stable Laravel version (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary authored Sep 28, 2021
1 parent 163c9df commit f70f51e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ assertValidationRuleContains($rule, string $class)

Verifies the rule or rules contains an instance of the given [Rule](https://laravel.com/docs/validation#custom-validation-rules) class.

```php
assertNotSoftDeleted(Model $model)
```

Verifies the given model is not _soft deleted_, providing the inverse of [assertSoftDeleted](https://laravel.com/docs/database-testing#available-assertions).

## Matchers
```php
LaravelMatchers::isModel(Model $model = null)
Expand Down Expand Up @@ -111,3 +105,8 @@ createFormRequest(string $class, array $data = [])
```

Creates an instance of the given [Form Request](https://laravel.com/docs/7.x/validation#form-request-validation) class with the given request data.

## Support Policy
Starting with version 2, this package will only support the latest stable version of Laravel (currently Laravel 8). If you need to support older versions of Laravel, you may use version 1 or upgrade your application ([try using Shift](https://laravelshift.com)).

This package still follows [semantic versioning](https://semver.org/). However, it does so with respect to its own code. Any breaking changes will increase its major version number. Otherwise, minor version number increases will contain new features. This includes changes for future versions of Laravel.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
}
],
"require": {
"php": ">=7.2",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.5|^8.0|^9.0"
"php": ">=7.3",
"illuminate/testing": "^8.0",
"mockery/mockery": "^1.4.2",
"phpunit/phpunit": "^9.3.3"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 2 additions & 6 deletions src/AdditionalAssertionsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ class AdditionalAssertionsServiceProvider extends ServiceProvider
{
public function register()
{
$test_response_class = class_exists(\Illuminate\Testing\TestResponse::class)
? \Illuminate\Testing\TestResponse::class
: \Illuminate\Foundation\Testing\TestResponse::class;

if (!$test_response_class::hasMacro('assertJsonTypedStructure')) {
$test_response_class::macro('assertJsonTypedStructure', function (array $structure) {
if (!\Illuminate\Testing\TestResponse::hasMacro('assertJsonTypedStructure')) {
\Illuminate\Testing\TestResponse::macro('assertJsonTypedStructure', function (array $structure) {
AdditionalAssertions::assertArrayStructure($structure, $this->json());

return $this;
Expand Down
16 changes: 2 additions & 14 deletions src/Traits/AdditionalAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace JMac\Testing\Traits;

use Illuminate\Support\Facades\Route;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Route;
use PHPUnit\Framework\Assert as PHPUnitAssert;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;

Expand Down Expand Up @@ -113,11 +113,7 @@ public function createFormRequest(string $form_request, array $data = [])

public function assertValidationRules(array $expected, array $actual)
{
if (class_exists(\Illuminate\Testing\Assert::class)) {
\Illuminate\Testing\Assert::assertArraySubset($this->normalizeRules($expected), $this->normalizeRules($actual));
} else {
\Illuminate\Foundation\Testing\Assert::assertArraySubset($this->normalizeRules($expected), $this->normalizeRules($actual));
}
\Illuminate\Testing\Assert::assertArraySubset($this->normalizeRules($expected), $this->normalizeRules($actual));
}

public function assertExactValidationRules(array $expected, array $actual)
Expand Down Expand Up @@ -179,14 +175,6 @@ public static function assertArrayStructure(array $structure, array $actual)
}
}

public function assertNotSoftDeleted(Model $model)
{
return $this->assertDatabaseHas($model->getTable(), [
$model->getKeyName() => $model->getKey(),
'deleted_at' => null,
]);
}

private function normalizeRules(array $rules)
{
return array_map([$this, 'expandRules'], $rules);
Expand Down

0 comments on commit f70f51e

Please sign in to comment.