graze /
queue
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * This file is part of graze/queue. |
||||||
| 5 | * |
||||||
| 6 | * Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com> |
||||||
| 7 | * |
||||||
| 8 | * For the full copyright and license information, please view the LICENSE |
||||||
| 9 | * file that was distributed with this source code. |
||||||
| 10 | * |
||||||
| 11 | * @license https://github.com/graze/queue/blob/master/LICENSE MIT |
||||||
| 12 | * |
||||||
| 13 | * @link https://github.com/graze/queue |
||||||
| 14 | */ |
||||||
| 15 | |||||||
| 16 | namespace Graze\Queue\Adapter; |
||||||
| 17 | |||||||
| 18 | use Aws\ResultInterface; |
||||||
| 19 | use Aws\Firehose\FirehoseClient; |
||||||
| 20 | use Graze\Queue\Adapter\Exception\MethodNotSupportedException; |
||||||
| 21 | use Graze\Queue\Message\MessageFactoryInterface; |
||||||
| 22 | use Graze\Queue\Message\MessageInterface; |
||||||
| 23 | use Mockery as m; |
||||||
| 24 | use Mockery\MockInterface; |
||||||
| 25 | use Graze\Queue\Test\TestCase; |
||||||
| 26 | |||||||
| 27 | class FirehoseAdapterTest extends TestCase |
||||||
| 28 | { |
||||||
| 29 | /** @var MessageInterface|MockInterface */ |
||||||
| 30 | private $messageA; |
||||||
| 31 | /** @var MessageInterface|MockInterface */ |
||||||
| 32 | private $messageB; |
||||||
| 33 | /** @var MessageInterface|MockInterface */ |
||||||
| 34 | private $messageC; |
||||||
| 35 | /** @var MessageInterface[]|MockInterface[] */ |
||||||
| 36 | private $messages; |
||||||
| 37 | /** @var ResultInterface|MockInterface */ |
||||||
| 38 | private $model; |
||||||
| 39 | /** @var MessageFactoryInterface|MockInterface */ |
||||||
| 40 | private $factory; |
||||||
| 41 | /** @var FirehoseClient */ |
||||||
| 42 | private $client; |
||||||
| 43 | |||||||
| 44 | public function setUp() |
||||||
| 45 | { |
||||||
| 46 | $this->client = m::mock(FirehoseClient::class); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 47 | $this->model = m::mock(ResultInterface::class); |
||||||
| 48 | $this->factory = m::mock(MessageFactoryInterface::class); |
||||||
| 49 | |||||||
| 50 | $this->messageA = $a = m::mock(MessageInterface::class); |
||||||
| 51 | $this->messageB = $b = m::mock(MessageInterface::class); |
||||||
| 52 | $this->messageC = $c = m::mock(MessageInterface::class); |
||||||
| 53 | $this->messages = [$a, $b, $c]; |
||||||
| 54 | } |
||||||
| 55 | |||||||
| 56 | public function testInterface() |
||||||
| 57 | { |
||||||
| 58 | assertThat(new FirehoseAdapter($this->client, 'foo'), is(anInstanceOf('Graze\Queue\Adapter\AdapterInterface'))); |
||||||
| 59 | } |
||||||
| 60 | |||||||
| 61 | public function testEnqueue() |
||||||
| 62 | { |
||||||
| 63 | $adapter = new FirehoseAdapter($this->client, 'foo'); |
||||||
| 64 | |||||||
| 65 | $this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo'); |
||||||
|
0 ignored issues
–
show
The method
shouldReceive() does not exist on Graze\Queue\Message\MessageInterface.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 66 | $this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar'); |
||||||
| 67 | $this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz'); |
||||||
| 68 | |||||||
| 69 | $this->model->shouldReceive('get')->once()->with('RequestResponses')->andReturn([]); |
||||||
|
0 ignored issues
–
show
The method
shouldReceive() does not exist on Aws\ResultInterface.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 70 | |||||||
| 71 | $this->client->shouldReceive('putRecordBatch')->once()->with([ |
||||||
| 72 | 'DeliveryStreamName' => 'foo', |
||||||
| 73 | 'Records' => [ |
||||||
| 74 | ['Data' => 'foo'], |
||||||
| 75 | ['Data' => 'bar'], |
||||||
| 76 | ['Data' => 'baz'], |
||||||
| 77 | ], |
||||||
| 78 | ])->andReturn($this->model); |
||||||
| 79 | |||||||
| 80 | $adapter->enqueue($this->messages); |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | /** |
||||||
| 84 | * @expectedException \Graze\Queue\Adapter\Exception\MethodNotSupportedException |
||||||
| 85 | */ |
||||||
| 86 | public function testAcknowledge() |
||||||
| 87 | { |
||||||
| 88 | $adapter = new FirehoseAdapter($this->client, 'foo'); |
||||||
| 89 | $adapter->acknowledge($this->messages); |
||||||
| 90 | } |
||||||
| 91 | |||||||
| 92 | /** |
||||||
| 93 | * @expectedException \Graze\Queue\Adapter\Exception\MethodNotSupportedException |
||||||
| 94 | */ |
||||||
| 95 | public function testDequeue() |
||||||
| 96 | { |
||||||
| 97 | $adapter = new FirehoseAdapter($this->client, 'foo'); |
||||||
| 98 | $adapter->dequeue($this->factory, 10); |
||||||
|
0 ignored issues
–
show
It seems like
$this->factory can also be of type Mockery\MockInterface; however, parameter $factory of Graze\Queue\Adapter\FirehoseAdapter::dequeue() does only seem to accept Graze\Queue\Message\MessageFactoryInterface, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 99 | } |
||||||
| 100 | |||||||
| 101 | /** |
||||||
| 102 | * @expectedException \Graze\Queue\Adapter\Exception\MethodNotSupportedException |
||||||
| 103 | */ |
||||||
| 104 | public function testPurge() |
||||||
| 105 | { |
||||||
| 106 | $adapter = new FirehoseAdapter($this->client, 'foo'); |
||||||
| 107 | $adapter->purge(); |
||||||
| 108 | } |
||||||
| 109 | |||||||
| 110 | /** |
||||||
| 111 | * @expectedException \Graze\Queue\Adapter\Exception\MethodNotSupportedException |
||||||
| 112 | */ |
||||||
| 113 | public function testDelete() |
||||||
| 114 | { |
||||||
| 115 | $adapter = new FirehoseAdapter($this->client, 'foo'); |
||||||
| 116 | $adapter->delete(); |
||||||
| 117 | } |
||||||
| 118 | } |
||||||
| 119 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..