-
-
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.
Changed MetaData::getDI to throw exception
See: #15011
- Loading branch information
1 parent
45ee3a4
commit f62b248
Showing
6 changed files
with
113 additions
and
41 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,30 +5,44 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* 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\Test\Database\Mvc\Model\MetaData; | ||
|
||
use DatabaseTester; | ||
use Phalcon\Mvc\Model\Exception as ExpectedException; | ||
use Phalcon\Mvc\Model\MetaData\Memory; | ||
use Phalcon\Storage\Exception; | ||
use Phalcon\Test\Fixtures\Traits\DiTrait; | ||
|
||
class GetSetDICest | ||
{ | ||
use DiTrait; | ||
|
||
public function _before(DatabaseTester $I) | ||
/** | ||
* Executed before each test | ||
* | ||
* @param DatabaseTester $I | ||
* @return void | ||
*/ | ||
public function _before(DatabaseTester $I): void | ||
{ | ||
$this->setNewFactoryDefault(); | ||
try { | ||
$this->setNewFactoryDefault(); | ||
} catch (Exception $e) { | ||
$I->fail($e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\MetaData :: getDI() / setDI() | ||
* | ||
* @param DatabaseTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2020-02-01 | ||
* | ||
|
@@ -39,11 +53,34 @@ public function mvcModelMetadataGetSetDI(DatabaseTester $I) | |
$I->wantToTest('Mvc\Model\MetaData - getDI() / setDI()'); | ||
|
||
$metadata = new Memory(); | ||
|
||
$I->assertNull($metadata->getDI()); | ||
|
||
$metadata->setDI($this->container); | ||
|
||
$I->assertEquals($this->container, $metadata->getDI()); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\MetaData :: getDI() - exception | ||
* | ||
* @param DatabaseTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2020-05-05 | ||
* | ||
* @group common | ||
*/ | ||
public function mvcModelMetadataGetDIThrowsException(DatabaseTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\MetaData - getDI() - exception'); | ||
|
||
$I->expectThrowable( | ||
new ExpectedException( | ||
'A dependency injection container is required to access internal services' | ||
), | ||
function () { | ||
(new Memory())->getDI(); | ||
} | ||
); | ||
} | ||
|
||
|
||
} |