Skip to content

Commit

Permalink
[BUG]fix saga enableConcurrent without addBranchOrder bug
Browse files Browse the repository at this point in the history
[BUG]fix saga enableConcurrent without addBranchOrder bug
  • Loading branch information
PandaLIU-1111 authored Mar 31, 2023
2 parents 21e308a + 2cf49e8 commit 1b60067
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Saga.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*
* @license https://github.com/dtm-php/dtm-client/blob/master/LICENSE
*/

namespace DtmClient;

use DtmClient\Api\ApiInterface;
Expand Down Expand Up @@ -79,7 +80,7 @@ public function addConcurrentContext()
if ($this->concurrent) {
TransContext::setCustomData(json_encode([
'concurrent' => $this->concurrent,
'orders' => $this->orders,
'orders' => $this->orders ?: null,
]));
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Cases/SagaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ public function testEnableConcurrent()
$this->assertTrue($concurrent);
}

public function testEnableConcurrentWithoutAddBranchOrders()
{
$api = \Mockery::mock(ApiInterface::class);

$saga = new Saga($api);
$saga->enableConcurrent();

$ordersProperty = new \ReflectionProperty($saga, 'orders');
$ordersProperty->setAccessible(true);
$orders = $ordersProperty->getValue($saga);
$this->assertSame(null, $orders ?: null);
}

public function testSubmit()
{
$api = \Mockery::mock(ApiInterface::class);
Expand Down

0 comments on commit 1b60067

Please sign in to comment.