-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy tests from symplify/autowire-array-parameter (#3152)
- Loading branch information
1 parent
58069c3
commit 4e9214f
Showing
20 changed files
with
411 additions
and
4 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
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
53 changes: 53 additions & 0 deletions
53
tests/DependencyInjection/CompilerPass/AutowireArrayParameterCompilerPassTest.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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\ArrayShapeCollector; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\IterableCollector; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\SomeCollector; | ||
use Rector\Core\Tests\DependencyInjection\HttpKernel\AutowireArrayParameterHttpKernel; | ||
use Symplify\PackageBuilder\Testing\AbstractKernelTestCase; | ||
|
||
final class AutowireArrayParameterCompilerPassTest extends AbstractKernelTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
$this->bootKernel(AutowireArrayParameterHttpKernel::class); | ||
} | ||
|
||
public function test(): void | ||
{ | ||
/** @var SomeCollector $someCollector */ | ||
$someCollector = $this->getService(SomeCollector::class); | ||
$this->assertCount(3, $someCollector->getFirstCollected()); | ||
$this->assertCount(2, $someCollector->getSecondCollected()); | ||
|
||
$this->assertInstanceOf(FirstCollectedInterface::class, $someCollector->getFirstCollected()[0]); | ||
$this->assertInstanceOf(SecondCollectedInterface::class, $someCollector->getSecondCollected()[0]); | ||
} | ||
|
||
public function testArrayShape(): void | ||
{ | ||
$arrayShapeCollector = $this->getService(ArrayShapeCollector::class); | ||
$this->assertCount(3, $arrayShapeCollector->getFirstCollected()); | ||
$this->assertCount(2, $arrayShapeCollector->getSecondCollected()); | ||
|
||
$this->assertInstanceOf(FirstCollectedInterface::class, $arrayShapeCollector->getFirstCollected()[0]); | ||
$this->assertInstanceOf(SecondCollectedInterface::class, $arrayShapeCollector->getSecondCollected()[0]); | ||
} | ||
|
||
public function testIterable(): void | ||
{ | ||
$iterableCollector = $this->getService(IterableCollector::class); | ||
|
||
$this->assertCount(3, $iterableCollector->getFirstCollected()); | ||
$this->assertCount(2, $iterableCollector->getSecondCollected()); | ||
|
||
$this->assertInstanceOf(FirstCollectedInterface::class, $iterableCollector->getFirstCollected()[0]); | ||
$this->assertInstanceOf(SecondCollectedInterface::class, $iterableCollector->getSecondCollected()[0]); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/DependencyInjection/CompilerPass/Source/ArrayShapeCollector.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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class ArrayShapeCollector | ||
{ | ||
/** | ||
* @var array<FirstCollectedInterface> | ||
*/ | ||
private $firstCollected = []; | ||
|
||
/** | ||
* @var array<SecondCollectedInterface> | ||
*/ | ||
private $secondCollected = []; | ||
|
||
/** | ||
* @param array<FirstCollectedInterface> $firstCollected | ||
* @param array<SecondCollectedInterface> $secondCollected | ||
*/ | ||
public function __construct(array $firstCollected, array $secondCollected) | ||
{ | ||
$this->firstCollected = $firstCollected; | ||
$this->secondCollected = $secondCollected; | ||
} | ||
|
||
/** | ||
* @return array<FirstCollectedInterface> | ||
*/ | ||
public function getFirstCollected(): array | ||
{ | ||
return $this->firstCollected; | ||
} | ||
|
||
/** | ||
* @return array<SecondCollectedInterface> | ||
*/ | ||
public function getSecondCollected(): array | ||
{ | ||
return $this->secondCollected; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/DependencyInjection/CompilerPass/Source/Collected/FirstServiceOfFirstCollected.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Collected; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
|
||
final class FirstServiceOfFirstCollected implements FirstCollectedInterface | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/DependencyInjection/CompilerPass/Source/Collected/FirstServiceOfSecondCollected.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Collected; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class FirstServiceOfSecondCollected implements SecondCollectedInterface | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/DependencyInjection/CompilerPass/Source/Collected/SecondServiceOfFirstCollected.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Collected; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
|
||
final class SecondServiceOfFirstCollected implements FirstCollectedInterface | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/DependencyInjection/CompilerPass/Source/Collected/SecondServiceOfSecondCollected.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Collected; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class SecondServiceOfSecondCollected implements SecondCollectedInterface | ||
{ | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
tests/DependencyInjection/CompilerPass/Source/Collected/SomeCollectedPromoted.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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Collected; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
|
||
final class SomeCollectedPromoted implements FirstCollectedInterface | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/DependencyInjection/CompilerPass/Source/Contract/FirstCollectedInterface.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract; | ||
|
||
interface FirstCollectedInterface | ||
{ | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
tests/DependencyInjection/CompilerPass/Source/Contract/SecondCollectedInterface.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract; | ||
|
||
interface SecondCollectedInterface | ||
{ | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
tests/DependencyInjection/CompilerPass/Source/IterableCollector.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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class IterableCollector | ||
{ | ||
/** | ||
* @var iterable<FirstCollectedInterface> | ||
*/ | ||
private $firstCollected = []; | ||
|
||
/** | ||
* @var iterable<SecondCollectedInterface> | ||
*/ | ||
private $secondCollected = []; | ||
|
||
/** | ||
* @param iterable<FirstCollectedInterface> $firstCollected | ||
* @param iterable<SecondCollectedInterface> $secondCollected | ||
*/ | ||
public function __construct(array $firstCollected, array $secondCollected) | ||
{ | ||
$this->firstCollected = $firstCollected; | ||
$this->secondCollected = $secondCollected; | ||
} | ||
|
||
/** | ||
* @return iterable<FirstCollectedInterface> | ||
*/ | ||
public function getFirstCollected(): array | ||
{ | ||
return $this->firstCollected; | ||
} | ||
|
||
/** | ||
* @return iterable<SecondCollectedInterface> | ||
*/ | ||
public function getSecondCollected(): array | ||
{ | ||
return $this->secondCollected; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/DependencyInjection/CompilerPass/Source/PromotedPropertyCollector.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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
|
||
final class PromotedPropertyCollector | ||
{ | ||
/** | ||
* @param FirstCollectedInterface[] $firstCollected | ||
*/ | ||
public function __construct( | ||
private array $firstCollected | ||
) { | ||
} | ||
|
||
/** | ||
* @return FirstCollectedInterface[] | ||
*/ | ||
public function getFirstCollected(): array | ||
{ | ||
return $this->firstCollected; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/DependencyInjection/CompilerPass/Source/SkipMe/SkipUnionTypes.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source\SkipMe; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class SkipUnionTypes | ||
{ | ||
public function __construct( | ||
public FirstCollectedInterface|SecondCollectedInterface $collectedInterface | ||
) { | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/DependencyInjection/CompilerPass/Source/SomeCollector.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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\DependencyInjection\CompilerPass\Source; | ||
|
||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\FirstCollectedInterface; | ||
use Rector\Core\Tests\DependencyInjection\CompilerPass\Source\Contract\SecondCollectedInterface; | ||
|
||
final class SomeCollector | ||
{ | ||
/** | ||
* @var FirstCollectedInterface[] | ||
*/ | ||
private $firstCollected = []; | ||
|
||
/** | ||
* @var SecondCollectedInterface[] | ||
*/ | ||
private $secondCollected = []; | ||
|
||
/** | ||
* @param FirstCollectedInterface[] $firstCollected | ||
* @param SecondCollectedInterface[] $secondCollected | ||
*/ | ||
public function __construct(array $firstCollected, array $secondCollected) | ||
{ | ||
$this->firstCollected = $firstCollected; | ||
$this->secondCollected = $secondCollected; | ||
} | ||
|
||
/** | ||
* @return FirstCollectedInterface[] | ||
*/ | ||
public function getFirstCollected(): array | ||
{ | ||
return $this->firstCollected; | ||
} | ||
|
||
/** | ||
* @return SecondCollectedInterface[] | ||
*/ | ||
public function getSecondCollected(): array | ||
{ | ||
return $this->secondCollected; | ||
} | ||
} |
Oops, something went wrong.