logfileco /
logfile-php
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Tests; |
||
| 4 | |||
| 5 | use PHPUnit\Framework\TestCase; |
||
| 6 | |||
| 7 | class FrameTest extends TestCase |
||
| 8 | { |
||
| 9 | public function testFilename() |
||
| 10 | { |
||
| 11 | $frame = new \Logfile\Frame; |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | $frame->setFile(__FILE__); |
||
| 14 | $this->assertEquals(__FILE__, $frame->getFile()); |
||
| 15 | $this->assertTrue($frame->hasFile()); |
||
| 16 | $this->assertEquals(__FILE__, $frame->getRelativeFilepath()); |
||
| 17 | } |
||
| 18 | |||
| 19 | public function testPathAndRelativeFilepath() |
||
| 20 | { |
||
| 21 | $frame = new \Logfile\Frame; |
||
| 22 | |||
| 23 | $frame->setFile(__FILE__); |
||
| 24 | $frame->setPath(__DIR__.'/../tests'); |
||
| 25 | $this->assertEquals(__DIR__ .'/', $frame->getPath()); |
||
| 26 | $this->assertTrue($frame->hasPath()); |
||
| 27 | $this->assertEquals(basename(__FILE__), $frame->getRelativeFilepath()); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function testLineNumber() |
||
| 31 | { |
||
| 32 | $frame = new \Logfile\Frame; |
||
| 33 | |||
| 34 | $frame->setLine(1); |
||
| 35 | $this->assertEquals(1, $frame->getLine()); |
||
| 36 | $this->assertTrue($frame->hasLine()); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function testCaller() |
||
| 40 | { |
||
| 41 | $frame = new \Logfile\Frame; |
||
| 42 | |||
| 43 | $frame->setCaller('foo'); |
||
| 44 | $this->assertEquals('foo', $frame->getCaller()); |
||
| 45 | $this->assertTrue($frame->hasCaller()); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function testArguments() |
||
| 49 | { |
||
| 50 | $frame = new \Logfile\Frame; |
||
| 51 | |||
| 52 | $frame->setArguments(['foo']); |
||
| 53 | $this->assertEquals(['param1'=> 'foo'], $frame->getArguments()); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function testManyArguments() |
||
| 57 | { |
||
| 58 | $frame = new \Logfile\Frame; |
||
| 59 | |||
| 60 | $frame->setArguments([range(1, 101)]); |
||
| 61 | $this->assertEquals(['param1'=> 'Array of length 101'], $frame->getArguments()); |
||
| 62 | } |
||
| 63 | |||
| 64 | public function testArgumentsTypes() |
||
| 65 | { |
||
| 66 | $frame = new \Logfile\Frame; |
||
| 67 | |||
| 68 | $frame->setArguments([['foo', 'bar']]); |
||
| 69 | $this->assertEquals(['param1'=> 'Array<string> of length 2'], $frame->getArguments()); |
||
| 70 | |||
| 71 | $frame->setArguments([[new \StdClass]]); |
||
| 72 | $this->assertEquals(['param1'=> 'Array<stdClass> of length 1'], $frame->getArguments()); |
||
| 73 | |||
| 74 | $frame->setArguments([[1, '2', false]]); |
||
| 75 | $this->assertEquals(['param1'=> 'Array<integer|string|boolean> of length 3'], $frame->getArguments()); |
||
| 76 | |||
| 77 | $frame->setArguments([[1, '2', false, null]]); |
||
| 78 | $this->assertEquals(['param1'=> 'Mixed Array of length 4'], $frame->getArguments()); |
||
| 79 | |||
| 80 | $frame->setArguments([true]); |
||
| 81 | $this->assertEquals(['param1'=> 'true'], $frame->getArguments()); |
||
| 82 | |||
| 83 | $frame->setArguments([false]); |
||
| 84 | $this->assertEquals(['param1'=> 'false'], $frame->getArguments()); |
||
| 85 | |||
| 86 | $frame->setArguments([null]); |
||
| 87 | $this->assertEquals(['param1'=> 'null'], $frame->getArguments()); |
||
| 88 | |||
| 89 | $frame->setArguments([1]); |
||
| 90 | $this->assertEquals(['param1'=> '1'], $frame->getArguments()); |
||
| 91 | |||
| 92 | $frame->setArguments([1.0]); |
||
| 93 | $this->assertEquals(['param1'=> '1.0'], $frame->getArguments()); |
||
| 94 | |||
| 95 | $frame->setArguments([new \StdClass]); |
||
| 96 | $this->assertEquals(['param1'=> 'Object stdClass'], $frame->getArguments()); |
||
| 97 | |||
| 98 | $frame->setArguments([stream_context_create()]); |
||
| 99 | $this->assertEquals(['param1'=> 'Resource stream-context'], $frame->getArguments()); |
||
| 100 | } |
||
| 101 | |||
| 102 | public function testContext() |
||
| 103 | { |
||
| 104 | $frame = new \Logfile\Frame; |
||
| 105 | $frame->setFile(__FILE__); |
||
| 106 | $frame->setLine(1); |
||
| 107 | $this->assertTrue($frame->hasContext()); |
||
| 108 | $this->assertTrue($frame->getContext() instanceof \Logfile\Context); |
||
|
0 ignored issues
–
show
The type
Logfile\Context was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 109 | } |
||
| 110 | |||
| 111 | public function testArray() |
||
| 112 | { |
||
| 113 | $frame = new \Logfile\Frame; |
||
| 114 | $frame->setFile(__FILE__); |
||
| 115 | $frame->setLine(1); |
||
| 116 | $frame->setCaller('foo'); |
||
| 117 | $this->assertTrue(is_array($frame->toArray())); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function testCreate() |
||
| 121 | { |
||
| 122 | $frame = \Logfile\Frame::create([ |
||
| 123 | 'file' => __FILE__, |
||
| 124 | 'line' => 1, |
||
| 125 | 'class' => 'stdClass', |
||
| 126 | 'type' => '->', |
||
| 127 | 'function' => '__construct' |
||
| 128 | ]); |
||
| 129 | $this->assertTrue($frame instanceof \Logfile\Frame); |
||
| 130 | |||
| 131 | $frame = \Logfile\Frame::create([ |
||
| 132 | 'file' => __FILE__, |
||
| 133 | 'line' => 1, |
||
| 134 | 'function' => 'isset', |
||
| 135 | 'args' => [true], |
||
| 136 | ]); |
||
| 137 | $this->assertTrue($frame instanceof \Logfile\Frame); |
||
| 138 | } |
||
| 139 | } |
||
| 140 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths