Skip to content

Commit

Permalink
Merge pull request #69 from advisors-excel-llc/feature/RecursionlessS…
Browse files Browse the repository at this point in the history
…treaming

No recursion allowed
  • Loading branch information
NickALafrance authored Mar 6, 2020
2 parents f66cfe9 + be5f24b commit 53804af
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 262 deletions.
18 changes: 14 additions & 4 deletions Tests/Bayeux/BayeuxClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ protected function setUp()

public function testStream()
{
if (getenv('AccountPushTopic') == '') {
$this->fail('Account push topic not named in .env.');
return;
}

$rand = rand(100, 1000);
$name = 'Test Account '.$rand;

Expand Down Expand Up @@ -73,11 +78,11 @@ function (ChannelInterface $channel, Message $message) use ($name, &$consumer) {

$this->client->getChannel(ChannelInterface::META_CONNECT)->subscribe($consumer);

$channel = $this->client->getChannel('/topic/Accounts');
$channel = $this->client->getChannel(getenv('AccountPushTopic'));
$channel->subscribe(
Consumer::create(
function (ChannelInterface $channel, Message $message) use ($name) {
$this->assertEquals("/topic/Accounts", $channel->getChannelId());
$this->assertEquals(getenv('AccountPushTopic'), $channel->getChannelId());
$data = $message->getData();
$this->assertNotNull($data);
$sobject = $data->getSobject();
Expand Down Expand Up @@ -111,6 +116,11 @@ function (ChannelInterface $channel, Message $message) use ($name) {

public function testCdc()
{
if (getenv('AccountChangeEvent') == '') {
$this->fail('Account push topic not named in .env.');
return;
}

$rand = rand(100, 1000);
$name = 'Test Account '.$rand;

Expand Down Expand Up @@ -139,11 +149,11 @@ function (ChannelInterface $channel, Message $message) use ($name, &$consumer) {

$this->client->getChannel(ChannelInterface::META_CONNECT)->subscribe($consumer);

$channel = $this->client->getChannel('/data/AccountChangeEvent');
$channel = $this->client->getChannel(getenv('AccountChangeEvent'));
$channel->subscribe(
Consumer::create(
function (ChannelInterface $channel, Message $message) use ($name) {
$this->assertEquals("/data/AccountChangeEvent", $channel->getChannelId());
$this->assertEquals(getenv('AccountChangeEvent'), $channel->getChannelId());
$data = $message->getData();
$this->assertNotNull($data);
$payload = $data->getPayload();
Expand Down
6 changes: 5 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
-->
<env name="SF_AUTH_CODE" value="AN_AUTH_CODE" />
<env name="SF_REDIRECT_URI" value="http://localhost" />

<!-- Whatever you named your push topic and change event topic in SF has to match the test, so name them here correctly so they match! -->
<env name="AccountPushTopic" value="" />
<env name="AccountChangeEvent" value="" />
</php>
<testsuites>
<testsuite name="Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
</phpunit>
</phpunit>
Loading

0 comments on commit 53804af

Please sign in to comment.