Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update phpunit to version 10 #84

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"php-open-source-saver/jwt-auth": "^2.2",
"psr/simple-cache": "^3.0",
"ronasit/laravel-helpers": "dev-master",
"ronasit/laravel-swagger": "^2.2",
"ronasit/laravel-swagger": "dev-master",
"spatie/laravel-google-cloud-storage": "^2.3",
"spatie/laravel-ignition": "^2.4",
"symfony/http-client": "6.4.5",
Expand All @@ -36,7 +36,7 @@
"friendsofphp/php-cs-fixer": "^3.8",
"mockery/mockery": "^1.6",
"php-coveralls/php-coveralls": "^2.7",
"phpunit/phpunit": "^9.6.17",
"phpunit/phpunit": "^10.5",
"ronasit/laravel-entity-generator": ">=2.0.4-beta",
"tightenco/tlint": "^9.3"
},
Expand Down
624 changes: 255 additions & 369 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
|--------------------------------------------------------------------------
*/

'disabled_api_versions' => explode(',', env('DISABLED_API_VERSIONS')),
'disabled_api_versions' => explode(',', env('DISABLED_API_VERSIONS', '')),

/*
|--------------------------------------------------------------------------
Expand Down
19 changes: 16 additions & 3 deletions config/auto-doc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
| Route which will return documentation
*/
'route' => '/',
'route' => '',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -73,9 +73,22 @@
|--------------------------------------------------------------------------
|
| Library name, which used to secure the project.
| Available values: "jwt", "laravel", "null"
| Should have one of the key from the `security_drivers` config
*/
'security' => '',
'security_drivers' => [
'jwt' => [
'type' => 'apiKey',
'name' => 'Authorization',
'in' => 'header'
],
'laravel' => [
'type' => 'apiKey',
'name' => '__ym_uid',
'in' => 'cookie',
],
],

