Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Merge 23a4c78 into f468b11
Browse files Browse the repository at this point in the history
  • Loading branch information
Vabogco committed Oct 19, 2021
2 parents f468b11 + 23a4c78 commit 5ff4aab
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Expand Up @@ -6,7 +6,7 @@ checks:
build:
environment:
php:
version: 7.1
version: 7.2
tests:
override:
- command: vendor/bin/codecept run unit --coverage-xml=build/clover.xml
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"minimum-stability": "stable",
"require": {
"php": ">=7.1.0",
"ext-PDO": "^7.1",
"php": ">=7.2.0",
"ext-PDO": "*",
"ext-json": "*",
"doctrine/doctrine-bundle": "^1.9 || ^2.0",
"doctrine/orm": "~2.3",
"jms/serializer-bundle": "^2.4 || ^3.0",
"php-amqplib/php-amqplib": "~2.9",
"php-amqplib/rabbitmq-bundle": "~1.14.3",
"php-amqplib/php-amqplib": "~3.0",
"php-amqplib/rabbitmq-bundle": "~2.9.0",
"symfony/config": "^4.1 || ^5.0",
"symfony/console": "^4.2 || ^5.0",
"symfony/dependency-injection": "^4.2 || ^5.0",
Expand All @@ -21,8 +21,10 @@
"symfony/monolog-bundle": "^3.3"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.3",
"friendsofphp/php-cs-fixer": "^2.13",
"codeception/codeception": "~2.3.0"
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 10 additions & 0 deletions src/Strategy/Delay/ArithmeticProgressionStrategy.php
Expand Up @@ -20,6 +20,16 @@ public function __construct(int $startIntervalSec, float $multiplier)
$this->multiplier = $multiplier;
}

public function getStartInterval(): int
{
return $this->startInterval;
}

public function getMultiplier(): float
{
return $this->multiplier;
}

public function generateInterval(int $iteration): DateInterval
{
$newIntervalSec = (int) ceil($this->startInterval + ($this->multiplier * ($iteration - 1)));
Expand Down
10 changes: 10 additions & 0 deletions src/Strategy/Delay/GeometricProgressionStrategy.php
Expand Up @@ -20,6 +20,16 @@ public function __construct(int $startIntervalSec, float $multiplier)
$this->multiplier = $multiplier;
}

public function getStartInterval(): int
{
return $this->startInterval;
}

public function getMultiplier(): float
{
return $this->multiplier;
}

