diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0ffab46 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + + name: PHP ${{ matrix.php }} + + steps: + - name: Check out repository + uses: actions/checkout@v6 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json, tokenizer, filter, mbstring + tools: composer:v2 + coverage: none + + - name: Validate Composer metadata + run: composer validate --strict + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist + + - name: Run tests + run: composer test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09eb8a4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: php -dist: trusty -php: - - 7.1 - - 7.2 - - hhvm -matrix: - allow_failures: - - php: hhvm diff --git a/composer.json b/composer.json index c8c8f15..220f584 100644 --- a/composer.json +++ b/composer.json @@ -1,30 +1,33 @@ { - "name": "vanderlee/swaggergen", - "description": "Generate Swagger/OpenAPI documentation from simple PHPdoc-like comments in PHP source code.", - "type": "library", - "keywords": ["swagger", "openapi", "doc", "documentation", "rest", "api", "documentor", "comments", "generate", "generator"], - "homepage": "https://github.com/vanderlee/PHPSwaggerGen", - "license": "MIT", - "support": { - "issues": "https://github.com/vanderlee/PHPSwaggerGen/issues", - "source": "https://github.com/vanderlee/PHPSwaggerGen/" - }, - "require": { - "php": ">=8.0", - "ext-json": "*", - "ext-tokenizer": "*", - "ext-filter": "*", - "ext-mbstring": "*" - }, - "suggest": { - "ext-yaml": "Allows producing Swagger docs in Yaml format" - }, - "autoload": { - "psr-4": { - "SwaggerGen\\": "SwaggerGen/" - } - }, - "require-dev": { - "phpunit/phpunit": "10" - } + "name": "vanderlee/swaggergen", + "description": "Generate Swagger/OpenAPI documentation from simple PHPdoc-like comments in PHP source code.", + "type": "library", + "keywords": ["swagger", "openapi", "doc", "documentation", "rest", "api", "documentor", "comments", "generate", "generator"], + "homepage": "https://github.com/vanderlee/PHPSwaggerGen", + "license": "MIT", + "support": { + "issues": "https://github.com/vanderlee/PHPSwaggerGen/issues", + "source": "https://github.com/vanderlee/PHPSwaggerGen/" + }, + "require": { + "php": ">=8.0", + "ext-json": "*", + "ext-tokenizer": "*", + "ext-filter": "*", + "ext-mbstring": "*" + }, + "suggest": { + "ext-yaml": "Allows producing Swagger docs in YAML format" + }, + "autoload": { + "psr-4": { + "SwaggerGen\\": "SwaggerGen/" + } + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^10.5 || ^11.5" + }, + "scripts": { + "test": "phpunit" + } } diff --git a/phpunit.xml b/phpunit.xml index 7fec2bd..bfc0238 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,12 +1,10 @@ - - - - - tests - - - \ No newline at end of file + + + + + tests + + + diff --git a/tests/SwaggerGenTest.php b/tests/SwaggerGenTest.php index df71b38..fd3e4d6 100644 --- a/tests/SwaggerGenTest.php +++ b/tests/SwaggerGenTest.php @@ -92,7 +92,7 @@ public function testGetSwagger_JSON_Pretty() response 202 '), array(), SwaggerGen::FORMAT_JSON_PRETTY); - $this->assertStringEqualsStringIgnoringLineEndings(<<assertSame($normalizeLineEndings($expected), $normalizeLineEndings($output)); } /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3ca9812..e13b507 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,9 @@ getSwagger($files, array(), SwaggerGen::FORMAT_JSON); - $this->assertJsonStringEqualsJsonString($expected, $this->normalizeJson($actual), $name); + $this->assertJsonStringEqualsJsonString($expected, self::normalizeJson($actual), $name); } /** @@ -26,7 +26,7 @@ public function testAllCases($name, $files, $expected) * @param string $json * @return string */ - private function normalizeJson($json) + private static function normalizeJson($json) { return json_encode( json_decode($json), @@ -34,13 +34,13 @@ private function normalizeJson($json) ); } - public function provideAllCases() + public static function provideAllCases() { $cases = array(); foreach (glob(__DIR__ . '/*', GLOB_ONLYDIR) as $dir) { $path = realpath($dir); - $json = $this->normalizeJson(file_get_contents($path . '/expected.json')); + $json = self::normalizeJson(file_get_contents($path . '/expected.json')); $files = array(); if (file_exists($path . '/source.php')) {