for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NeedleProject\LaravelRabbitMq;
use PHPUnit\Framework\TestCase;
class ConfigHelperTest extends TestCase
{
/**
* @dataProvider provideScenarios
* @param $inputConfig
* @param $expectedConfig
*/
public function testDefaultsForMainKeys($inputConfig, $expectedConfig)
$configHelper = new ConfigHelper();
$newConfig = $configHelper->addDefaults($inputConfig);
$this->assertEquals($expectedConfig, $newConfig);
}
public static function provideScenarios(): array
return [
// first scenario -- add root keys
[
[],
'connections' => [],
'exchanges' => [],
'queues' => [],
'publishers' => [],
'consumers' => []
]
],
// second scenario -- add attributes on queues
'connections' => [
'bar' => []
'queues' => [
'foo' => [
'name' => 'foo.bar',
'connection' => 'bar'
'connection' => 'bar',
'attributes' => []
// third scenario -- add prefetch_count and global_prefetch on consumer
'consumers' => [
'foo_consumer' => [
'queue' => 'foo',
'message_processor' => 'BAR'
'prefetch_count' => 1,
'global_prefetch' => true,
// 4th scenario -- don't override prefetch_count and global_prefetch on consumer
'prefetch_count' => 3,
'global_prefetch' => false,
// 5th scenario -- add attributes on queues
'attributes' => [
'bind' => [
['exchange' => 'foobar']
];