Page MenuHomeDevCentral

Payload full test, with a blackhole broker
ClosedPublic

Authored by dereckson on Jan 9 2016, 05:33.
Referenced Files
F3913546: D197.id484.diff
Thu, Dec 19, 10:35
F3913460: D197.id468.diff
Thu, Dec 19, 10:11
F3913006: D197.diff
Thu, Dec 19, 08:01
Unknown Object (File)
Sun, Dec 15, 05:14
Unknown Object (File)
Sat, Dec 14, 09:47
Unknown Object (File)
Thu, Dec 12, 04:08
Unknown Object (File)
Sun, Dec 8, 21:28
Unknown Object (File)
Sat, Dec 7, 23:42
Subscribers
None

Details

Reviewers
dereckson
Commits
Unknown Object (Diffusion Commit)
rNOTIFc89945f725f8: Payload full test, with a blackhole broker
Summary

Tests a more realistic scenario where:

  • a payload is received
  • events are fully dispatched

We mock the broker to allow to run the test without one.

This bumps the dependency to Keruald Broker from 0.1 to 0.2.

Test Plan

phpunit

Diff Detail

Repository
rNOTIF Notifications center
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dereckson retitled this revision from to WIP: Payload full test.
dereckson updated this object.
dereckson edited the test plan for this revision. (Show Details)
dereckson added a reviewer: dereckson.
dereckson edited edge metadata.

We need to mock the broker.

Code to mock
Broker::setExchangeTarget($this->target)
    ->routeTo($this->routingKey)
    ->sendMessage($this->message);
Mock proposal
$mock = Mockery('Keruald\Broker\AMQPBroker');

$mock->shouldReceive('setExchangeTarget'); // TODO: return $this, not null
$mock->shouldReceive('routeTo');
$mock->shouldReceive('sendMessage');

$this->app->instance('broker', $mock);

Reference: http://docs.mockery.io/en/latest/reference/demeter_chains.html

dereckson edited edge metadata.

Rebased against master

We can mock, or use the blackhole.

dereckson edited edge metadata.
This revision is now accepted and ready to land.Jan 9 2016, 18:12
dereckson retitled this revision from WIP: Payload full test to Payload full test, with a blackhole broker.Jan 9 2016, 18:13
dereckson updated this object.
dereckson edited edge metadata.
This revision was automatically updated to reflect the committed changes.

We need to mock the broker.

Code to mock
Broker::setExchangeTarget($this->target)
    ->routeTo($this->routingKey)
    ->sendMessage($this->message);
Mock proposal
$mock = Mockery('Keruald\Broker\AMQPBroker');

$mock->shouldReceive('setExchangeTarget'); // TODO: return $this, not null
$mock->shouldReceive('routeTo');
$mock->shouldReceive('sendMessage');

$this->app->instance('broker', $mock);

Reference: http://docs.mockery.io/en/latest/reference/demeter_chains.html

For reference, the following method mocks correctly the broker:

Working mock code
$mock = Mockery::mock('Keruald\Broker\Broker');
$mock->shouldReceive('connect');
$mock->shouldReceive('setExchangeTarget->routeTo->sendMessage');

$this->app->instance('broker', $mock);