Skip to content

Commit afe63aa

Browse files
committedDec 13, 2024··
Add support for v1.3.0
1 parent ba75002 commit afe63aa

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed
 

‎composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"minimum-stability": "stable",
88
"require": {
99
"php": ">=8.2",
10-
"yceruto/decorator": "1.2.*",
10+
"yceruto/decorator": "^1.3",
1111
"symfony/framework-bundle": "^6.4|^7.0"
1212
},
1313
"require-dev": {

‎src/Decorator/Serializer/Serialize.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use Yceruto\Decorator\Attribute\DecoratorAttribute;
1717

18-
#[\Attribute(\Attribute::TARGET_METHOD)]
18+
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
1919
final class Serialize extends DecoratorAttribute
2020
{
2121
public function __construct(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Decorator Bundle package.
7+
*
8+
* (c) Yonel Ceruto <open@yceruto.dev>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Yceruto\DecoratorBundle\Tests\Integration\App\DecorateController\Controller;
15+
16+
use Symfony\Component\Routing\Attribute\Route;
17+
use Yceruto\DecoratorBundle\Decorator\Serializer\Serialize;
18+
19+
#[Serialize]
20+
#[Route('/serialize-decorator/invokable')]
21+
class InvokableControllerWithSerializeDecorator
22+
{
23+
public function __invoke(): array
24+
{
25+
return ['success' => true];
26+
}
27+
}

‎tests/Integration/DecorateControllerTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ public function testSerializerDecoratorDefaultOptions(): void
3939
self::assertSame('{"success":true}', $client->getInternalResponse()->getContent());
4040
}
4141

42+
public function testSerializerDecoratorInInvokable(): void
43+
{
44+
$client = self::createClient();
45+
$client->request('GET', '/serialize-decorator/invokable');
46+
47+
self::assertResponseIsSuccessful();
48+
self::assertResponseFormatSame('json');
49+
self::assertResponseStatusCodeSame(200);
50+
self::assertResponseHeaderSame('Content-Type', 'application/json');
51+
self::assertSame('{"success":true}', $client->getInternalResponse()->getContent());
52+
}
53+
4254
public function testSerializerDecoratorEmptyResult(): void
4355
{
4456
$client = self::createClient();

0 commit comments

Comments
 (0)
Please sign in to comment.