-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTestController.php
More file actions
44 lines (36 loc) · 1.23 KB
/
TestController.php
File metadata and controls
44 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace Shopsys\HttpSmokeTesting\Test;
use Shopsys\HttpSmokeTesting\Attribute\DataSet;
use Shopsys\HttpSmokeTesting\Attribute\Parameter;
use Shopsys\HttpSmokeTesting\Attribute\Skipped;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class TestController
{
#[Route(path: '/hello/{name}')]
#[DataSet(parameters: [new Parameter(name: 'name', value: 'Batman')])]
#[DataSet(statusCode: 404, parameters: [new Parameter(name: 'name', value: 'World')])]
public function helloAction(string $name): Response
{
if ($name === 'Batman') {
return new Response(sprintf('I am %1$s!', $name), 200);
}
return new Response('Nothing found.', 404);
}
#[Route(path: '/test')]
#[DataSet(parameters: [new Parameter(name: 'myName', value: 'Batman')])]
public function testAction(string $name): Response
{
if ($name === 'Batman') {
return new Response(sprintf('I am %1$s!', $name), 200);
}
return new Response('Nothing found.', 404);
}
#[Route(path: '/untested')]
#[Skipped]
public function untestedAction(): Response
{
return new Response('', 500);
}
}