-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted integration for Ilias release_8
- Loading branch information
Showing
13 changed files
with
135 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,6 @@ | |
* @author Thomas Joußen <[email protected]> | ||
* @see https://www.php-fig.org/psr/psr-11/#32-psrcontainercontainerexceptioninterface | ||
*/ | ||
class PluginContainerException extends \RuntimeException implements ContainerExceptionInterface | ||
class PluginContainerException extends Exception implements ContainerExceptionInterface | ||
{ | ||
} |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
namespace Thojou\Ilias\Plugin\Utils\DI; | ||
|
||
use Exception; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
/** | ||
|
@@ -23,6 +24,6 @@ | |
* @author Thomas Joußen <[email protected]> | ||
* @see https://www.php-fig.org/psr/psr-11/#33-psrcontainernotfoundexceptioninterface | ||
*/ | ||
class PluginContainerNotFoundException extends \Exception implements NotFoundExceptionInterface | ||
class PluginContainerNotFoundException extends Exception implements NotFoundExceptionInterface | ||
{ | ||
} |
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
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,73 @@ | ||
<?php | ||
|
||
namespace Thojou\Ilias\Plugin\Utils\Tests\DI; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
use Thojou\Ilias\Plugin\Utils\DI\PluginContainerException; | ||
use Thojou\Ilias\Plugin\Utils\DI\PluginContainerNotFoundException; | ||
use Thojou\Ilias\Plugin\Utils\DI\PluginContainerWrapper; | ||
use ILIAS\DI\Container; | ||
|
||
class PluginContainerWrapperTest extends TestCase | ||
{ | ||
public function testGet() | ||
{ | ||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(true); | ||
$container->method('offsetGet')->willReturn('service'); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container); | ||
|
||
$this->assertEquals('service', $pluginContainerWrapper->get('service')); | ||
} | ||
|
||
public function testGetWithPrefix() | ||
{ | ||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(true); | ||
$container->method('offsetGet')->willReturn('service'); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container, 'prefix_'); | ||
|
||
$this->assertEquals('service', $pluginContainerWrapper->get('service')); | ||
} | ||
|
||
public function testHas() | ||
{ | ||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(true); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container); | ||
|
||
$this->assertTrue($pluginContainerWrapper->has('service')); | ||
} | ||
|
||
public function testHasReturnsFalse() | ||
{ | ||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(false); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container); | ||
|
||
$this->assertFalse($pluginContainerWrapper->has('nonexistent_service')); | ||
} | ||
|
||
public function testGetThrowsNotFoundException() | ||
{ | ||
$this->expectException(PluginContainerNotFoundException::class); | ||
|
||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(false); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container); | ||
|
||
$pluginContainerWrapper->get('nonexistent_service'); | ||
} | ||
|
||
public function testGetThrowsContainerException() | ||
{ | ||
$container = $this->createMock(Container::class); | ||
$container->method('offsetExists')->willReturn(true); | ||
$container->method('offsetGet')->will($this->throwException(new Exception())); | ||
$pluginContainerWrapper = new PluginContainerWrapper($container); | ||
|
||
$this->expectException(PluginContainerException::class); | ||
$pluginContainerWrapper->get('service_causing_exception'); | ||
} | ||
} |
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