-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check the class to which constructor args are passed
Since IDEA may create a paradox with `$var = new SomeCls(); if ($var instanceof SomeOtherClass) {...}` causing keys to resolve as if args passed to `SomeCls` were passed to `SomeOtherCls`
- Loading branch information
Showing
3 changed files
with
59 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
<?php | ||
namespace DeepTest; | ||
|
||
use Lib\ParamValidation\DictP; | ||
use Lib\ParamValidation\ListP; | ||
use Lib\ParamValidation\StringP; | ||
|
||
/** | ||
* unlike UnitTest.php, this test not just checks that actual result has _at least_ | ||
* such keys, but it tests that it has _exactly_ such keys, without extras | ||
*/ | ||
class ExactKeysUnitTest | ||
{ | ||
private static function getPnrSchema() | ||
{ | ||
return new DictP([], [ | ||
'recordLocator' => new StringP([], []), | ||
'passengers' => new ListP([], ['elemType' => new DictP([], [ | ||
'lastName' => new StringP([], []), | ||
'firstName' => new StringP([], []), | ||
])]), | ||
'itinerary' => new ListP([], ['elemType' => new ListP([], [ | ||
'from' => new StringP([], []), | ||
'to' => new StringP([], []), | ||
'date' => new StringP([], []), | ||
])]), | ||
]); | ||
} | ||
|
||
/** @param $pnr = ParamUtil::sample(static::getPnrSchema()) */ | ||
// public static function provideParamValidation($pnr) | ||
// { | ||
// // should suggest: 'recordLocator', 'passengers', 'itinerary' | ||
// // should not suggest: 'elemType' | ||
// $pnr['']; | ||
// return [ | ||
// [$pnr, ['recordLocator', 'passengers', 'itinerary']], | ||
// ]; | ||
// } | ||
} | ||
<?php | ||
namespace DeepTest; | ||
|
||
use Lib\ParamValidation\DictP; | ||
use Lib\ParamValidation\ListP; | ||
use Lib\ParamValidation\StringP; | ||
|
||
/** | ||
* unlike UnitTest.php, this test not just checks that actual result has _at least_ | ||
* such keys, but it tests that it has _exactly_ such keys, without extras | ||
*/ | ||
class ExactKeysUnitTest | ||
{ | ||
private static function getPnrSchema() | ||
{ | ||
return new DictP([], [ | ||
'recordLocator' => new StringP([], ['pattern' => '/^[A-Z0-9]{6}$/']), | ||
'passengers' => new ListP([], ['elemType' => new DictP([], [ | ||
'lastName' => new StringP([], []), | ||
'firstName' => new StringP([], []), | ||
])]), | ||
'itinerary' => new ListP([], ['elemType' => new ListP([], [ | ||
'from' => new StringP([], []), | ||
'to' => new StringP([], []), | ||
'date' => new StringP([], []), | ||
])]), | ||
]); | ||
} | ||
|
||
/** @param $pnr = ParamUtil::sample(static::getPnrSchema()) */ | ||
public static function provideParamValidation($pnr) | ||
{ | ||
// should suggest: 'recordLocator', 'passengers', 'itinerary' | ||
// should not suggest: 'elemType' | ||
$pnr['']; | ||
return [ | ||
[$pnr, ['recordLocator', 'passengers', 'itinerary']], | ||
]; | ||
} | ||
} |