Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #38141 [Messenger] Added factory methods to DelayStamp for better…
… DX (Toflar) This PR was merged into the 5.2-dev branch. Discussion ---------- [Messenger] Added factory methods to DelayStamp for better DX | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | not necessary imho I often find myself delaying messages for a few minutes or so and I always have to remember the `DelayStamp` uses milliseconds. I guess these simple factories could improve DX quite a bit :) Commits ------- fdc8da0 [Messenger] Added factory methods to DelayStamp for better DX
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Symfony/Component/Messenger/Tests/Stamp/DelayStampTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Messenger\Tests\Stamp; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Messenger\Stamp\DelayStamp; | ||
|
||
/** | ||
* @author Yanick Witschi <yanick.witschi@terminal42.ch> | ||
*/ | ||
class DelayStampTest extends TestCase | ||
{ | ||
public function testSeconds() | ||
{ | ||
$stamp = DelayStamp::delayForSeconds(30); | ||
$this->assertSame(30000, $stamp->getDelay()); | ||
} | ||
|
||
public function testMinutes() | ||
{ | ||
$stamp = DelayStamp::delayForMinutes(30); | ||
$this->assertSame(1800000, $stamp->getDelay()); | ||
} | ||
|
||
public function testHours() | ||
{ | ||
$stamp = DelayStamp::delayForHours(30); | ||
$this->assertSame(108000000, $stamp->getDelay()); | ||
} | ||
} |