Skip to content

Commit

Permalink
Check tests with PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 17, 2023
1 parent 936faba commit 1f0af95
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
# SPDX-License-Identifier: GPL-3.0-or-later

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 8

paths:
- src/
- tests/

scanDirectories:
- vendor
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.35",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9 || ^10"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Art4\JsonApiClient\Tests\Fixtures;

use Art4\JsonApiClient\Utils\FactoryInterface;
use Art4\JsonApiClient\Factory as FactoryInterface;

final class Factory implements FactoryInterface
{
Expand Down
20 changes: 12 additions & 8 deletions tests/Fixtures/HelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@
use Art4\JsonApiClient\Factory;
use Art4\JsonApiClient\Manager;
use Art4\JsonApiClient\Tests\Fixtures\Factory as FixtureFactory;
use PHPUnit\Framework\MockObject\MockObject;

/**
* Helper Trait
*/
trait HelperTrait
{
/** @var Manager&MockObject */
protected Manager $manager;

/** @var Factory&MockObject */
protected Factory $factory;

/** @var Accessable&MockObject */
protected Accessable $parent;

/**
* Json Values Provider
*
* @see http://json.org/
* @return array<array<mixed>>
*/
public static function jsonValuesProvider(): array
{
Expand All @@ -47,7 +51,7 @@ public static function jsonValuesProvider(): array
/**
* Json Values Provider but without the object
*
* @see http://json.org/
* @return array<array<mixed>>
*/
public static function jsonValuesProviderWithoutObject(): array
{
Expand All @@ -61,7 +65,7 @@ public static function jsonValuesProviderWithoutObject(): array
/**
* Json Values Provider but without the array
*
* @see http://json.org/
* @return array<array<mixed>>
*/
public static function jsonValuesProviderWithoutArray(): array
{
Expand All @@ -75,7 +79,7 @@ public static function jsonValuesProviderWithoutArray(): array
/**
* Json Values Provider but without the string
*
* @see http://json.org/
* @return array<array<mixed>>
*/
public static function jsonValuesProviderWithoutString(): array
{
Expand All @@ -89,7 +93,7 @@ public static function jsonValuesProviderWithoutString(): array
/**
* Json Values Provider but without the object and string
*
* @see http://json.org/
* @return array<array<mixed>>
*/
public static function jsonValuesProviderWithoutObjectAndString(): array
{
Expand All @@ -104,7 +108,7 @@ public static function jsonValuesProviderWithoutObjectAndString(): array
/**
* Json Values as string Provider
*
* @see http://json.org/
* @return array<array<string>>
*/
public static function jsonValuesAsStringProvider(): array
{
Expand All @@ -124,7 +128,7 @@ public static function jsonValuesAsStringProvider(): array
/**
* Json Values as string Provider but without the object
*
* @see http://json.org/
* @return array<array<string>>
*/
public static function jsonValuesAsStringProviderWithoutObject(): array
{
Expand All @@ -145,7 +149,7 @@ public function buildManagerMock()
$factory->testcase = $this;

// Mock Manager
$manager = $this->createMock('Art4\JsonApiClient\Utils\FactoryManagerInterface');
$manager = $this->createMock(Manager::class);

$manager->expects($this->any())
->method('getFactory')
Expand Down

0 comments on commit 1f0af95

Please sign in to comment.