Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') }}
Expand All @@ -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 }}
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v4/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="dot-annotated-services Test Suite">
<directory>./test</directory>
Expand Down
15 changes: 8 additions & 7 deletions test/AnnotatedRepositoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,19 +23,20 @@

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
*/
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']);
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down
28 changes: 14 additions & 14 deletions test/AnnotatedServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
Expand Down Expand Up @@ -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([]);
Expand All @@ -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);
Expand Down Expand Up @@ -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([]);
Expand Down
Loading