| 1 | <?php |
||
| 9 | class ProducerTest extends \PHPUnit_Framework_TestCase |
||
| 10 | { |
||
| 11 | public function testOptions() |
||
| 12 | { |
||
| 13 | $configuration = [ |
||
| 14 | 'connection' => 'connection-name', |
||
| 15 | 'exchange' => [ |
||
| 16 | 'name' => 'exchange-name', |
||
| 17 | ], |
||
| 18 | 'queue' => [ |
||
| 19 | 'name' => 'queue-name', |
||
| 20 | ], |
||
| 21 | 'class' => 'class-name', |
||
| 22 | 'auto_setup_fabric_enabled' => false, |
||
| 23 | ]; |
||
| 24 | $options = new Producer(); |
||
| 25 | $options->setFromArray($configuration); |
||
| 26 | |||
| 27 | static::assertEquals($configuration['connection'], $options->getConnection()); |
||
| 28 | static::assertInstanceOf('RabbitMqModule\\Options\\Exchange', $options->getExchange()); |
||
| 29 | static::assertInstanceOf('RabbitMqModule\\Options\\Queue', $options->getQueue()); |
||
| 30 | static::assertEquals($configuration['class'], $options->getClass()); |
||
| 31 | static::assertFalse($options->isAutoSetupFabricEnabled()); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @expectedException \InvalidArgumentException |
||
| 36 | */ |
||
| 37 | public function testSetQueueInvalidValue() |
||
| 38 | { |
||
| 39 | $options = new Producer(); |
||
| 40 | $options->setQueue(''); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @expectedException \InvalidArgumentException |
||
| 45 | */ |
||
| 46 | public function testSetExchangeInvalidValue() |
||
| 47 | { |
||
| 48 | $options = new Producer(); |
||
| 49 | $options->setExchange(''); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |