diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index c0fbc53..9652006 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,14 +15,14 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -36,7 +36,7 @@ jobs: run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - name: Cache dependencies installed with composer - uses: actions/cache@v3 + uses: actions/cache@v6 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} @@ -50,6 +50,6 @@ jobs: run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml - name: Send code coverage report to Codecov.io - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9976515..2763b9c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,14 +15,14 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -36,7 +36,7 @@ jobs: run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - name: Cache dependencies installed with composer - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/README.md b/README.md index 04b81e2..05f701e 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Documentation is available at: https://docs.dotkernel.org/dot-annotated-services [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/blob/4.0/LICENSE.md) -[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services) -[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml) ## Installation diff --git a/composer.json b/composer.json index 1f70e67..cd041f8 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "service-manager" ], "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "doctrine/annotations": "^1.14.3", "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/orm" : "^2.20", @@ -30,7 +30,7 @@ "laminas/laminas-coding-standard": "^3.0", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^10.5.9" + "phpunit/phpunit": "^12.5.22" }, "autoload": { "psr-4": { diff --git a/docs/book/v4/overview.md b/docs/book/v4/overview.md index 42302bd..0250d43 100644 --- a/docs/book/v4/overview.md +++ b/docs/book/v4/overview.md @@ -22,6 +22,6 @@ By providing reusable factories for service and repository injection, it reduces [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/blob/4.0/LICENSE.md) -[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services) -[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml) diff --git a/phpunit.xml b/phpunit.xml index 65d03b8..f1c9d27 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + ./test diff --git a/test/AnnotatedRepositoryFactoryTest.php b/test/AnnotatedRepositoryFactoryTest.php index 0b498c1..d6ad9bc 100644 --- a/test/AnnotatedRepositoryFactoryTest.php +++ b/test/AnnotatedRepositoryFactoryTest.php @@ -11,8 +11,10 @@ use Dot\AnnotatedServices\Exception\RuntimeException; use Dot\AnnotatedServices\Factory\AnnotatedRepositoryFactory as Subject; //use DotTest\AnnotatedServices\TestClass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -21,11 +23,12 @@ use function get_class; +#[AllowMockObjectsWithoutExpectations] class AnnotatedRepositoryFactoryTest extends TestCase { private MockObject&ContainerInterface $container; private MockObject&Subject $subject; - private MockObject&Reader $annotationReader; + private Stub&Reader $annotationReader; /** * @throws Exception @@ -33,7 +36,7 @@ class AnnotatedRepositoryFactoryTest extends TestCase public function setUp(): void { $this->container = $this->createMock(ContainerInterface::class); - $this->annotationReader = $this->createMock(Reader::class); + $this->annotationReader = $this->createStub(Reader::class); $this->subject = $this->createPartialMock(Subject::class, ['createAnnotationReader']); } @@ -60,8 +63,6 @@ public function testThrowsExceptionClassNotExtendsEntityRepository() { $requestedName = TestClass::class; - $this->getMockBuilder($requestedName)->getMock(); - $this->expectException(RuntimeException::class); $this->expectExceptionMessage(RuntimeException::doesNotExtend(EntityRepository::class)->getMessage()); $this->subject->__invoke($this->container, $requestedName); @@ -75,7 +76,7 @@ public function testThrowsExceptionClassNotExtendsEntityRepository() */ public function testCreateObjectThrowsExceptionAnnotationNotFound() { - $repository = $this->createMock(EntityRepository::class); + $repository = $this->createStub(EntityRepository::class); $this->annotationReader->method('getClassAnnotation')->willReturn(null); $this->subject->method('createAnnotationReader')->willReturn($this->annotationReader); @@ -98,9 +99,9 @@ public function testCreateObjectThrowsExceptionAnnotationNotFound() */ public function testCreateObjectReturnsEntityRepository() { - $repository = $this->createMock(EntityRepository::class); + $repository = $this->createStub(EntityRepository::class); $annotation = new Entity('test'); - $entityManager = $this->createMock(EntityManagerInterface::class); + $entityManager = $this->createStub(EntityManagerInterface::class); $entityManager->method('getRepository')->willReturn($repository); diff --git a/test/AnnotatedServiceFactoryTest.php b/test/AnnotatedServiceFactoryTest.php index 8f56ec4..f97ae67 100644 --- a/test/AnnotatedServiceFactoryTest.php +++ b/test/AnnotatedServiceFactoryTest.php @@ -8,8 +8,10 @@ use Dot\AnnotatedServices\Annotation\Inject; use Dot\AnnotatedServices\Exception\RuntimeException; use Dot\AnnotatedServices\Factory\AnnotatedServiceFactory as Subject; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -20,19 +22,20 @@ use function get_class; +#[AllowMockObjectsWithoutExpectations] class AnnotatedServiceFactoryTest extends TestCase { - private MockObject&ContainerInterface $container; + private Stub&ContainerInterface $container; private MockObject&Subject $subject; - private MockObject&Reader $annotationReader; + private Stub&Reader $annotationReader; /** * @throws Exception */ public function setUp(): void { - $this->container = $this->createMock(ContainerInterface::class); - $this->annotationReader = $this->createMock(Reader::class); + $this->container = $this->createStub(ContainerInterface::class); + $this->annotationReader = $this->createStub(Reader::class); $this->subject = $this->createPartialMock(Subject::class, [ 'createAnnotationReader', 'getReflectionClass', @@ -63,8 +66,7 @@ public function testThrowsExceptionClassNotFound() public function testReturnServiceWithNoDependencies() { $requestedName = TestClass::class; - $this->getMockBuilder($requestedName)->allowMockingUnknownTypes()->getMock(); - $refClass = $this->createMock(ReflectionClass::class); + $refClass = $this->createStub(ReflectionClass::class); $refClass->method('getConstructor')->willReturn(null); $refClass->method('getMethods')->willReturn([]); @@ -88,10 +90,9 @@ public function testReturnServiceWithNoDependencies() */ public function testThrowsExceptionAnnotationNotFound() { - $requestedName = TestClass::class; - $this->getMockBuilder($requestedName)->allowMockingUnknownTypes()->getMock(); - $refClass = $this->createMock(ReflectionClass::class); - $refConstructor = $this->createMock(ReflectionMethod::class); + $requestedName = TestClass::class; + $refClass = $this->createStub(ReflectionClass::class); + $refConstructor = $this->createStub(ReflectionMethod::class); $refClass->method('getConstructor')->willReturn($refConstructor); $refConstructor->method('getNumberOfRequiredParameters')->willReturn(100); @@ -120,10 +121,9 @@ public function testThrowsExceptionAnnotationNotFound() */ public function testReturnService() { - $requestedName = TestClass::class; - $this->getMockBuilder($requestedName)->allowMockingUnknownTypes()->getMock(); - $refClass = $this->createMock(ReflectionClass::class); - $refConstructor = $this->createMock(ReflectionMethod::class); + $requestedName = TestClass::class; + $refClass = $this->createStub(ReflectionClass::class); + $refConstructor = $this->createStub(ReflectionMethod::class); $refClass->method('getConstructor')->willReturn($refConstructor); $refClass->method('getMethods')->willReturn([]);