Skip to content

Commit a7f07cb

Browse files
committed
Add phpunit/phpunit and updates recipes
1 parent a904340 commit a7f07cb

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ composer.lock
2525
/public/assets/
2626
/assets/vendor/
2727
###< symfony/asset-mapper ###
28+
29+
###> phpunit/phpunit ###
30+
/.phpunit.cache/
31+
###< phpunit/phpunit ###

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"twig/twig": "^3.0"
5252
},
5353
"require-dev": {
54+
"phpunit/phpunit": "*",
5455
"symfony/browser-kit": "*",
5556
"symfony/css-selector": "*",
5657
"symfony/debug-bundle": "*",

phpunit.dist.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6+
colors="true"
7+
failOnDeprecation="true"
8+
failOnNotice="true"
9+
failOnWarning="true"
10+
bootstrap="tests/bootstrap.php"
11+
cacheDirectory=".phpunit.cache"
12+
>
13+
<php>
14+
<ini name="display_errors" value="1" />
15+
<ini name="error_reporting" value="-1" />
16+
<server name="APP_ENV" value="test" force="true" />
17+
<server name="SHELL_VERBOSITY" value="-1" />
18+
</php>
19+
20+
<testsuites>
21+
<testsuite name="Project Test Suite">
22+
<directory>tests</directory>
23+
</testsuite>
24+
</testsuites>
25+
26+
<source ignoreSuppressionOfDeprecations="true"
27+
ignoreIndirectDeprecations="true"
28+
restrictNotices="true"
29+
restrictWarnings="true"
30+
>
31+
<include>
32+
<directory>src</directory>
33+
</include>
34+
35+
<deprecationTrigger>
36+
<method>Doctrine\Deprecations\Deprecation::trigger</method>
37+
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
38+
<function>trigger_deprecation</function>
39+
</deprecationTrigger>
40+
</source>
41+
42+
<extensions>
43+
</extensions>
44+
</phpunit>

src/Schedule.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Symfony\Component\Scheduler\Attribute\AsSchedule;
6+
use Symfony\Component\Scheduler\Schedule as SymfonySchedule;
7+
use Symfony\Component\Scheduler\ScheduleProviderInterface;
8+
use Symfony\Contracts\Cache\CacheInterface;
9+
10+
#[AsSchedule]
11+
class Schedule implements ScheduleProviderInterface
12+
{
13+
public function __construct(
14+
private CacheInterface $cache,
15+
) {
16+
}
17+
18+
public function getSchedule(): SymfonySchedule
19+
{
20+
return (new SymfonySchedule())
21+
->stateful($this->cache) // ensure missed tasks are executed
22+
->processOnlyLastMissedRun(true) // ensure only last missed task is run
23+
24+
// add your own tasks here
25+
// see https://symfony.com/doc/current/scheduler.html#attaching-recurring-messages-to-a-schedule
26+
;
27+
}
28+
}

symfony.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@
104104
"phpdocumentor/type-resolver": {
105105
"version": "1.5.1"
106106
},
107+
"phpunit/phpunit": {
108+
"version": "12.2",
109+
"recipe": {
110+
"repo": "github.com/symfony/recipes",
111+
"branch": "main",
112+
"version": "11.1",
113+
"ref": "c6658a60fc9d594805370eacdf542c3d6b5c0869"
114+
},
115+
"files": [
116+
".env.test",
117+
"phpunit.dist.xml",
118+
"tests/bootstrap.php",
119+
"bin/phpunit"
120+
]
121+
},
107122
"psr/cache": {
108123
"version": "3.0.0"
109124
},
@@ -433,6 +448,18 @@
433448
"config/routes.yaml"
434449
]
435450
},
451+
"symfony/scheduler": {
452+
"version": "7.3",
453+
"recipe": {
454+
"repo": "github.com/symfony/recipes",
455+
"branch": "main",
456+
"version": "7.2",
457+
"ref": "caea3c928ee9e1b21288fd76aef36f16ea355515"
458+
},
459+
"files": [
460+
"src/Schedule.php"
461+
]
462+
},
436463
"symfony/security-bundle": {
437464
"version": "5.4",
438465
"recipe": {

0 commit comments

Comments
 (0)