Page MenuHomeDevCentral

Payload full test, with a blackhole broker
ClosedPublic

Authored by dereckson on Jan 9 2016, 05:33.
Referenced Files
F3630543: D197.id.diff
Sun, Oct 6, 08:09
F3630433: D197.diff
Sun, Oct 6, 07:34
F3630391: D197.diff
Sun, Oct 6, 07:18
Unknown Object (File)
Sat, Oct 5, 05:39
Unknown Object (File)
Sat, Oct 5, 05:26
Unknown Object (File)
Thu, Oct 3, 13:42
Unknown Object (File)
Wed, Oct 2, 07:48
Unknown Object (File)
Wed, Oct 2, 07:47
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
No Lint Coverage
Unit
Tests Passed
Branch
arcpatch-D197
Build Status
Buildable 258
Build 258: arc lint + arc unit

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);