-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate usage of the traits without registered DI extension
- Loading branch information
Showing
7 changed files
with
93 additions
and
32 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
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
16 changes: 16 additions & 0 deletions
16
tests/KdybyTests/Autowired/DeprecationsFixtures/SimplePresenter.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 KdybyTests\Autowired\DeprecationsFixtures; | ||
|
||
use Kdyby; | ||
use Nette; | ||
|
||
|
||
class SimplePresenter extends Nette\Application\UI\Presenter | ||
{ | ||
|
||
use Kdyby\Autowired\AutowireProperties; | ||
use Kdyby\Autowired\AutowireComponentFactories; | ||
|
||
} |
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,42 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace KdybyTests\Autowired; | ||
|
||
use KdybyTests\Autowired\DeprecationsFixtures\SimplePresenter; | ||
use KdybyTests\ContainerTestCase; | ||
use Tester\Assert; | ||
|
||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
|
||
final class DeprecationsTest extends ContainerTestCase | ||
{ | ||
|
||
public function testDIExtensionNotRegistered(): void | ||
{ | ||
$container = $this->compileContainer(); | ||
$presenter = new SimplePresenter(); | ||
|
||
Assert::error( | ||
function () use ($container, $presenter): void { | ||
$container->callMethod([$presenter, 'injectComponentFactories']); | ||
}, | ||
E_USER_DEPRECATED, | ||
'Using Kdyby\Autowired\AutowireComponentFactories without registered AutowiredExtension is deprecated, register the extension in your config.', | ||
); | ||
|
||
Assert::error( | ||
function () use ($container, $presenter): void { | ||
$container->callMethod([$presenter, 'injectProperties']); | ||
}, | ||
E_USER_DEPRECATED, | ||
'Using Kdyby\Autowired\AutowireProperties without registered AutowiredExtension is deprecated, register the extension in your config.', | ||
); | ||
} | ||
|
||
} | ||
|
||
(new DeprecationsTest())->run(); |