Skip to content

Commit

Permalink
[tests] Add test for CallableContextProcessor
Browse files Browse the repository at this point in the history
Assert that string functions don't get called only closures

Issue: MOYA-1244
  • Loading branch information
Marrikulus committed Dec 20, 2023
1 parent a97aff2 commit 4c6cf69
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Processor/CallableContextProcessorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php declare(strict_types=1);

namespace Stefna\Logger\Processor;

use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;

function testingFunction()
{
print("should not print this");
}

final class CallableContextProcessorTest extends TestCase
{
public function testCallableContextProcessorDoesNotCallFunctionStrings()
{
$stringFunction = 'Stefna\Logger\Processor\testingFunction';

$this->expectOutputString("");
$processor = new CallableContextProcessor();
$processor([
'context' => [
'valueShouldNotBeCalled' => $stringFunction,
],
]);
}

public function testCallableContextProcessorCallsClosures()
{
$this->expectOutputString("should print this");
$processor = new CallableContextProcessor();
$processor([
'context' => [
'valueShouldNotBeCalled' => function () {
print("should print this");
},
],
]);
}
}

0 comments on commit 4c6cf69

Please sign in to comment.