public function generateInterval(int $iteration): DateInterval
{
$newIntervalSec = (int) ceil($this->startInterval * ($this->multiplier ** ($iteration - 1)));
Expand Down
33 changes: 17 additions & 16 deletions tests/unit/QueueCommonServicesTrait.php
Expand Up @@ -16,14 +16,15 @@
use Lamoda\QueueBundle\Service\QueueRequeueService;
use Lamoda\QueueBundle\Service\QueueService;
use OldSound\RabbitMqBundle\RabbitMq\Producer;
use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\MockObject;

trait QueueCommonServicesTrait
{
/**
* @param array|null $methods
*
* @return EntityFactory | PHPUnit_Framework_MockObject_MockObject
* @return EntityFactory | MockObject
*/
protected function getMockEntityFactory(?array $methods = null)
{
Expand All @@ -33,7 +34,7 @@ protected function getMockEntityFactory(?array $methods = null)
/**
* @param array|null $methods
*
* @return QueueService | PHPUnit_Framework_MockObject_MockObject
* @return QueueService | MockObject
*/
protected function getMockQueueService(?array $methods = null)
{
Expand All @@ -43,7 +44,7 @@ protected function getMockQueueService(?array $methods = null)
/**
* @param array|null $methods
*
* @return Publisher | PHPUnit_Framework_MockObject_MockObject
* @return Publisher | MockObject
*/
protected function getMockPublisher(?array $methods = null)
{
Expand All @@ -53,7 +54,7 @@ protected function getMockPublisher(?array $methods = null)
/**
* @param array|null $methods
*
* @return PublisherFactory | PHPUnit_Framework_MockObject_MockObject
* @return PublisherFactory | MockObject
*/
protected function getMockPublisherFactory(?array $methods = null)
{
Expand All @@ -63,7 +64,7 @@ protected function getMockPublisherFactory(?array $methods = null)
/**
* @param array|null $methods
*
* @return Consumer | PHPUnit_Framework_MockObject_MockObject
* @return Consumer | MockObject
*/
protected function getMockConsumer(?array $methods = null)
{
Expand All @@ -73,7 +74,7 @@ protected function getMockConsumer(?array $methods = null)
/**
* @param array|null $methods
*
* @return QueueRequeueService | PHPUnit_Framework_MockObject_MockObject
* @return QueueRequeueService | MockObject
*/
protected function getMockQueueRequeueService(?array $methods = null)
{
Expand All @@ -83,7 +84,7 @@ protected function getMockQueueRequeueService(?array $methods = null)
/**
* @param array|null $methods
*
* @return PHPUnit_Framework_MockObject_MockObject | QueueConsumerCommand
* @return MockObject | QueueConsumerCommand
*/
protected function getQueueMockConsumerCommand(?array $methods = null)
{
Expand All @@ -93,7 +94,7 @@ protected function getQueueMockConsumerCommand(?array $methods = null)
/**
* @param array|null $methods
*
* @return QueueRepository | PHPUnit_Framework_MockObject_MockObject
* @return QueueRepository | MockObject
*/
protected function getMockQueueRepository(?array $methods = null)
{
Expand All @@ -103,7 +104,7 @@ protected function getMockQueueRepository(?array $methods = null)
/**
* @param array|null $methods
*
* @return HandlerInterface | PHPUnit_Framework_MockObject_MockObject
* @return HandlerInterface | MockObject
*/
protected function getMockHandler(?array $methods = null)
{
Expand All @@ -113,7 +114,7 @@ protected function getMockHandler(?array $methods = null)
/**
* @param array|null $methods
*
* @return Producer | PHPUnit_Framework_MockObject_MockObject
* @return Producer | MockObject
*/
protected function getMockProducer(?array $methods = null)
{
Expand All @@ -123,7 +124,7 @@ protected function getMockProducer(?array $methods = null)
/**
* @param array|null $methods
*
* @return AbstractJob | PHPUnit_Framework_MockObject_MockObject
* @return AbstractJob | MockObject
*/
protected function getMockAbstractJob(?array $methods = null)
{
Expand All @@ -137,12 +138,12 @@ protected function getMockAbstractJob(?array $methods = null)
* @param string $serviceName
* @param array|null $methods
*
* @return PHPUnit_Framework_MockObject_MockObject
* @return MockObject
*/
private function getQueueMockService(
string $serviceName,
?array $methods = null
): PHPUnit_Framework_MockObject_MockObject {
): MockObject {
return $this->getMockBuilder($serviceName)
->disableOriginalConstructor()
->setMethods($methods)
Expand All @@ -152,7 +153,7 @@ private function getQueueMockService(
/**
* @param array|null $methods
*
* @return DelayService | PHPUnit_Framework_MockObject_MockObject
* @return DelayService | MockObject
*/
private function getMockDelayService(?array $methods = null)
{
Expand All @@ -162,5 +163,5 @@ private function getMockDelayService(?array $methods = null)
->getMock();
}

abstract protected function getMockBuilder($className);
abstract protected function getMockBuilder(string $className): MockBuilder;
}
8 changes: 4 additions & 4 deletions tests/unit/Service/DelayStrategyResolverTest.php
Expand Up @@ -21,8 +21,8 @@ public function testGetStrategy()
$resolver = $this->createDelayStrategyResolver($strategiesByQueues);
$strategy = $resolver->getStrategy($checkingQueueName);
$this->assertInstanceOf(ArithmeticProgressionStrategy::class, $strategy);
$this->assertAttributeEquals(100, 'startInterval', $strategy);
$this->assertAttributeEquals(4, 'multiplier', $strategy);
$this->assertEquals(100, $strategy->getStartInterval());
$this->assertEquals(4, $strategy->getMultiplier());
}

public function testGetDefaultStrategy()
Expand All @@ -33,8 +33,8 @@ public function testGetDefaultStrategy()
$resolver = $this->createDelayStrategyResolver($strategiesByQueues);
$strategy = $resolver->getStrategy($checkingQueueName);
$this->assertInstanceOf(GeometricProgressionStrategy::class, $strategy);
$this->assertAttributeEquals(60, 'startInterval', $strategy);
$this->assertAttributeEquals(3, 'multiplier', $strategy);
$this->assertEquals(60, $strategy->getStartInterval());
$this->assertEquals(3, $strategy->getMultiplier());
}

public function testFailGetDefaultStrategy()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/SymfonyMockTrait.php
Expand Up @@ -7,6 +7,7 @@
use Doctrine\ORM\EntityManager;
use JMS\Serializer\Serializer;
use JMS\Serializer\SerializerInterface;
use PHPUnit\Framework\MockObject\MockBuilder;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
Expand Down Expand Up @@ -100,5 +101,5 @@ protected function getMockEventDispatcher(array $methods = [])
->getMock();
}

abstract protected function getMockBuilder($className);
abstract protected function getMockBuilder(string $className): MockBuilder;
}

0 comments on commit 5ff4aab

Please sign in to comment.