-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from sj-i/add-test-call-trace
add test for CallFrame
- Loading branch information
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\PhpProcessReader; | ||
|
||
use PhpProfiler\Lib\PhpInternals\Opcodes\OpcodeV70; | ||
use PhpProfiler\Lib\PhpInternals\Types\Zend\Opline; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CallFrameTest extends TestCase | ||
{ | ||
public function testGetFullyQualifiedFunctionName() | ||
{ | ||
$call_frame = new CallFrame( | ||
'class_name', | ||
'function_name', | ||
'file_name', | ||
null | ||
); | ||
$this->assertSame( | ||
'class_name::function_name', | ||
$call_frame->getFullyQualifiedFunctionName() | ||
); | ||
} | ||
|
||
public function testGetLineno() | ||
{ | ||
$call_frame = new CallFrame( | ||
'class_name', | ||
'function_name', | ||
'file_name', | ||
null | ||
); | ||
$this->assertSame( | ||
-1, | ||
$call_frame->getLineno() | ||
); | ||
|
||
$call_frame = new CallFrame( | ||
'class_name', | ||
'function_name', | ||
'file_name', | ||
new Opline( | ||
0, | ||
0, | ||
0, | ||
0, | ||
123, | ||
new OpcodeV70(0), | ||
0, | ||
0, | ||
0 | ||
) | ||
); | ||
$this->assertSame( | ||
123, | ||
$call_frame->getLineno() | ||
); | ||
} | ||
|
||
public function testGetOpcodeName() | ||
{ | ||
$call_frame = new CallFrame( | ||
'class_name', | ||
'function_name', | ||
'file_name', | ||
null | ||
); | ||
$this->assertSame( | ||
'', | ||
$call_frame->getOpcodeName() | ||
); | ||
|
||
$call_frame = new CallFrame( | ||
'class_name', | ||
'function_name', | ||
'file_name', | ||
new Opline( | ||
0, | ||
0, | ||
0, | ||
0, | ||
123, | ||
new OpcodeV70(OpcodeV70::ZEND_NOP), | ||
0, | ||
0, | ||
0 | ||
) | ||
); | ||
$this->assertSame( | ||
'ZEND_NOP', | ||
$call_frame->getOpcodeName() | ||
); | ||
} | ||
} |