mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
This splits the testing suite into the separate modules as appropriate in order to improve the reliability of the testing suite as a whole and make it easier for developers to have an up to date testing suite from the core to build off of. Additionally the tests are now namespaced and some minor improvements to the PluginManager were made. Now the PluginManager will internally treat plugin identifiers as lower case strings, only transforming them to their normalized versions when requested by methods like getPlugins() & getAllPlugins(). The idea behind this is that it provides a much simpler way to internally handle checking, especially for plugin replacement where casing could cause issues. Replaces #576. Fixes #575.
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Cms\Tests\Classes;
|
|
|
|
use System\Tests\Bootstrap\TestCase;
|
|
use Cms\Classes\CmsException;
|
|
use Cms\Classes\Router;
|
|
use Cms\Classes\Theme;
|
|
use Winter\Storm\Exception\SystemException;
|
|
|
|
class CmsExceptionTest extends TestCase
|
|
{
|
|
//
|
|
// Tests
|
|
//
|
|
|
|
public function testExceptionMask()
|
|
{
|
|
$foreignException = new \Exception('This is a general error');
|
|
$exceptionMask = new SystemException('This is a system exception');
|
|
$exceptionMask->setMask($foreignException);
|
|
|
|
$this->assertEquals('This is a general error', $exceptionMask->getMessage());
|
|
}
|
|
|
|
public function testCmsExceptionPhp()
|
|
{
|
|
$theme = Theme::load('test');
|
|
$router = new Router($theme);
|
|
$page = $router->findByUrl('/throw-php');
|
|
|
|
$error = [
|
|
'file' => 'test.php',
|
|
'line' => 20,
|
|
];
|
|
$foreignException = new \Symfony\Component\ErrorHandler\Error\FatalError('This is a general error', 100, $error);
|
|
$this->setProtectedProperty($foreignException, 'file', "/modules/cms/classes/CodeParser.php(165) : eval()'d code line 7");
|
|
|
|
$exception = new CmsException($page, 300);
|
|
$exception->setMask($foreignException);
|
|
|
|
$this->assertEquals($page->getFilePath(), $exception->getFile());
|
|
$this->assertEquals('PHP Content', $exception->getErrorType());
|
|
$this->assertEquals('This is a general error', $exception->getMessage());
|
|
}
|
|
}
|