Skip to content

Commit

Permalink
Merge pull request #163 from RonasIT/145-fix-bug-with-empty-arguments
Browse files Browse the repository at this point in the history
#145: Fix bug with empty arguments
  • Loading branch information
DenTray authored Dec 12, 2024
2 parents c5a92fd + d72fcea commit d4a3681
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/MockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function mockClass(string $class, array $callChain, bool $disableConstruc
$callIndex = $this->getInvocationCount($matcher) - 1;
$expectedCall = $calls[$callIndex];

$expectedArguments = Arr::get($expectedCall, 'arguments');
$expectedArguments = Arr::get($expectedCall, 'arguments', []);

$this->assertArguments(
$args,
Expand Down Expand Up @@ -107,7 +107,7 @@ public function mockNativeFunction(string $namespace, array $callChain)
$callIndex = $this->getInvocationCount($matcher) - 1;
$expectedCall = $calls[$callIndex];

$expectedArguments = Arr::get($expectedCall, 'arguments');
$expectedArguments = Arr::get($expectedCall, 'arguments', []);

$this->assertArguments(
$args,
Expand Down
2 changes: 2 additions & 0 deletions tests/MockTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function testMockWithDifferentFunction()
$this->functionCall('is_array', [123]),
$this->functionCall('rand', [6, 10], 7),
$this->functionCall('uniqid', [], '0987654321'),
$this->functionCall(name: 'uniqid', result: '0987654321'),
$this->functionCall('array_slice', [[1, 2, 3, 4, 5], 2, 2], [3, 4]),
$this->functionCall('array_slice', [[1, 2, 3, 4, 5], 2], [3, 4, 5]),
]);
Expand All @@ -55,6 +56,7 @@ public function testMockWithDifferentFunction()
$this->assertTrue(is_array(123));
$this->assertEquals(7, rand(6, 10));
$this->assertEquals('0987654321', uniqid());
$this->assertEquals('0987654321', uniqid());
$this->assertEquals([3, 4], array_slice([1, 2, 3, 4, 5], 2, 2));
$this->assertEquals([3, 4, 5], array_slice([1, 2, 3, 4, 5], 2));
}
Expand Down

0 comments on commit d4a3681

Please sign in to comment.