-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15916 from twistersfury/5.0.x-initialization
Adding InitializationAwareInterface
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Phalcon\Di; | ||
|
||
interface InitializationAwareInterface | ||
{ | ||
public function initialize() -> void; | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Tests\Fixtures\Di; | ||
|
||
use Phalcon\Di\InitializationAwareInterface; | ||
|
||
/** | ||
* Class InitializationAwareComponent | ||
* | ||
* @package Phalcon\Tests\Fixtures\Di | ||
*/ | ||
class InitializationAwareComponent implements InitializationAwareInterface | ||
{ | ||
private bool $initialized = false; | ||
|
||
public function initialize(): void | ||
{ | ||
$this->initialized = true; | ||
} | ||
|
||
public function isInitialized(): bool | ||
{ | ||
return $this->initialized; | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Tests\Unit\Di; | ||
|
||
use Phalcon\Di\Di; | ||
use Phalcon\Tests\Fixtures\Di\InitializationAwareComponent; | ||
use UnitTester; | ||
|
||
/** | ||
* Class InitializationAwareCest | ||
* | ||
* @package Phalcon\Tests\Unit\Di | ||
*/ | ||
class InitializationAwareCest | ||
{ | ||
/** | ||
* Tests Phalcon\Di\Di :: initialization aware interface | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalcon.io> | ||
* @since 2019-09-09 | ||
*/ | ||
public function diInitializationAware(UnitTester $I) | ||
{ | ||
$I->wantToTest('Di - initialization aware interface'); | ||
|
||
$di = new Di(); | ||
|
||
$I->assertEquals(true, $di->get(InitializationAwareComponent::class)->isInitialized()); | ||
} | ||
} |