From 7b72b38fd9533b3daedd5af17eeab3a6b14a3e5e Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Sat, 10 Jun 2017 01:55:41 -0700 Subject: [PATCH] Assert that references array is equal, not a subset, and update expected.json files (#395) --- tests/Validation/ValidationTest.php | 7 +------ .../cases/WithReturnTypehints.php.expected.json | 6 ++++++ tests/Validation/cases/exceptions1.php.expected.json | 6 +++++- tests/Validation/cases/functionUse2.php.expected.json | 3 +++ .../cases/magicConstantsShouldBeGlobal.php.expected.json | 9 ++++++++- tests/Validation/cases/magicConsts.php.expected.json | 6 +++++- tests/Validation/cases/memberAccess5.php.expected.json | 6 +++++- tests/Validation/cases/namespaces8.php.expected.json | 6 ++++++ tests/Validation/cases/self4.php.expected.json | 6 ++++++ 9 files changed, 45 insertions(+), 10 deletions(-) diff --git a/tests/Validation/ValidationTest.php b/tests/Validation/ValidationTest.php index 649e947..8fa7442 100644 --- a/tests/Validation/ValidationTest.php +++ b/tests/Validation/ValidationTest.php @@ -64,12 +64,7 @@ class ValidationTest extends TestCase try { $this->assertEquals($expectedValues['definitions'], $actualValues['definitions']); - - try { - $this->assertArraySubset((array)$expectedValues['references'], (array)$actualValues['references'], false, 'references don\'t match.'); - } catch (\Throwable $e) { - $this->assertEquals((array)$expectedValues['references'], (array)$actualValues['references'], 'references don\'t match.'); - } + $this->assertEquals((array)$expectedValues['references'], (array)$actualValues['references'], 'references don\'t match.'); } catch (\Throwable $e) { $outputFile = getExpectedValuesFile($testCaseFile); file_put_contents($outputFile, json_encode($actualValues, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); diff --git a/tests/Validation/cases/WithReturnTypehints.php.expected.json b/tests/Validation/cases/WithReturnTypehints.php.expected.json index 50801d9..166786a 100644 --- a/tests/Validation/cases/WithReturnTypehints.php.expected.json +++ b/tests/Validation/cases/WithReturnTypehints.php.expected.json @@ -6,6 +6,12 @@ "self": [ "./WithReturnTypehints.php" ], + "Fixtures\\Prophecy\\__CLASS__": [ + "./WithReturnTypehints.php" + ], + "__CLASS__": [ + "./WithReturnTypehints.php" + ], "parent": [ "./WithReturnTypehints.php" ] diff --git a/tests/Validation/cases/exceptions1.php.expected.json b/tests/Validation/cases/exceptions1.php.expected.json index d74deff..4a13354 100644 --- a/tests/Validation/cases/exceptions1.php.expected.json +++ b/tests/Validation/cases/exceptions1.php.expected.json @@ -1,5 +1,9 @@ { - "references": [], + "references": { + "MyNamespace\\Exception": [ + "./exceptions1.php" + ] + }, "definitions": { "MyNamespace": { "fqn": "MyNamespace", diff --git a/tests/Validation/cases/functionUse2.php.expected.json b/tests/Validation/cases/functionUse2.php.expected.json index f3609bd..320cc41 100644 --- a/tests/Validation/cases/functionUse2.php.expected.json +++ b/tests/Validation/cases/functionUse2.php.expected.json @@ -3,6 +3,9 @@ "LanguageServer": [ "./functionUse2.php" ], + "LanguageServer\\pathToUri()": [ + "./functionUse2.php" + ], "LanguageServer\\timeout()": [ "./functionUse2.php" ] diff --git a/tests/Validation/cases/magicConstantsShouldBeGlobal.php.expected.json b/tests/Validation/cases/magicConstantsShouldBeGlobal.php.expected.json index 36a2942..b61333f 100644 --- a/tests/Validation/cases/magicConstantsShouldBeGlobal.php.expected.json +++ b/tests/Validation/cases/magicConstantsShouldBeGlobal.php.expected.json @@ -1,5 +1,12 @@ { - "references": [], + "references": { + "B\\__FILE__": [ + "./magicConstantsShouldBeGlobal.php" + ], + "__FILE__": [ + "./magicConstantsShouldBeGlobal.php" + ] + }, "definitions": { "B": { "fqn": "B", diff --git a/tests/Validation/cases/magicConsts.php.expected.json b/tests/Validation/cases/magicConsts.php.expected.json index c017d49..6641af3 100644 --- a/tests/Validation/cases/magicConsts.php.expected.json +++ b/tests/Validation/cases/magicConsts.php.expected.json @@ -1,5 +1,9 @@ { - "references": [], + "references": { + "__CLASS__": [ + "./magicConsts.php" + ] + }, "definitions": { "A": { "fqn": "A", diff --git a/tests/Validation/cases/memberAccess5.php.expected.json b/tests/Validation/cases/memberAccess5.php.expected.json index ae2b4ac..5023cd6 100644 --- a/tests/Validation/cases/memberAccess5.php.expected.json +++ b/tests/Validation/cases/memberAccess5.php.expected.json @@ -1,5 +1,9 @@ { - "references": [], + "references": { + "MyNamespace\\ParseErrorsTest->args": [ + "./memberAccess5.php" + ] + }, "definitions": { "MyNamespace": { "fqn": "MyNamespace", diff --git a/tests/Validation/cases/namespaces8.php.expected.json b/tests/Validation/cases/namespaces8.php.expected.json index 2fbd1fb..7a77f7c 100644 --- a/tests/Validation/cases/namespaces8.php.expected.json +++ b/tests/Validation/cases/namespaces8.php.expected.json @@ -2,6 +2,12 @@ "references": { "LanguageServer": [ "./namespaces8.php" + ], + "LanguageServer\\pathToUri()": [ + "./namespaces8.php" + ], + "LanguageServer\\uriToPath()": [ + "./namespaces8.php" ] }, "definitions": { diff --git a/tests/Validation/cases/self4.php.expected.json b/tests/Validation/cases/self4.php.expected.json index 5fac53f..9a01912 100644 --- a/tests/Validation/cases/self4.php.expected.json +++ b/tests/Validation/cases/self4.php.expected.json @@ -6,6 +6,12 @@ "MyNamespace\\A->addTestFile()": [ "./self4.php" ], + "MyNamespace\\__DIR__": [ + "./self4.php" + ], + "__DIR__": [ + "./self4.php" + ], "MyNamespace\\DS": [ "./self4.php" ],