blob: e36a8de3daab07f5e3d16d5bbe07209d005f3bfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
namespace Jaeger\Tests;
use Jaeger\Scope;
use Jaeger\ScopeManager;
use Jaeger\Span;
use PHPUnit\Framework\TestCase;
class ScopeTest extends TestCase
{
/**
* @var ScopeManager|\PHPUnit\Framework\MockObject\MockObject
*/
private $scopeManager;
/**
* @var Span|\PHPUnit\Framework\MockObject\MockObject
*/
private $span;
function setUp(): void
{
$this->scopeManager = $this->createMock(ScopeManager::class);
$this->span = $this->createMock(Span::class);
}
function testCloseDoNotFinishSpanOnClose()
{
$scope = new Scope($this->scopeManager, $this->span, false);
$this->scopeManager->method('getActive')->willReturn($scope);
$this->scopeManager->expects($this->once())->method('getActive');
$this->span->expects($this->never())->method('finish');
$this->scopeManager->expects($this->once())->method('setActive');
$scope->close();
}
function testCloseFinishSpanOnClose()
{
$scope = new Scope($this->scopeManager, $this->span, true);
$this->scopeManager->method('getActive')->willReturn($scope);
$this->scopeManager->expects($this->once())->method('getActive');
$this->span->expects($this->once())->method('finish');
$this->scopeManager->expects($this->once())->method('setActive');
$scope->close();
}
function testGetSpan()
{
$scope = new Scope($this->scopeManager, $this->span, false);
$this->assertEquals($this->span, $scope->getSpan());
}
}
|