'defaults' => [

/*
Expand Down Expand Up @@ -171,5 +184,5 @@
'development',
],

'config_version' => '2.6',
'config_version' => '2.7',
];
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:

nginx:
Expand Down
15 changes: 8 additions & 7 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="bootstrap/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="bootstrap/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<extensions>
<extension class="RonasIT\Support\AutoDoc\Tests\PhpUnitExtensions\SwaggerExtension"/>
<bootstrap class="RonasIT\Support\AutoDoc\Tests\PhpUnitExtensions\SwaggerExtension">
</bootstrap>
</extensions>
<testsuites>
<testsuite name="Tests">
Expand All @@ -19,4 +15,9 @@
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
</php>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
</phpunit>
42 changes: 36 additions & 6 deletions tests/InitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ public function testRunWithoutAdminAndReadmeCreation()
public function testRunWithAdminAndWithoutReadmeCreation()
{
$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')]
[
'database/migrations/2018_11_11_111111_add_default_user.php',
$this->getFixture('migration.php'),
'optionalParameter',
'optionalParameter',
]
);

$this
Expand All @@ -44,8 +49,18 @@ public function testRunWithAdminAndDefaultReadmeCreation()
$this->mockShellExec();

$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')],
['README.md', $this->getFixture('default_readme.md')]
[
'database/migrations/2018_11_11_111111_add_default_user.php',
$this->getFixture('migration.php'),
'optionalParameter',
'optionalParameter',
],
[
'README.md',
$this->getFixture('default_readme.md'),
'optionalParameter',
'optionalParameter',
]
);

$this
Expand Down Expand Up @@ -117,7 +132,12 @@ public function testRunWithAdminAndDefaultReadmeCreation()
public function testRunWithAdminAndPartialReadmeCreation()
{
$this->mockFilePutContent(
['README.md', $this->getFixture('partial_readme.md')]
[
'README.md',
$this->getFixture('partial_readme.md'),
'optionalParameter',
'optionalParameter',
]
);

$this
Expand Down Expand Up @@ -181,8 +201,18 @@ public function testRunWithAdminAndFullReadmeCreation()
$this->mockShellExec();

$this->mockFilePutContent(
['database/migrations/2018_11_11_111111_add_default_user.php', $this->getFixture('migration.php')],
['README.md', $this->getFixture('full_readme.md')]
[
'database/migrations/2018_11_11_111111_add_default_user.php',
$this->getFixture('migration.php'),
'optionalParameter',
'optionalParameter',
],
[
'README.md',
$this->getFixture('full_readme.md'),
'optionalParameter',
'optionalParameter',
]
);

$this
Expand Down
18 changes: 7 additions & 11 deletions tests/RoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,39 @@
namespace App\Tests;

use App\Services\RoleService;
use PHPUnit\Framework\Attributes\DataProvider;

class RoleTest extends TestCase
{
public function getSearchFilters(): array
public static function getSearchFilters(): array
{
return [
[
'filter' => ['all' => 1],
'result' => 'search_by_all.json',
'fixture' => 'search_by_all.json',
],
[
'filter' => [
'page' => 2,
'per_page' => 1,
],
'result' => 'search_by_page_per.json',
'fixture' => 'search_by_page_per.json',
],
[
'filter' => ['query' => 'us'],
'result' => 'get_roles_by_name.json',
'fixture' => 'get_roles_by_name.json',
],
[
'filter' => [
'desc' => true,
'order_by' => 'name',
],
'result' => 'get_roles_check_order.json',
'fixture' => 'get_roles_check_order.json',
],
];
}

/**
* @dataProvider getSearchFilters
*
* @param array $filter
* @param string $fixture
*/
#[DataProvider('getSearchFilters')]
public function testSearch($filter, $fixture)
{
$results = app(RoleService::class)->search($filter);
Expand Down
31 changes: 11 additions & 20 deletions tests/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use App\Services\SettingService;
use PHPUnit\Framework\Attributes\DataProvider;

class SettingTest extends TestCase
{
Expand Down Expand Up @@ -104,34 +105,34 @@ public function testGetNotExists()
$response->assertNotFound();
}

public function getSearchFilters()
public static function getSearchFilters(): array
{
return [
[
'filter' => ['query' => 'states'],
'result' => 'get_setting_by_key.json',
'fixture' => 'get_setting_by_key.json',
],
[
'filter' => [
'order_by' => 'name',
'desc' => false,
],
'result' => 'get_settings_check_order.json',
'fixture' => 'get_settings_check_order.json',
],
[
'filters' => [
'filter' => [
'per_page' => 2,
],
'fixture' => 'search_per_page.json',
],
[
'filters' => [
'filter' => [
'all' => 1,
],
'fixture' => 'search_all.json',
],
[
'filters' => [
'filter' => [
'per_page' => 1,
'query' => 'states',
],
Expand All @@ -140,12 +141,7 @@ public function getSearchFilters()
];
}

/**
* @dataProvider getSearchFilters
*
* @param array $filter
* @param string $fixture
*/
#[DataProvider('getSearchFilters')]
public function testSearch($filter, $fixture)
{
$response = $this->actingAs($this->admin)->json('get', '/settings', $filter);
Expand All @@ -155,22 +151,17 @@ public function testSearch($filter, $fixture)
$this->assertEqualsFixture($fixture, $response->json());
}

public function getUserSearchFilters()
public static function getUserSearchFilters(): array
{
return [
[
'filter' => [],
'result' => 'get_public_settings.json',
'fixture' => 'get_public_settings.json',
],
];
}

/**
* @dataProvider getUserSearchFilters
*
* @param array $filter
* @param string $fixture
*/
#[DataProvider('getUserSearchFilters')]
public function testSearchByUser($filter, $fixture)
{
$response = $this->actingAs($this->user)->json('get', '/settings', $filter);
Expand Down
4 changes: 2 additions & 2 deletions tests/Support/InitCommandMockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ trait InitCommandMockTrait
public function mockFilePutContent(...$arguments): void
{
$callChain = [
['.env.example', $this->getFixture('env.example.yml')],
['.env.development', $this->getFixture('env.development.yml')],
['.env.example', $this->getFixture('env.example.yml'), 'optionalParameter', 'optionalParameter'],
['.env.development', $this->getFixture('env.development.yml'), 'optionalParameter', 'optionalParameter'],
...$arguments,
];

Expand Down
24 changes: 10 additions & 14 deletions tests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;

class UserTest extends TestCase
{
Expand Down Expand Up @@ -264,31 +265,31 @@ public function testGetNotExists()
$response->assertNotFound();
}

public function getSearchFilters()
public static function getSearchFilters(): array
{
return [
[
'filter' => ['all' => 1],
'result' => 'search_by_all_user.json',
'fixture' => 'search_by_all_user.json',
],
[
'filter' => [
'page' => 1,
'per_page' => 2,
],
'result' => 'search_by_page_per_page_user.json',
'fixture' => 'search_by_page_per_page_user.json',
],
[
'filter' => ['query' => 'Another User'],
'result' => 'get_users_by_name.json',
'fixture' => 'get_users_by_name.json',
],
[
'filter' => ['query' => 'admin@example.com'],
'result' => 'get_users_by_email.json',
'fixture' => 'get_users_by_email.json',
],
[
'filter' => ['query' => 'Admin'],
'result' => 'get_users_by_query.json',
'fixture' => 'get_users_by_query.json',
],
[
'filter' => [
Expand All @@ -297,24 +298,19 @@ public function getSearchFilters()
'order_by' => 'created_at',
'desc' => false,
],
'result' => 'get_users_complex.json',
'fixture' => 'get_users_complex.json',
],
[
'filter' => [
'desc' => false,
'order_by' => 'name',
],
'result' => 'get_users_check_order.json',
'fixture' => 'get_users_check_order.json',
],
];
}

/**
* @dataProvider getSearchFilters
*
* @param array $filter
* @param string $fixture
*/
#[DataProvider('getSearchFilters')]
public function testSearch($filter, $fixture)
{
$response = $this->actingAs($this->admin)->json('get', '/users', $filter);
Expand Down
Loading