Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ composer.lock

# PHP CS Fixer
.php_cs.cache
/.phpunit.result.cache
6 changes: 6 additions & 0 deletions Components/Queues/Drivers/AmqpQueueDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@ protected function validateConnection()
{
return $this->stream instanceof AbstractConnection;
}

public function purge(string $queue): void
{
$this->declareChannel();
$this->channel->queue_purge($queue);
}
}
8 changes: 8 additions & 0 deletions Core/Processors/Routing/ContentRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ protected function onPostProcessEvent(ProcessEvent $event)
$condition = $event->getProcessingContext()->get(self::CONDITION_MATCHED);
$event->setEventDetails('Matched condition: '.$condition);
}

/**
* @return ConditionalClause[]
*/
public function clauses(): array
{
return $this->clauses;
}
}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ start: ## Start the project
$(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate

useradd: ## Add your host user to the container
$(EXEC_SUDO_PHP) groupadd -f -g $(shell id -g) $(USER_NAME)
$(EXEC_SUDO_PHP) useradd -u $(shell id -u) -g $(shell id -g) -m $(USER_NAME)
$(EXEC_SUDO_PHP) groupadd -f -g $(shell id -g) $(USER_NAME) 2> /dev/null
$(EXEC_SUDO_PHP) useradd -u $(shell id -u) -g $(shell id -g) -m $(USER_NAME) 2> /dev/null

stop: ## Stop the project
$(DOCKER_COMPOSE) stop
Expand All @@ -44,7 +44,7 @@ clear-cache:
$(EXEC_SUDO_PHP) bash -c 'rm -rf var/cache/*'

vendor:
$(EXEC_PHP) composer install --prefer-dist
$(EXEC_PHP) composer install

test:
$(EXEC_PHP) php ./bin/phpunit
5 changes: 3 additions & 2 deletions Tests/BaseKernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Smartbox\Integration\FrameworkBundle\Core\Messages\Context;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Class BaseKernelTestCase.
Expand All @@ -16,14 +17,14 @@ class BaseKernelTestCase extends KernelTestCase
/** @var SmartesbHelper */
protected $helper;

protected function setUp()
protected function setUp(): void
{
$this->bootKernel();
$this->getContainer()->set('doctrine', $this->createMock(RegistryInterface::class));
$this->helper = $this->getContainer()->get('smartesb.helper');
}

public function getContainer()
public function getContainer(): ContainerInterface
{
return self::$kernel->getContainer();
}
Expand Down
13 changes: 9 additions & 4 deletions Tests/Functional/Consumers/AsyncQueueConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Smartbox\Integration\FrameworkBundle\Tests\Functional\Consumers;

use Smartbox\Integration\FrameworkBundle\Components\Queues\AsyncQueueConsumer;
use Smartbox\Integration\FrameworkBundle\Components\Queues\Drivers\AsyncQueueDriverInterface;
use Smartbox\Integration\FrameworkBundle\Components\Queues\Drivers\QueueDriverInterface;
use Smartbox\Integration\FrameworkBundle\Components\Queues\QueueMessage;
use Smartbox\Integration\FrameworkBundle\Components\Queues\QueueProtocol;
use Smartbox\Integration\FrameworkBundle\Core\Endpoints\Endpoint;
Expand All @@ -21,12 +23,14 @@ class AsyncQueueConsumerTest extends BaseKernelTestCase
{
const QUEUE = '/test/async';

private function getConsumer()
private function getConsumer(): AsyncQueueConsumer
{
return $this->helper->getConsumer('async_queue');
/** @var AsyncQueueConsumer $consumer */
$consumer = $this->helper->getConsumer('async_queue');
return $consumer;
}

private function getQueueDriver(string $queueDriverName): AsyncQueueDriverInterface
private function getQueueDriver(string $queueDriverName): QueueDriverInterface
{
return $this->helper->getQueueDriver($queueDriverName);
}
Expand All @@ -40,6 +44,7 @@ public function testConsume()
$serializer = $consumer->getSerializer();
$queueDriver = $this->getQueueDriver('amqp');
$queueDriver->connect();
$queueDriver->purge(self::QUEUE);

$message = $this->createMessage(new EntityX(333));
$queueMessage = new QueueMessage();
Expand Down Expand Up @@ -68,7 +73,7 @@ public function testConsume()
$consumer->consume($endpoint);

$output = $this->getActualOutput();
$this->assertNotContains('A message was consumed', $output);
$this->assertStringNotContainsString('A message was consumed', $output);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Consumers/QueueConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function (Endpoint $endpoint) use ($queues) {
\pcntl_alarm(0);

$output = $this->getActualOutput();
$this->assertNotContains('A message was consumed', $output); // The consumer should not display message information if no logger
$this->assertStringNotContainsString('A message was consumed', $output); // The consumer should not display message information if no logger
}

/**
Expand Down Expand Up @@ -197,6 +197,6 @@ function (Endpoint $endpoint) use ($queues) {
\pcntl_alarm(0);

$output = $this->getActualOutput();
$this->assertNotContains('A message was consumed', $output); // The consumer should not display message information with NullLogger
$this->assertStringNotContainsString('A message was consumed', $output); // The consumer should not display message information with NullLogger
}
}
4 changes: 2 additions & 2 deletions Tests/Functional/Drivers/Queue/AbstractQueueDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ abstract class AbstractQueueDriverTest extends BaseTestCase
*/
protected $driver;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->driver = $this->createDriver();
$this->driver->connect();
$this->queueName = static::QUEUE_PREFIX.(new \ReflectionClass($this->driver))->getShortName().md5(random_bytes(10));
}

protected function tearDown()
protected function tearDown(): void
{
$this->driver->disconnect();
$this->driver = null;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Handlers/DeferredEventsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DeferredEventsHandlerTest extends \PHPUnit\Framework\TestCase
/** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */
public $eventDispatcherMock;

public function setUp()
public function setUp(): void
{
$this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
$this->handler = new DeferredEventsHandler();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Handlers/MessageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MessageHandlerTest extends \PHPUnit\Framework\TestCase
/** @var MessageFactoryInterface */
public $factory;

protected function setUp()
protected function setUp(): void
{
$this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
$this->handler = new MessageHandler();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract public function getInvalidMessages();

abstract public function getWorkingMessages();

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->processor = $this->createProcessor();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Producers/ConfigurableProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ConfigurableProducerTest extends BaseTestCase
],
];

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Producers/JsonFileLoaderProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JsonFileLoaderProducerTest extends BaseTestCase
/** @var JsonFileLoaderProducer */
protected $producer;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->producer = new JsonFileLoaderProducer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RestConfigurableProducerTest extends BaseTestCase
/** @var RestConfigurableProducer */
protected $producer;

public function setUp()
public function setUp(): void
{
parent::setUp();
$producer = new RestConfigurableProducer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CsvConfigurableStepsProviderTest extends BaseTestCase
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -41,7 +41,7 @@ public function setUp()
/**
* {@inheritdoc}
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
//create a temporary folder
Expand All @@ -51,7 +51,7 @@ public static function setUpBeforeClass()
/**
* {@inheritdoc}
*/
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
$files = \glob(self::TMP_FOLDER.'*');
foreach ($files as $file) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Storage/Driver/MongoDBDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MongoDBDriverTest extends KernelTestCase
/** @var NoSQLDriverInterface */
protected static $storageDriver;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
if (!\extension_loaded('mongodb')) {
self::markTestSkipped(
Expand All @@ -55,7 +55,7 @@ public static function setUpBeforeClass()
parent::setUpBeforeClass();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
self::$storageDriver = null;
parent::tearDownAfterClass();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Tools/Evaluator/ExpressionEvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class ExpressionEvaluatorTest extends KernelTestCase
*/
protected $evaluator;

protected function setUp()
protected function setUp(): void
{
$this->bootKernel();
$this->evaluator = static::$kernel->getContainer()->get('smartesb.util.evaluator');
}

protected function tearDown()
protected function tearDown(): void
{
$this->evaluator = null;
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Tools/Mapper/MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class MapperTest extends BaseTestCase
/** @var Mapper|MapperInterface */
protected $mapper;

public function setUp()
public function setUp(): void
{
$this->bootKernel(['debug' => false]);
$this->mapper = $this->getContainer()->get('smartesb.util.mapper');
}

public function tearDown()
public function tearDown(): void
{
$this->mapper = null;
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/Unit/Command/ConsumeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ConsumeCommandTest extends KernelTestCase
const NB_MESSAGES = 1;
const URI = 'queue://main/api';

protected function setUp()
protected function setUp(): void
{
self::bootKernel();
self::$kernel->getContainer()->set('doctrine', $this->createMock(RegistryInterface::class));
Expand Down Expand Up @@ -49,8 +49,8 @@ public function testExecuteWithKillAfter()
]);

$output = $commandTester->getDisplay();
$this->assertContains('limited to', $output);
$this->assertContains('Consumer was gracefully stopped', $output);
$this->assertStringContainsString('limited to', $output);
$this->assertStringContainsString('Consumer was gracefully stopped', $output);
}

public function testExecuteWithoutKillAfter()
Expand All @@ -68,7 +68,7 @@ public function testExecuteWithoutKillAfter()
]);

$output = $commandTester->getDisplay();
$this->assertNotContains('limited to', $output);
$this->assertContains('Consumer was gracefully stopped', $output);
$this->assertStringNotContainsString('limited to', $output);
$this->assertStringContainsString('Consumer was gracefully stopped', $output);
}
}
2 changes: 1 addition & 1 deletion Tests/Unit/Components/DB/DBConfigurableConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DBConfigurableConsumerTest extends \PHPUnit\Framework\TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
$this->messageFactory = $this->createMock(MessageFactory::class);
$this->stepProvider = $this->createMock(ConfigurableStepsProviderInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConfigurableDbalProtocolTest extends \PHPUnit\Framework\TestCase
*/
private $expectedOptions;

protected function setUp()
protected function setUp(): void
{
$this->dbalProtocol = new ConfigurableDbalProtocol();
$this->expectedOptions = [
Expand All @@ -33,7 +33,7 @@ protected function setUp()
];
}

protected function tearDown()
protected function tearDown(): void
{
$this->dbalProtocol = null;
$this->expectedOptions = null;
Expand Down
Loading