Skip to content

Commit

Permalink
Complete the current test suite (#250)
Browse files Browse the repository at this point in the history
- Add to the specs the registered classes and functions recorded via the keys `'registered-classes'` and `'registered-functions'`. This should not change the current behaviour but makes it easier to test this part of the whitelisting feature.
- Add a check to ensure the keys used in `'meta'` or a spec definition are all valid
- Add the missing `'registered-functions'` where appropriate
- Moved the specs testing from `PhpScoperTest` to `PhpScoperSpecTest` to make it more readable
- Do not record the functions return types (which can be identifiers or names as well)
  • Loading branch information
theofidry authored Jul 24, 2018
2 parents 56adc81 + 6c172ad commit 1fd056d
Show file tree
Hide file tree
Showing 135 changed files with 752 additions and 225 deletions.
2 changes: 2 additions & 0 deletions specs/binary/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Some statements made directly in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class-FQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Different kind of whitelisted class constant calls in the global scope' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/class-const/global-scope-single-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class belonging to the global namespace' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with an aliased use statement' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with a use statement' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/class-const/global-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/class-const/namespace-scope-single-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class belonging to the global namespace or the current namespace' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with an aliased use statement' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with a use statement' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/class-const/namespace-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class-static-prop/global-scope-single-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class belonging to the global namespace' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with an aliased use statement' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with a use statement' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class-static-prop/global-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class-static-prop/namespace-scope-single-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class belonging to the global namespace or the current namespace' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with an aliased use statement' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class partially imported with a use statement' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class-static-prop/namespace-scope-two-level.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a namespaced class' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/anonymous.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
10 changes: 6 additions & 4 deletions specs/class/conditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down Expand Up @@ -62,9 +64,9 @@ class A
}

PHP
,
],

'Declaration in a namespace: prefix each namespace' => <<<'PHP'
'Declaration in a namespace' => <<<'PHP'
<?php
namespace Foo;
Expand All @@ -84,7 +86,7 @@ class A
}

PHP
],
,

'Declaration of a whitelisted class' => [
'whitelist' => ['Foo\A'],
Expand All @@ -108,7 +110,7 @@ class A
}

PHP
],
],

'Multiple declarations in different namespaces' => <<<'PHP'
<?php
Expand Down
2 changes: 2 additions & 0 deletions specs/class/final.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/regular-extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/regular.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/class/trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Declaration in the global namespace' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/const/const-declaration-with-global-whitelisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constants declaration in the global namespace' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/const/const-declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => false,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constants declaration in the global namespace' => [
Expand Down
2 changes: 2 additions & 0 deletions specs/const/global-scope-global-with-global-whitelisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call in the global namespace' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => false,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call imported with an aliased use statement' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => true,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call imported with a use statement' => <<<'PHP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => false,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call imported with a use statement' => <<<'PHP'
Expand Down
2 changes: 2 additions & 0 deletions specs/const/global-scope-global.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'whitelist' => [],
'whitelist-global-constants' => false,
'whitelist-global-functions' => true,
'registered-classes' => [],
'registered-functions' => [],
],

'Constant call in the global namespace' => <<<'PHP'
Expand Down
Loading

0 comments on commit 1fd056d

Please sign in to comment.