Skip to content

Commit

Permalink
Merge aa21904 into 7187aa0
Browse files Browse the repository at this point in the history
  • Loading branch information
vitgrams committed Mar 5, 2023
2 parents 7187aa0 + aa21904 commit 27f979f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests-with-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: '8.1'
- uses: actions/checkout@v3
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ bootstrap/cache/
composer.lock

.phpunit.result.cache
.phpunit.cache
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM webdevops/php-nginx-dev:7.3
FROM webdevops/php-nginx-dev:8.1

RUN wget -O "/usr/local/bin/go-replace" "https://github.com/webdevops/goreplace/releases/download/1.1.2/gr-arm64-linux" \
RUN wget -O "/usr/local/bin/go-replace" "https://github.com/webdevops/go-replace/releases/download/22.9.0/go-replace.linux.arm64" \
&& chmod +x "/usr/local/bin/go-replace" \
&& "/usr/local/bin/go-replace" --version
&& "/usr/local/bin/go-replace" --version
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
}
],
"require": {
"php": ">=7.3.0",
"laravel/framework": ">=5.3.0",
"phpunit/phpunit": ">=7.0|<=10.0"
"php": "^8.1",
"laravel/framework": "^10.2",
"phpunit/phpunit": "^10.0"
},
"require-dev": {
"orchestra/testbench": "^6.25",
"orchestra/testbench": "^8.0",
"php-coveralls/php-coveralls": "^2.5"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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">
<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.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
Expand Down
19 changes: 0 additions & 19 deletions src/Commands/PushDocumentationCommand.php

This file was deleted.

29 changes: 29 additions & 0 deletions src/Tests/PhpUnitEventSubscribers/SwaggerSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace RonasIT\Support\AutoDoc\Tests\PhpUnitEventSubscribers;

use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use PHPUnit\Event;
use PHPUnit\Event\Test\AfterLastTestMethodFinished;
use RonasIT\Support\AutoDoc\Services\SwaggerService;

final class SwaggerSubscriber implements Event\Test\AfterLastTestMethodFinishedSubscriber
{
public function notify(AfterLastTestMethodFinished $event): void
{
$this->createApplication();

app(SwaggerService::class)->saveProductionData();
}

protected function createApplication(): Application
{
$app = require_once base_path('bootstrap/app.php');

$app->loadEnvironmentFrom('.env.testing');
$app->make(Kernel::class)->bootstrap();

return $app;
}
}
34 changes: 8 additions & 26 deletions src/Tests/PhpUnitExtensions/SwaggerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,16 @@

namespace RonasIT\Support\AutoDoc\Tests\PhpUnitExtensions;

use PHPUnit\Runner\AfterLastTestHook;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Console\Kernel;
use RonasIT\Support\AutoDoc\Services\SwaggerService;
use PHPUnit\Runner\Extension\Extension as PhpunitExtension;
use PHPUnit\Runner\Extension\Facade as EventFacade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;
use RonasIT\Support\AutoDoc\Tests\PhpUnitEventSubscribers\SwaggerSubscriber;

/**
* This interface, as well as the associated mechanism for extending PHPUnit,
* will be removed in PHPUnit 10. There is no alternative available in this
* version of PHPUnit.
*
* @see https://github.com/sebastianbergmann/phpunit/issues/4676
*/
class SwaggerExtension implements AfterLastTestHook
final class SwaggerExtension implements PhpunitExtension
{
public function executeAfterLastTest(): void
public function bootstrap(Configuration $configuration, EventFacade $facade, ParameterCollection $parameters): void
{
$this->createApplication();

app(SwaggerService::class)->saveProductionData();
}

protected function createApplication(): Application
{
$app = require __DIR__ . '/../../../../../../bootstrap/app.php';

$app->loadEnvironmentFrom('.env.testing');
$app->make(Kernel::class)->bootstrap();

return $app;
$facade->registerSubscriber(new SwaggerSubscriber());
}
}
17 changes: 0 additions & 17 deletions tests/PushDocumentationCommandTest.php

This file was deleted.

15 changes: 5 additions & 10 deletions tests/SwaggerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace RonasIT\Support\Tests;

use Illuminate\Http\Testing\File;
use PHPUnit\Framework\Attributes\DataProvider;
use RonasIT\Support\AutoDoc\Exceptions\InvalidDriverClassException;
use RonasIT\Support\AutoDoc\Exceptions\LegacyConfigException;
use RonasIT\Support\AutoDoc\Exceptions\SwaggerDriverClassNotFoundException;
use RonasIT\Support\AutoDoc\Exceptions\WrongSecurityConfigException;
use RonasIT\Support\AutoDoc\Services\SwaggerService;
use RonasIT\Support\Tests\Support\Mock\TestNotificationSetting;
use RonasIT\Support\Tests\Support\Traits\SwaggerServiceMockTrait;
use Symfony\Component\HttpFoundation\Response;
use stdClass;

class SwaggerServiceTest extends TestCase
{
Expand Down Expand Up @@ -45,14 +46,14 @@ public function testConstructorDriverClassNotExists()

public function testConstructorDriverClassNotImplementsInterface()
{
config(['auto-doc.drivers.local.class' => TestCase::class]);
config(['auto-doc.drivers.local.class' => stdClass::class]);

$this->expectException(InvalidDriverClassException::class);

app(SwaggerService::class);
}

public function getAddData(): array
public static function getAddData(): array
{
return [
[
Expand Down Expand Up @@ -83,13 +84,7 @@ public function getAddData(): array
];
}

/**
* @dataProvider getAddData
*
* @param ?string $contentType
* @param string $requestFixture
* @param string $responseFixture
*/
#[DataProvider('getAddData')]
public function testAddData(?string $contentType, string $requestFixture, string $responseFixture)
{
$this->mockDriverGetEmptyAndSaveTpmData($this->getJsonFixture($requestFixture));
Expand Down
17 changes: 0 additions & 17 deletions tests/fixtures/PushDocumentationCommandTest/documentation.json

This file was deleted.

0 comments on commit 27f979f

Please sign in to comment.