Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
- name: sonarcloud.io
uses: sonarsource/sonarqube-scan-action@v4.1.0
uses: sonarsource/sonarqube-scan-action@v5.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.
## Requirements

* php: ^8.2
* symfony/yaml: ^5.4.46|^6.4.14|^7.2
* symfony/yaml: ^5.4.45|^6.4.18|^7.2

## Suggest

* chubbyphp/chubbyphp-container: ^2.1
* chubbyphp/chubbyphp-container: ^2.2
* psr/container: ^1.1.2|^2.0.2

## Installation
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"ext-dom": "*",
"ext-json": "*",
"ext-mbstring": "*",
"symfony/yaml": "^5.4.46|^6.4.14|^7.2"
"symfony/yaml": "^5.4.45|^6.4.18|^7.2"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^2.2",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.3",
"chubbyphp/chubbyphp-mock": "^1.8",
"infection/infection": "^0.29.8",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.4",
"chubbyphp/chubbyphp-mock": "^2.0@dev",
"infection/infection": "^0.29.13",
"php-coveralls/php-coveralls": "^2.7.0",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.0.3",
"phpunit/phpunit": "^11.5.0",
"phpstan/phpstan": "^2.1.6",
"phpunit/phpunit": "^11.5.10",
"psr/container": "^2.0.2"
},
"autoload": {
Expand Down
33 changes: 18 additions & 15 deletions tests/Unit/Decoder/DecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
use Chubbyphp\DecodeEncode\Decoder\Decoder;
use Chubbyphp\DecodeEncode\Decoder\TypeDecoderInterface;
use Chubbyphp\DecodeEncode\LogicException;
use Chubbyphp\Mock\Call;
use Chubbyphp\Mock\MockByCallsTrait;
use PHPUnit\Framework\MockObject\MockObject;
use Chubbyphp\Mock\MockMethod\WithReturn;
use Chubbyphp\Mock\MockObjectBuilder;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -19,13 +18,13 @@
*/
final class DecoderTest extends TestCase
{
use MockByCallsTrait;

public function testGetContentTypes(): void
{
/** @var MockObject|TypeDecoderInterface */
$typeDecoder = $this->getMockByCalls(TypeDecoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
$builder = new MockObjectBuilder();

/** @var TypeDecoderInterface $typeDecoder */
$typeDecoder = $builder->create(TypeDecoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
]);

$decoder = new Decoder([$typeDecoder]);
Expand All @@ -35,10 +34,12 @@ public function testGetContentTypes(): void

public function testDecode(): void
{
/** @var MockObject|TypeDecoderInterface */
$typeDecoder = $this->getMockByCalls(TypeDecoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
Call::create('decode')->with('{"key": "value"}')->willReturn(['key' => 'value']),
$builder = new MockObjectBuilder();

/** @var TypeDecoderInterface $typeDecoder */
$typeDecoder = $builder->create(TypeDecoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
new WithReturn('decode', ['{"key": "value"}'], ['key' => 'value']),
]);

$decoder = new Decoder([$typeDecoder]);
Expand All @@ -51,9 +52,11 @@ public function testDecodeWithMissingType(): void
$this->expectException(LogicException::class);
$this->expectExceptionMessage('There is no decoder/encoder for content-type: "application/xml"');

/** @var MockObject|TypeDecoderInterface */
$typeDecoder = $this->getMockByCalls(TypeDecoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
$builder = new MockObjectBuilder();

/** @var TypeDecoderInterface $typeDecoder */
$typeDecoder = $builder->create(TypeDecoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
]);

$decoder = new Decoder([$typeDecoder]);
Expand Down
33 changes: 18 additions & 15 deletions tests/Unit/Encoder/EncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
use Chubbyphp\DecodeEncode\Encoder\Encoder;
use Chubbyphp\DecodeEncode\Encoder\TypeEncoderInterface;
use Chubbyphp\DecodeEncode\LogicException;
use Chubbyphp\Mock\Call;
use Chubbyphp\Mock\MockByCallsTrait;
use PHPUnit\Framework\MockObject\MockObject;
use Chubbyphp\Mock\MockMethod\WithReturn;
use Chubbyphp\Mock\MockObjectBuilder;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -19,13 +18,13 @@
*/
final class EncoderTest extends TestCase
{
use MockByCallsTrait;

public function testGetContentTypes(): void
{
/** @var MockObject|TypeEncoderInterface $typeEncoder */
$typeEncoder = $this->getMockByCalls(TypeEncoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
$builder = new MockObjectBuilder();

/** @var TypeEncoderInterface $typeEncoder */
$typeEncoder = $builder->create(TypeEncoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
]);

$encoder = new Encoder([$typeEncoder]);
Expand All @@ -35,10 +34,12 @@ public function testGetContentTypes(): void

public function testEncode(): void
{
/** @var MockObject|TypeEncoderInterface $typeEncoder */
$typeEncoder = $this->getMockByCalls(TypeEncoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
Call::create('encode')->with(['key' => 'value'])->willReturn('{"key":"value"}'),
$builder = new MockObjectBuilder();

/** @var TypeEncoderInterface $typeEncoder */
$typeEncoder = $builder->create(TypeEncoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
new WithReturn('encode', [['key' => 'value']], '{"key":"value"}'),
]);

$encoder = new Encoder([$typeEncoder]);
Expand All @@ -51,9 +52,11 @@ public function testEncodeWithMissingType(): void
$this->expectException(LogicException::class);
$this->expectExceptionMessage('There is no decoder/encoder for content-type: "application/xml"');

/** @var MockObject|TypeEncoderInterface $typeEncoder */
$typeEncoder = $this->getMockByCalls(TypeEncoderInterface::class, [
Call::create('getContentType')->with()->willReturn('application/json'),
$builder = new MockObjectBuilder();

/** @var TypeEncoderInterface $typeEncoder */
$typeEncoder = $builder->create(TypeEncoderInterface::class, [
new WithReturn('getContentType', [], 'application/json'),
]);

$encoder = new Encoder([$typeEncoder]);
Expand Down
18 changes: 10 additions & 8 deletions tests/Unit/ServiceFactory/DecoderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Chubbyphp\DecodeEncode\Decoder\DecoderInterface;
use Chubbyphp\DecodeEncode\Decoder\TypeDecoderInterface;
use Chubbyphp\DecodeEncode\ServiceFactory\DecoderFactory;
use Chubbyphp\Mock\Call;
use Chubbyphp\Mock\MockByCallsTrait;
use Chubbyphp\Mock\MockMethod\WithReturn;
use Chubbyphp\Mock\MockObjectBuilder;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;

Expand All @@ -19,13 +19,13 @@
*/
final class DecoderFactoryTest extends TestCase
{
use MockByCallsTrait;

public function testInvoke(): void
{
$builder = new MockObjectBuilder();

/** @var ContainerInterface $container */
$container = $this->getMockByCalls(ContainerInterface::class, [
Call::create('get')->with(TypeDecoderInterface::class.'[]')->willReturn([]),
$container = $builder->create(ContainerInterface::class, [
new WithReturn('get', [TypeDecoderInterface::class.'[]'], []),
]);

$factory = new DecoderFactory();
Expand All @@ -37,9 +37,11 @@ public function testInvoke(): void

public function testCallStatic(): void
{
$builder = new MockObjectBuilder();

/** @var ContainerInterface $container */
$container = $this->getMockByCalls(ContainerInterface::class, [
Call::create('get')->with(TypeDecoderInterface::class.'[]default')->willReturn([]),
$container = $builder->create(ContainerInterface::class, [
new WithReturn('get', [TypeDecoderInterface::class.'[]default'], []),
]);

$factory = [DecoderFactory::class, 'default'];
Expand Down
18 changes: 10 additions & 8 deletions tests/Unit/ServiceFactory/EncoderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Chubbyphp\DecodeEncode\Encoder\EncoderInterface;
use Chubbyphp\DecodeEncode\Encoder\TypeEncoderInterface;
use Chubbyphp\DecodeEncode\ServiceFactory\EncoderFactory;
use Chubbyphp\Mock\Call;
use Chubbyphp\Mock\MockByCallsTrait;
use Chubbyphp\Mock\MockMethod\WithReturn;
use Chubbyphp\Mock\MockObjectBuilder;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;

Expand All @@ -19,13 +19,13 @@
*/
final class EncoderFactoryTest extends TestCase
{
use MockByCallsTrait;

public function testInvoke(): void
{
$builder = new MockObjectBuilder();

/** @var ContainerInterface $container */
$container = $this->getMockByCalls(ContainerInterface::class, [
Call::create('get')->with(TypeEncoderInterface::class.'[]')->willReturn([]),
$container = $builder->create(ContainerInterface::class, [
new WithReturn('get', [TypeEncoderInterface::class.'[]'], []),
]);

$factory = new EncoderFactory();
Expand All @@ -37,9 +37,11 @@ public function testInvoke(): void

public function testCallStatic(): void
{
$builder = new MockObjectBuilder();

/** @var ContainerInterface $container */
$container = $this->getMockByCalls(ContainerInterface::class, [
Call::create('get')->with(TypeEncoderInterface::class.'[]default')->willReturn([]),
$container = $builder->create(ContainerInterface::class, [
new WithReturn('get', [TypeEncoderInterface::class.'[]default'], []),
]);

$factory = [EncoderFactory::class, 'default'];
Expand Down