Skip to content

Commit 61b086b

Browse files
committed
Improved tests for few uncovered places
1 parent dcac7e5 commit 61b086b

4 files changed

Lines changed: 94 additions & 1 deletion

File tree

infection.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"perMutator": "build/per-mutator.md"
1212
},
1313
"tmpDir": "/tmp/infection",
14-
"minMsi": 90,
14+
"minMsi": 95,
1515
"minCoveredMsi": 95,
1616
"mutators": {
1717
"@default": true,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Graphpinator\Parser\Tests\Unit\Exception;
6+
7+
use Graphpinator\Common\Location;
8+
use Graphpinator\Parser\Exception\EmptyRequest;
9+
use PHPUnit\Framework\TestCase;
10+
11+
final class ParserErrorTest extends TestCase
12+
{
13+
public function testIsOutputable() : void
14+
{
15+
$exception = new EmptyRequest(new Location(1, 1));
16+
17+
self::assertTrue($exception->isOutputable());
18+
}
19+
20+
public function testLocationIsSet() : void
21+
{
22+
$location = new Location(5, 10);
23+
$exception = new EmptyRequest($location);
24+
25+
self::assertSame($location, $exception->getLocation());
26+
}
27+
}

tests/Unit/ParserTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,4 +994,15 @@ public function testInvalid(string $input, string $exception, ?string $message =
994994

995995
Parser::parseString($input);
996996
}
997+
998+
public function testEmptyRequestLocation() : void
999+
{
1000+
try {
1001+
Parser::parseString('');
1002+
self::fail('Expected EmptyRequest exception');
1003+
} catch (EmptyRequest $e) {
1004+
self::assertSame(1, $e->getLocation()->getLine());
1005+
self::assertSame(1, $e->getLocation()->getColumn());
1006+
}
1007+
}
9971008
}

tests/Unit/TypeRef/TypeRefTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Graphpinator\Parser\Tests\Unit\TypeRef;
6+
7+
use Graphpinator\Parser\TypeRef\ListTypeRef;
8+
use Graphpinator\Parser\TypeRef\NamedTypeRef;
9+
use Graphpinator\Parser\TypeRef\NotNullRef;
10+
use PHPUnit\Framework\TestCase;
11+
12+
final class TypeRefTest extends TestCase
13+
{
14+
public function testNamedTypeRefPrint() : void
15+
{
16+
$typeRef = new NamedTypeRef('String');
17+
18+
self::assertSame('String', $typeRef->print());
19+
}
20+
21+
public function testNotNullRefPrint() : void
22+
{
23+
$innerRef = new NamedTypeRef('Int');
24+
$typeRef = new NotNullRef($innerRef);
25+
26+
self::assertSame('Int!', $typeRef->print());
27+
}
28+
29+
public function testListTypeRefPrint() : void
30+
{
31+
$innerRef = new NamedTypeRef('String');
32+
$typeRef = new ListTypeRef($innerRef);
33+
34+
self::assertSame('[String]', $typeRef->print());
35+
}
36+
37+
public function testComplexTypeRefPrint() : void
38+
{
39+
$namedRef = new NamedTypeRef('Int');
40+
$notNullRef = new NotNullRef($namedRef);
41+
$listRef = new ListTypeRef($notNullRef);
42+
$outerNotNullRef = new NotNullRef($listRef);
43+
44+
self::assertSame('[Int!]!', $outerNotNullRef->print());
45+
}
46+
47+
public function testNestedListTypeRefPrint() : void
48+
{
49+
$namedRef = new NamedTypeRef('String');
50+
$innerListRef = new ListTypeRef($namedRef);
51+
$outerListRef = new ListTypeRef($innerListRef);
52+
53+
self::assertSame('[[String]]', $outerListRef->print());
54+
}
55+
}

0 commit comments

Comments
 (0)