Skip to content

Commit 5bdba05

Browse files
committed
test: parse from file
1 parent c9511b0 commit 5bdba05

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

tests/CommentTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ public function testParse()
5959
$this->assertSame('/*value*/', $parsed['a//b']);
6060
}
6161

62+
public function testParseFromFile()
63+
{
64+
$parsed = Comment::parseFromFile(__DIR__ . '/composer.json', true);
65+
66+
$this->assertTrue(is_array($parsed));
67+
$this->assertSame('adhocore/json-comment', $parsed['name']);
68+
}
69+
6270
public function theTests()
6371
{
6472
return [

tests/composer.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "adhocore/json-comment",
3+
"description": "Lightweight JSON comment stripper library for PHP",
4+
"type":/* This is creepy comment */ "library",
5+
"keywords": [
6+
"json",
7+
"comment",
8+
// Single line comment, Notice the comma below:
9+
"strip-comment",
10+
],
11+
"license": "MIT",
12+
/*
13+
* This is multiline comment
14+
*/
15+
"authors": [
16+
{
17+
"name": "Jitendra Adhikari",
18+
"email": "[email protected]",
19+
},
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Ahc\\Json\\": "src/",
24+
},
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Ahc\\Json\\Test\\": "tests/",
29+
},
30+
},
31+
"require": {
32+
"php": ">=7.0",
33+
"ext-ctype": "*",
34+
},
35+
"require-dev": {
36+
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5",
37+
},
38+
"scripts": {
39+
"test": "phpunit",
40+
"echo": "echo '// This is not comment'",
41+
"test:cov": "phpunit --coverage-text --coverage-clover coverage.xml",
42+
},
43+
}

0 commit comments

Comments
 (0)