Page MenuHomeDevCentral

Payload full test, with a blackhole broker
ClosedPublic

Authored by dereckson on Jan 9 2016, 05:33.
Referenced Files
Unknown Object (File)
Wed, Nov 13, 07:55
Unknown Object (File)
Wed, Nov 13, 07:10
Unknown Object (File)
Sun, Nov 10, 08:42
Unknown Object (File)
Sun, Nov 10, 08:41
Unknown Object (File)
Mon, Nov 4, 07:23
Unknown Object (File)
Mon, Oct 28, 20:07
Unknown Object (File)
Mon, Oct 21, 18:15
Unknown Object (File)
Mon, Oct 21, 11: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);