-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Testing): Fix MakeExpectationCommand with union returns in assert…
… class - Add ablity to re-generate stub files for the expectation command tests
- Loading branch information
Showing
12 changed files
with
365 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
37 changes: 37 additions & 0 deletions
37
tests/Feature/Testing/Commands/MakeExpectationCommand/TestReturnUnionActionContract.php
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
use ArrayAccess; | ||
use Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants; | ||
use const DIRECTORY_SEPARATOR; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Enumerable; | ||
use LaraStrict\Cache\Constants\CacheExpirations; | ||
use LaraStrict\Enums\EnvironmentType; | ||
use LaraStrict\Testing\Laravel\TestingApplication; | ||
|
||
interface TestReturnUnionActionContract | ||
{ | ||
public function execute( | ||
int $int, | ||
string $string, | ||
$noTypeHint, | ||
EnvironmentType $type, | ||
TestingApplication $testingApplication, | ||
string|int $multi, | ||
string|int|null $multiNull, | ||
string|int|null $multiNullDefault = 'test', | ||
?string $optional = null, | ||
string $optionalString = 'test', | ||
string $constant = DIRECTORY_SEPARATOR, | ||
int $constantClass = CacheExpirations::HalfDay, | ||
EnvironmentType $enumDefault = EnvironmentType::Testing, | ||
$noTypeHintDefault = null, | ||
string $customConstants = Constants\CustomConstants::TEST, | ||
TestingApplication $object = new TestingApplication(), | ||
ArrayAccess&Enumerable $intersectionType = new Collection() | ||
): string|int|null|TestingApplication; | ||
} |
60 changes: 60 additions & 0 deletions
60
...ture/Testing/Commands/MakeExpectationCommand/TestReturnUnionActionContractAssert.php.stub
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @extends \LaraStrict\Testing\AbstractExpectationCallMap<\Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\TestReturnUnionActionContractExpectation> | ||
*/ | ||
class TestReturnUnionActionContractAssert extends \LaraStrict\Testing\AbstractExpectationCallMap implements TestReturnUnionActionContract | ||
{ | ||
function execute( | ||
int $int, | ||
string $string, | ||
$noTypeHint, | ||
\LaraStrict\Enums\EnvironmentType $type, | ||
\LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
string|int $multi, | ||
string|int|null $multiNull, | ||
string|int|null $multiNullDefault = 'test', | ||
string $optional = null, | ||
string $optionalString = 'test', | ||
string $constant = DIRECTORY_SEPARATOR, | ||
int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
\LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
$noTypeHintDefault = null, | ||
string $customConstants = Constants\CustomConstants::TEST, | ||
\LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
\ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
): \LaraStrict\Testing\Laravel\TestingApplication|string|int|null { | ||
$expectation = $this->getExpectation(); | ||
$message = $this->getDebugMessage(); | ||
|
||
Assert::assertEquals($expectation->int, $int, $message); | ||
Assert::assertEquals($expectation->string, $string, $message); | ||
Assert::assertEquals($expectation->noTypeHint, $noTypeHint, $message); | ||
Assert::assertEquals($expectation->type, $type, $message); | ||
Assert::assertEquals($expectation->testingApplication, $testingApplication, $message); | ||
Assert::assertEquals($expectation->multi, $multi, $message); | ||
Assert::assertEquals($expectation->multiNull, $multiNull, $message); | ||
Assert::assertEquals($expectation->multiNullDefault, $multiNullDefault, $message); | ||
Assert::assertEquals($expectation->optional, $optional, $message); | ||
Assert::assertEquals($expectation->optionalString, $optionalString, $message); | ||
Assert::assertEquals($expectation->constant, $constant, $message); | ||
Assert::assertEquals($expectation->constantClass, $constantClass, $message); | ||
Assert::assertEquals($expectation->enumDefault, $enumDefault, $message); | ||
Assert::assertEquals($expectation->noTypeHintDefault, $noTypeHintDefault, $message); | ||
Assert::assertEquals($expectation->customConstants, $customConstants, $message); | ||
Assert::assertEquals($expectation->object, $object, $message); | ||
Assert::assertEquals($expectation->intersectionType, $intersectionType, $message); | ||
|
||
if (is_callable($expectation->hook)) { | ||
call_user_func($expectation->hook, $int, $string, $noTypeHint, $type, $testingApplication, $multi, $multiNull, $multiNullDefault, $optional, $optionalString, $constant, $constantClass, $enumDefault, $noTypeHintDefault, $customConstants, $object, $intersectionType, $expectation); | ||
} | ||
|
||
return $expectation->return; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...Testing/Commands/MakeExpectationCommand/TestReturnUnionActionContractExpectation.php.stub
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
final class TestReturnUnionActionContractExpectation | ||
{ | ||
/** | ||
* @param \Closure(int,string,mixed,\LaraStrict\Enums\EnvironmentType,\LaraStrict\Testing\Laravel\TestingApplication,string|int,string|int|null,string|int|null,string,string,string,int,\LaraStrict\Enums\EnvironmentType,mixed,string,\LaraStrict\Testing\Laravel\TestingApplication,ArrayAccess&Illuminate\Support\Enumerable,self):void|null $hook | ||
*/ | ||
public function __construct( | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication|string|int|null $return, | ||
public readonly int $int, | ||
public readonly string $string, | ||
public readonly mixed $noTypeHint, | ||
public readonly \LaraStrict\Enums\EnvironmentType $type, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
public readonly string|int $multi, | ||
public readonly string|int|null $multiNull, | ||
public readonly string|int|null $multiNullDefault = 'test', | ||
public readonly ?string $optional = null, | ||
public readonly string $optionalString = 'test', | ||
public readonly string $constant = \DIRECTORY_SEPARATOR, | ||
public readonly int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
public readonly \LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
public readonly mixed $noTypeHintDefault = null, | ||
public readonly string $customConstants = \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants\CustomConstants::TEST, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
public readonly \ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
public readonly ?\Closure $hook = null, | ||
) { | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../Testing/Commands/MakeExpectationCommand/one.TestReturnUnionActionContractAssert.php.stub
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @extends \LaraStrict\Testing\AbstractExpectationCallMap<\App\Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\TestReturnUnionActionContractExpectation> | ||
*/ | ||
class TestReturnUnionActionContractAssert extends \LaraStrict\Testing\AbstractExpectationCallMap implements \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\TestReturnUnionActionContract | ||
{ | ||
function execute( | ||
int $int, | ||
string $string, | ||
$noTypeHint, | ||
\LaraStrict\Enums\EnvironmentType $type, | ||
\LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
string|int $multi, | ||
string|int|null $multiNull, | ||
string|int|null $multiNullDefault = 'test', | ||
string $optional = null, | ||
string $optionalString = 'test', | ||
string $constant = DIRECTORY_SEPARATOR, | ||
int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
\LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
$noTypeHintDefault = null, | ||
string $customConstants = \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants\CustomConstants::TEST, | ||
\LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
\ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
): \LaraStrict\Testing\Laravel\TestingApplication|string|int|null { | ||
$expectation = $this->getExpectation(); | ||
$message = $this->getDebugMessage(); | ||
|
||
Assert::assertEquals($expectation->int, $int, $message); | ||
Assert::assertEquals($expectation->string, $string, $message); | ||
Assert::assertEquals($expectation->noTypeHint, $noTypeHint, $message); | ||
Assert::assertEquals($expectation->type, $type, $message); | ||
Assert::assertEquals($expectation->testingApplication, $testingApplication, $message); | ||
Assert::assertEquals($expectation->multi, $multi, $message); | ||
Assert::assertEquals($expectation->multiNull, $multiNull, $message); | ||
Assert::assertEquals($expectation->multiNullDefault, $multiNullDefault, $message); | ||
Assert::assertEquals($expectation->optional, $optional, $message); | ||
Assert::assertEquals($expectation->optionalString, $optionalString, $message); | ||
Assert::assertEquals($expectation->constant, $constant, $message); | ||
Assert::assertEquals($expectation->constantClass, $constantClass, $message); | ||
Assert::assertEquals($expectation->enumDefault, $enumDefault, $message); | ||
Assert::assertEquals($expectation->noTypeHintDefault, $noTypeHintDefault, $message); | ||
Assert::assertEquals($expectation->customConstants, $customConstants, $message); | ||
Assert::assertEquals($expectation->object, $object, $message); | ||
Assert::assertEquals($expectation->intersectionType, $intersectionType, $message); | ||
|
||
if (is_callable($expectation->hook)) { | ||
call_user_func($expectation->hook, $int, $string, $noTypeHint, $type, $testingApplication, $multi, $multiNull, $multiNullDefault, $optional, $optionalString, $constant, $constantClass, $enumDefault, $noTypeHintDefault, $customConstants, $object, $intersectionType, $expectation); | ||
} | ||
|
||
return $expectation->return; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ing/Commands/MakeExpectationCommand/one.TestReturnUnionActionContractExpectation.php.stub
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
final class TestReturnUnionActionContractExpectation | ||
{ | ||
/** | ||
* @param \Closure(int,string,mixed,\LaraStrict\Enums\EnvironmentType,\LaraStrict\Testing\Laravel\TestingApplication,string|int,string|int|null,string|int|null,string,string,string,int,\LaraStrict\Enums\EnvironmentType,mixed,string,\LaraStrict\Testing\Laravel\TestingApplication,ArrayAccess&Illuminate\Support\Enumerable,self):void|null $hook | ||
*/ | ||
public function __construct( | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication|string|int|null $return, | ||
public readonly int $int, | ||
public readonly string $string, | ||
public readonly mixed $noTypeHint, | ||
public readonly \LaraStrict\Enums\EnvironmentType $type, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
public readonly string|int $multi, | ||
public readonly string|int|null $multiNull, | ||
public readonly string|int|null $multiNullDefault = 'test', | ||
public readonly ?string $optional = null, | ||
public readonly string $optionalString = 'test', | ||
public readonly string $constant = \DIRECTORY_SEPARATOR, | ||
public readonly int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
public readonly \LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
public readonly mixed $noTypeHintDefault = null, | ||
public readonly string $customConstants = \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants\CustomConstants::TEST, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
public readonly \ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
public readonly ?\Closure $hook = null, | ||
) { | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../Testing/Commands/MakeExpectationCommand/two.TestReturnUnionActionContractAssert.php.stub
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Integration\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @extends \LaraStrict\Testing\AbstractExpectationCallMap<\App\Integration\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\TestReturnUnionActionContractExpectation> | ||
*/ | ||
class TestReturnUnionActionContractAssert extends \LaraStrict\Testing\AbstractExpectationCallMap implements \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\TestReturnUnionActionContract | ||
{ | ||
function execute( | ||
int $int, | ||
string $string, | ||
$noTypeHint, | ||
\LaraStrict\Enums\EnvironmentType $type, | ||
\LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
string|int $multi, | ||
string|int|null $multiNull, | ||
string|int|null $multiNullDefault = 'test', | ||
string $optional = null, | ||
string $optionalString = 'test', | ||
string $constant = DIRECTORY_SEPARATOR, | ||
int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
\LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
$noTypeHintDefault = null, | ||
string $customConstants = \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants\CustomConstants::TEST, | ||
\LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
\ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
): \LaraStrict\Testing\Laravel\TestingApplication|string|int|null { | ||
$expectation = $this->getExpectation(); | ||
$message = $this->getDebugMessage(); | ||
|
||
Assert::assertEquals($expectation->int, $int, $message); | ||
Assert::assertEquals($expectation->string, $string, $message); | ||
Assert::assertEquals($expectation->noTypeHint, $noTypeHint, $message); | ||
Assert::assertEquals($expectation->type, $type, $message); | ||
Assert::assertEquals($expectation->testingApplication, $testingApplication, $message); | ||
Assert::assertEquals($expectation->multi, $multi, $message); | ||
Assert::assertEquals($expectation->multiNull, $multiNull, $message); | ||
Assert::assertEquals($expectation->multiNullDefault, $multiNullDefault, $message); | ||
Assert::assertEquals($expectation->optional, $optional, $message); | ||
Assert::assertEquals($expectation->optionalString, $optionalString, $message); | ||
Assert::assertEquals($expectation->constant, $constant, $message); | ||
Assert::assertEquals($expectation->constantClass, $constantClass, $message); | ||
Assert::assertEquals($expectation->enumDefault, $enumDefault, $message); | ||
Assert::assertEquals($expectation->noTypeHintDefault, $noTypeHintDefault, $message); | ||
Assert::assertEquals($expectation->customConstants, $customConstants, $message); | ||
Assert::assertEquals($expectation->object, $object, $message); | ||
Assert::assertEquals($expectation->intersectionType, $intersectionType, $message); | ||
|
||
if (is_callable($expectation->hook)) { | ||
call_user_func($expectation->hook, $int, $string, $noTypeHint, $type, $testingApplication, $multi, $multiNull, $multiNullDefault, $optional, $optionalString, $constant, $constantClass, $enumDefault, $noTypeHintDefault, $customConstants, $object, $intersectionType, $expectation); | ||
} | ||
|
||
return $expectation->return; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ing/Commands/MakeExpectationCommand/two.TestReturnUnionActionContractExpectation.php.stub
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Integration\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand; | ||
|
||
final class TestReturnUnionActionContractExpectation | ||
{ | ||
/** | ||
* @param \Closure(int,string,mixed,\LaraStrict\Enums\EnvironmentType,\LaraStrict\Testing\Laravel\TestingApplication,string|int,string|int|null,string|int|null,string,string,string,int,\LaraStrict\Enums\EnvironmentType,mixed,string,\LaraStrict\Testing\Laravel\TestingApplication,ArrayAccess&Illuminate\Support\Enumerable,self):void|null $hook | ||
*/ | ||
public function __construct( | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication|string|int|null $return, | ||
public readonly int $int, | ||
public readonly string $string, | ||
public readonly mixed $noTypeHint, | ||
public readonly \LaraStrict\Enums\EnvironmentType $type, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $testingApplication, | ||
public readonly string|int $multi, | ||
public readonly string|int|null $multiNull, | ||
public readonly string|int|null $multiNullDefault = 'test', | ||
public readonly ?string $optional = null, | ||
public readonly string $optionalString = 'test', | ||
public readonly string $constant = \DIRECTORY_SEPARATOR, | ||
public readonly int $constantClass = \LaraStrict\Cache\Constants\CacheExpirations::HalfDay, | ||
public readonly \LaraStrict\Enums\EnvironmentType $enumDefault = \LaraStrict\Enums\EnvironmentType::Testing, | ||
public readonly mixed $noTypeHintDefault = null, | ||
public readonly string $customConstants = \Tests\LaraStrict\Feature\Testing\Commands\MakeExpectationCommand\Constants\CustomConstants::TEST, | ||
public readonly \LaraStrict\Testing\Laravel\TestingApplication $object = new \LaraStrict\Testing\Laravel\TestingApplication(/* unknown */), | ||
public readonly \ArrayAccess&\Illuminate\Support\Enumerable $intersectionType = new \Illuminate\Support\Collection(/* unknown */), | ||
public readonly ?\Closure $hook = null, | ||
) { | ||
} | ||
} |
Oops, something went wrong.