|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * Copyright © Magento, Inc. All rights reserved. |
| 7 | + * See COPYING.txt for license details. |
| 8 | + */ |
| 9 | + |
| 10 | +namespace Magento\Framework\Amqp\Test\Unit\Topology; |
| 11 | + |
| 12 | +use InvalidArgumentException; |
| 13 | +use Magento\Framework\Amqp\Topology\ArgumentProcessor; |
| 14 | +use PHPUnit\Framework\MockObject\MockObject; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +/** |
| 18 | + * Class ArgumentProcessorTest |
| 19 | + */ |
| 20 | +class ArgumentProcessorTest extends TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @var ArgumentProcessor|MockObject |
| 24 | + */ |
| 25 | + private $argumentProcessor; |
| 26 | + |
| 27 | + /** |
| 28 | + * @return void |
| 29 | + */ |
| 30 | + public function testProcessArgumentsWhenAnyArgumentIsIncorrect(): void |
| 31 | + { |
| 32 | + $arguments = [ |
| 33 | + 'test' => new class { |
| 34 | + } |
| 35 | + ]; |
| 36 | + |
| 37 | + $this->expectException(InvalidArgumentException::class); |
| 38 | + $this->argumentProcessor->processArguments($arguments); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * @return void |
| 43 | + */ |
| 44 | + public function testProcessArgumentsWhenAllArgumentAreCorrect(): void |
| 45 | + { |
| 46 | + $arguments = [ |
| 47 | + 'array_type' => ['some_key' => 'some_value'], |
| 48 | + 'numeric_value' => '25', |
| 49 | + 'integer_value' => 26, |
| 50 | + 'boolean_value' => false, |
| 51 | + 'string_value' => 'test' |
| 52 | + ]; |
| 53 | + |
| 54 | + $expected = [ |
| 55 | + 'array_type' => ['A', ['some_key' => 'some_value']], |
| 56 | + 'numeric_value' => ['I', 25], |
| 57 | + 'integer_value' => ['I', 26], |
| 58 | + 'boolean_value' => ['t', false], |
| 59 | + 'string_value' => ['S', 'test'] |
| 60 | + ]; |
| 61 | + |
| 62 | + $this->assertSame($expected, $this->argumentProcessor->processArguments($arguments)); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * @return void |
| 67 | + */ |
| 68 | + protected function setUp(): void |
| 69 | + { |
| 70 | + parent::setUp(); |
| 71 | + $this->argumentProcessor = $this->getMockForTrait(ArgumentProcessor::class); |
| 72 | + } |
| 73 | +} |
0 commit comments