Code formatting changes (#3363)
Code formatting improvements submitted by @arthurkushman.
This commit is contained in:
parent
13dadaa667
commit
c78b3ef786
|
|
@ -3,14 +3,12 @@
|
||||||
use App;
|
use App;
|
||||||
use Lang;
|
use Lang;
|
||||||
use Event;
|
use Event;
|
||||||
use Backend;
|
|
||||||
use BackendMenu;
|
use BackendMenu;
|
||||||
use BackendAuth;
|
use BackendAuth;
|
||||||
use Backend\Models\UserRole;
|
use Backend\Models\UserRole;
|
||||||
use Backend\Classes\WidgetManager;
|
use Backend\Classes\WidgetManager;
|
||||||
use October\Rain\Support\ModuleServiceProvider;
|
use October\Rain\Support\ModuleServiceProvider;
|
||||||
use System\Classes\SettingsManager;
|
use System\Classes\SettingsManager;
|
||||||
use System\Classes\CombineAssets;
|
|
||||||
use Cms\Classes\ComponentManager;
|
use Cms\Classes\ComponentManager;
|
||||||
use Cms\Classes\Page as CmsPage;
|
use Cms\Classes\Page as CmsPage;
|
||||||
use Cms\Classes\CmsObject;
|
use Cms\Classes\CmsObject;
|
||||||
|
|
@ -242,7 +240,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
protected function registerBackendWidgets()
|
protected function registerBackendWidgets()
|
||||||
{
|
{
|
||||||
WidgetManager::instance()->registerFormWidgets(function ($manager) {
|
WidgetManager::instance()->registerFormWidgets(function ($manager) {
|
||||||
$manager->registerFormWidget('Cms\FormWidgets\Components');
|
$manager->registerFormWidget(FormWidgets\Components::class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +265,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
'description' => 'cms::lang.maintenance.settings_menu_description',
|
'description' => 'cms::lang.maintenance.settings_menu_description',
|
||||||
'category' => SettingsManager::CATEGORY_CMS,
|
'category' => SettingsManager::CATEGORY_CMS,
|
||||||
'icon' => 'icon-plug',
|
'icon' => 'icon-plug',
|
||||||
'class' => 'Cms\Models\MaintenanceSetting',
|
'class' => Models\MaintenanceSetting::class,
|
||||||
'permissions' => ['cms.manage_themes'],
|
'permissions' => ['cms.manage_themes'],
|
||||||
'order' => 300
|
'order' => 300
|
||||||
],
|
],
|
||||||
|
|
@ -297,13 +295,13 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
});
|
});
|
||||||
|
|
||||||
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
|
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
|
||||||
if ($type == 'cms-page') {
|
if ($type === 'cms-page') {
|
||||||
return CmsPage::getMenuTypeInfo($type);
|
return CmsPage::getMenuTypeInfo($type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
|
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
|
||||||
if ($type == 'cms-page') {
|
if ($type === 'cms-page') {
|
||||||
return CmsPage::resolveMenuItem($item, $url, $theme);
|
return CmsPage::resolveMenuItem($item, $url, $theme);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -321,7 +319,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
});
|
});
|
||||||
|
|
||||||
Event::listen('backend.richeditor.getTypeInfo', function ($type) {
|
Event::listen('backend.richeditor.getTypeInfo', function ($type) {
|
||||||
if ($type == 'cms-page') {
|
if ($type === 'cms-page') {
|
||||||
return CmsPage::getRichEditorTypeInfo($type);
|
return CmsPage::getRichEditorTypeInfo($type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ class Controller
|
||||||
$url = Request::path();
|
$url = Request::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen($url)) {
|
if (empty($url)) {
|
||||||
$url = '/';
|
$url = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,11 +156,9 @@ class Controller
|
||||||
* Hidden page
|
* Hidden page
|
||||||
*/
|
*/
|
||||||
$page = $this->router->findByUrl($url);
|
$page = $this->router->findByUrl($url);
|
||||||
if ($page && $page->is_hidden) {
|
if ($page && $page->is_hidden && !BackendAuth::getUser()) {
|
||||||
if (!BackendAuth::getUser()) {
|
|
||||||
$page = null;
|
$page = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maintenance mode
|
* Maintenance mode
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class Layout extends CmsCompoundObject
|
||||||
*/
|
*/
|
||||||
public function isFallBack()
|
public function isFallBack()
|
||||||
{
|
{
|
||||||
return $this->fileName == self::FALLBACK_FILE_NAME;
|
return $this->fileName === self::FALLBACK_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,6 +50,6 @@ class Layout extends CmsCompoundObject
|
||||||
*/
|
*/
|
||||||
public function getCodeClassParent()
|
public function getCodeClassParent()
|
||||||
{
|
{
|
||||||
return '\Cms\Classes\LayoutCode';
|
return LayoutCode::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class MediaLibrary extends SystemMediaLibrary
|
||||||
*/
|
*/
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
traceLog('Class Cms\Classes\MediaLibrary has been deprecated, use ' . SystemMediaLibrary::class . ' instead.');
|
traceLog('Class ' . __CLASS__ . ' has been deprecated, use ' . SystemMediaLibrary::class . ' instead.');
|
||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class Page extends CmsCompoundObject
|
||||||
*/
|
*/
|
||||||
public function getCodeClassParent() : string
|
public function getCodeClassParent() : string
|
||||||
{
|
{
|
||||||
return '\Cms\Classes\PageCode';
|
return PageCode::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -185,8 +185,7 @@ class Resources extends ComponentBase
|
||||||
if (File::isDirectory($baseTheme.'/assets')) {
|
if (File::isDirectory($baseTheme.'/assets')) {
|
||||||
return $baseTheme.'/assets';
|
return $baseTheme.'/assets';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return $baseTheme.'/resources';
|
return $baseTheme.'/resources';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class ViewBag extends ComponentBase
|
||||||
/**
|
/**
|
||||||
* Determine if an attribute exists on the object.
|
* Determine if an attribute exists on the object.
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function __isset($key)
|
public function __isset($key)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ use Backend\Classes\Controller;
|
||||||
use Backend\Classes\WidgetManager;
|
use Backend\Classes\WidgetManager;
|
||||||
use October\Rain\Router\Router as RainRouter;
|
use October\Rain\Router\Router as RainRouter;
|
||||||
use ApplicationException;
|
use ApplicationException;
|
||||||
|
use Cms\Classes\Asset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CMS index
|
* CMS index
|
||||||
|
|
@ -126,7 +127,7 @@ class Index extends Controller
|
||||||
|
|
||||||
$this->vars['templatePath'] = Request::input('path');
|
$this->vars['templatePath'] = Request::input('path');
|
||||||
|
|
||||||
if ($type == 'page') {
|
if ($type === 'page') {
|
||||||
$router = new RainRouter;
|
$router = new RainRouter;
|
||||||
$this->vars['pageUrl'] = $router->urlFromPattern($template->url);
|
$this->vars['pageUrl'] = $router->urlFromPattern($template->url);
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +204,7 @@ class Index extends Controller
|
||||||
'tabTitle' => $this->getTabTitle($type, $template)
|
'tabTitle' => $this->getTabTitle($type, $template)
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($type == 'page') {
|
if ($type === 'page') {
|
||||||
$result['pageUrl'] = Url::to($template->url);
|
$result['pageUrl'] = Url::to($template->url);
|
||||||
$router = new Router($this->theme);
|
$router = new Router($this->theme);
|
||||||
$router->clearCache();
|
$router->clearCache();
|
||||||
|
|
@ -223,7 +224,7 @@ class Index extends Controller
|
||||||
$type = Request::input('type');
|
$type = Request::input('type');
|
||||||
$template = $this->createTemplate($type);
|
$template = $this->createTemplate($type);
|
||||||
|
|
||||||
if ($type == 'asset') {
|
if ($type === 'asset') {
|
||||||
$template->fileName = $this->widget->assetList->getCurrentRelativePath();
|
$template->fileName = $this->widget->assetList->getCurrentRelativePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,7 +307,7 @@ class Index extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can only expand components at this stage
|
// Can only expand components at this stage
|
||||||
if ((!$type = post('tokenType')) && $type != 'component') {
|
if ((!$type = post('tokenType')) && $type !== 'component') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,11 +346,11 @@ class Index extends Controller
|
||||||
protected function resolveTypeClassName($type)
|
protected function resolveTypeClassName($type)
|
||||||
{
|
{
|
||||||
$types = [
|
$types = [
|
||||||
'page' => '\Cms\Classes\Page',
|
'page' => Page::class,
|
||||||
'partial' => '\Cms\Classes\Partial',
|
'partial' => Partial::class,
|
||||||
'layout' => '\Cms\Classes\Layout',
|
'layout' => Layout::class,
|
||||||
'content' => '\Cms\Classes\Content',
|
'content' => Content::class,
|
||||||
'asset' => '\Cms\Classes\Asset'
|
'asset' => Asset::class
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!array_key_exists($type, $types)) {
|
if (!array_key_exists($type, $types)) {
|
||||||
|
|
@ -388,7 +389,7 @@ class Index extends Controller
|
||||||
|
|
||||||
protected function getTabTitle($type, $template)
|
protected function getTabTitle($type, $template)
|
||||||
{
|
{
|
||||||
if ($type == 'page') {
|
if ($type === 'page') {
|
||||||
$result = $template->title ?: $template->getFileName();
|
$result = $template->title ?: $template->getFileName();
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$result = trans('cms::lang.page.new');
|
$result = trans('cms::lang.page.new');
|
||||||
|
|
@ -397,7 +398,7 @@ class Index extends Controller
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'partial' || $type == 'layout' || $type == 'content' || $type == 'asset') {
|
if ($type === 'partial' || $type === 'layout' || $type === 'content' || $type === 'asset') {
|
||||||
$result = in_array($type, ['asset', 'content']) ? $template->getFileName() : $template->getBaseFileName();
|
$result = in_array($type, ['asset', 'content']) ? $template->getFileName() : $template->getBaseFileName();
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$result = trans('cms::lang.'.$type.'.new');
|
$result = trans('cms::lang.'.$type.'.new');
|
||||||
|
|
@ -504,8 +505,7 @@ class Index extends Controller
|
||||||
*/
|
*/
|
||||||
protected function convertLineEndings($markup)
|
protected function convertLineEndings($markup)
|
||||||
{
|
{
|
||||||
$markup = str_replace("\r\n", "\n", $markup);
|
$markup = str_replace(["\r\n", "\r"], "\n", $markup);
|
||||||
$markup = str_replace("\r", "\n", $markup);
|
|
||||||
|
|
||||||
return $markup;
|
return $markup;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Cms\Classes\ThemeManager;
|
||||||
use System\Classes\SettingsManager;
|
use System\Classes\SettingsManager;
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Backend\Widgets\Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme selector controller
|
* Theme selector controller
|
||||||
|
|
@ -57,7 +58,7 @@ class Themes extends Controller
|
||||||
/*
|
/*
|
||||||
* Enable AJAX for Form widgets
|
* Enable AJAX for Form widgets
|
||||||
*/
|
*/
|
||||||
if (post('mode') == 'import') {
|
if (post('mode') === 'import') {
|
||||||
$this->makeImportFormWidget($this->findThemeObject())->bindToController();
|
$this->makeImportFormWidget($this->findThemeObject())->bindToController();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +117,7 @@ class Themes extends Controller
|
||||||
$widgetConfig->arrayName = 'Theme';
|
$widgetConfig->arrayName = 'Theme';
|
||||||
$widgetConfig->context = 'update';
|
$widgetConfig->context = 'update';
|
||||||
|
|
||||||
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
|
$widget = $this->makeWidget(Form::class, $widgetConfig);
|
||||||
return $widget;
|
return $widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ class Cms
|
||||||
if (self::$actionExists) {
|
if (self::$actionExists) {
|
||||||
return Url::action($routeAction, ['slug' => $path]);
|
return Url::action($routeAction, ['slug' => $path]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return Url::to($path);
|
return Url::to($path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class File
|
||||||
public static function validateExtension($fileName, $allowedExtensions, $allowEmpty = true)
|
public static function validateExtension($fileName, $allowedExtensions, $allowEmpty = true)
|
||||||
{
|
{
|
||||||
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||||
if (!strlen($extension)) {
|
if (empty($extension)) {
|
||||||
return $allowEmpty;
|
return $allowEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use Model;
|
||||||
use Cms\Classes\Theme as CmsTheme;
|
use Cms\Classes\Theme as CmsTheme;
|
||||||
use System\Classes\CombineAssets;
|
use System\Classes\CombineAssets;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use System\Models\File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customization data used by a theme
|
* Customization data used by a theme
|
||||||
|
|
@ -106,11 +107,11 @@ class ThemeData extends Model
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field['type'] == 'repeater') {
|
if ($field['type'] === 'repeater') {
|
||||||
$this->jsonable[] = $id;
|
$this->jsonable[] = $id;
|
||||||
}
|
}
|
||||||
elseif ($field['type'] == 'fileupload') {
|
elseif ($field['type'] === 'fileupload') {
|
||||||
$this->attachOne[$id] = 'System\Models\File';
|
$this->attachOne[$id] = File::class;
|
||||||
unset($data[$id]);
|
unset($data[$id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class Loader extends LoaderBase implements Twig_LoaderInterface
|
||||||
*/
|
*/
|
||||||
protected function validateCmsObject($name)
|
protected function validateCmsObject($name)
|
||||||
{
|
{
|
||||||
if ($name == $this->obj->getFilePath()) {
|
if ($name === $this->obj->getFilePath()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class Loader implements Twig_LoaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = $name;
|
$view = $name;
|
||||||
if (File::extension($view) == $this->extension) {
|
if (File::extension($view) === $this->extension) {
|
||||||
$view = substr($view, 0, -strlen($this->extension));
|
$view = substr($view, 0, -strlen($this->extension));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use Cms\Classes\Theme as MyTheme;
|
use Cms\Classes\Theme as MyTheme;
|
||||||
use Cms\Classes\Router as MyRouter;
|
use Cms\Classes\Router as MyRouter;
|
||||||
class {className} extends \Cms\Classes\PageCode
|
class {className} extends Cms\Classes\PageCode
|
||||||
{
|
{
|
||||||
public function onStart() {
|
public function onStart() {
|
||||||
$this['pageStartVar'] = 3;
|
$this['pageStartVar'] = 3;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use Cms\Classes\Theme;
|
use Cms\Classes\Theme;
|
||||||
use Cms\Classes\Router;
|
use Cms\Classes\Router;
|
||||||
class {className} extends \Cms\Classes\PageCode
|
class {className} extends Cms\Classes\PageCode
|
||||||
{
|
{
|
||||||
public function onStart() {
|
public function onStart() {
|
||||||
$this['pageStartVar'] = 3;
|
$this['pageStartVar'] = 3;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Cms\Classes\PageCode;
|
||||||
|
use Cms\Classes\LayoutCode;
|
||||||
use Cms\Classes\Page;
|
use Cms\Classes\Page;
|
||||||
use Cms\Classes\Theme;
|
use Cms\Classes\Theme;
|
||||||
use Cms\Classes\Layout;
|
use Cms\Classes\Layout;
|
||||||
|
|
@ -15,14 +17,14 @@ class CodeParserTest extends TestCase
|
||||||
/*
|
/*
|
||||||
* Clear cache
|
* Clear cache
|
||||||
*/
|
*/
|
||||||
foreach (File::directories(storage_path().'/cms/cache') as $directory) {
|
foreach (File::directories(storage_path() . '/cms/cache') as $directory) {
|
||||||
File::deleteDirectory($directory);
|
File::deleteDirectory($directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProperty($name)
|
public static function getProperty($name)
|
||||||
{
|
{
|
||||||
$class = new ReflectionClass('\Cms\Classes\CodeParser');
|
$class = new ReflectionClass(CodeParser::class);
|
||||||
$property = $class->getProperty($name);
|
$property = $class->getProperty($name);
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
|
|
||||||
|
|
@ -48,19 +50,19 @@ class CodeParserTest extends TestCase
|
||||||
|
|
||||||
$controller = new Controller($theme);
|
$controller = new Controller($theme);
|
||||||
$obj = $parser->source(null, $layout, $controller);
|
$obj = $parser->source(null, $layout, $controller);
|
||||||
$this->assertInstanceOf('\Cms\Classes\LayoutCode', $obj);
|
$this->assertInstanceOf(LayoutCode::class, $obj);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test the file contents
|
* Test the file contents
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$body = preg_replace('/^\s*function/m', 'public function', $layout->code);
|
$body = preg_replace('/^\s*function/m', 'public function', $layout->code);
|
||||||
$expectedContent = '<?php '.PHP_EOL;
|
$expectedContent = '<?php ' . PHP_EOL;
|
||||||
|
|
||||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\LayoutCode'.PHP_EOL;
|
$expectedContent .= 'class ' . $info['className'] . ' extends ' . LayoutCode::class . PHP_EOL;
|
||||||
$expectedContent .= '{'.PHP_EOL;
|
$expectedContent .= '{' . PHP_EOL;
|
||||||
$expectedContent .= $body.PHP_EOL;
|
$expectedContent .= $body . PHP_EOL;
|
||||||
$expectedContent .= '}'.PHP_EOL;
|
$expectedContent .= '}' . PHP_EOL;
|
||||||
|
|
||||||
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
||||||
|
|
||||||
|
|
@ -136,11 +138,11 @@ class CodeParserTest extends TestCase
|
||||||
|
|
||||||
$this->assertFileExists($info['filePath']);
|
$this->assertFileExists($info['filePath']);
|
||||||
|
|
||||||
$expectedContent = '<?php '.PHP_EOL;
|
$expectedContent = '<?php ' . PHP_EOL;
|
||||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\LayoutCode'.PHP_EOL;
|
$expectedContent .= 'class ' . $info['className'] . ' extends ' . LayoutCode::class . PHP_EOL;
|
||||||
$expectedContent .= '{'.PHP_EOL;
|
$expectedContent .= '{' . PHP_EOL;
|
||||||
$expectedContent .= PHP_EOL;
|
$expectedContent .= PHP_EOL;
|
||||||
$expectedContent .= '}'.PHP_EOL;
|
$expectedContent .= '}' . PHP_EOL;
|
||||||
|
|
||||||
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
||||||
}
|
}
|
||||||
|
|
@ -163,14 +165,14 @@ class CodeParserTest extends TestCase
|
||||||
$this->assertFileExists($info['filePath']);
|
$this->assertFileExists($info['filePath']);
|
||||||
$controller = new Controller($theme);
|
$controller = new Controller($theme);
|
||||||
$obj = $parser->source($page, null, $controller);
|
$obj = $parser->source($page, null, $controller);
|
||||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
$this->assertInstanceOf(PageCode::class, $obj);
|
||||||
|
|
||||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||||
$expectedContent = '<?php '.PHP_EOL;
|
$expectedContent = '<?php ' . PHP_EOL;
|
||||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||||
$expectedContent .= '{'.PHP_EOL;
|
$expectedContent .= '{' . PHP_EOL;
|
||||||
$expectedContent .= $body.PHP_EOL;
|
$expectedContent .= $body . PHP_EOL;
|
||||||
$expectedContent .= '}'.PHP_EOL;
|
$expectedContent .= '}' . PHP_EOL;
|
||||||
|
|
||||||
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
||||||
}
|
}
|
||||||
|
|
@ -200,11 +202,11 @@ class CodeParserTest extends TestCase
|
||||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
||||||
|
|
||||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||||
$expectedContent = '<?php '.PHP_EOL;
|
$expectedContent = '<?php ' . PHP_EOL;
|
||||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||||
$expectedContent .= '{'.PHP_EOL;
|
$expectedContent .= '{' . PHP_EOL;
|
||||||
$expectedContent .= $body.PHP_EOL;
|
$expectedContent .= $body . PHP_EOL;
|
||||||
$expectedContent .= '}'.PHP_EOL;
|
$expectedContent .= '}' . PHP_EOL;
|
||||||
|
|
||||||
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
||||||
|
|
||||||
|
|
@ -226,14 +228,14 @@ class CodeParserTest extends TestCase
|
||||||
$this->assertFileExists($info['filePath']);
|
$this->assertFileExists($info['filePath']);
|
||||||
$controller = new Controller($theme);
|
$controller = new Controller($theme);
|
||||||
$obj = $parser->source($page, null, $controller);
|
$obj = $parser->source($page, null, $controller);
|
||||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
$this->assertInstanceOf(PageCode::class, $obj);
|
||||||
|
|
||||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||||
$expectedContent = '<?php '.PHP_EOL;
|
$expectedContent = '<?php ' . PHP_EOL;
|
||||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||||
$expectedContent .= '{'.PHP_EOL;
|
$expectedContent .= '{' . PHP_EOL;
|
||||||
$expectedContent .= $body.PHP_EOL;
|
$expectedContent .= $body . PHP_EOL;
|
||||||
$expectedContent .= '}'.PHP_EOL;
|
$expectedContent .= '}' . PHP_EOL;
|
||||||
|
|
||||||
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
$this->assertEquals($expectedContent, file_get_contents($info['filePath']));
|
||||||
}
|
}
|
||||||
|
|
@ -261,9 +263,9 @@ class CodeParserTest extends TestCase
|
||||||
$this->assertFileExists($info['filePath']);
|
$this->assertFileExists($info['filePath']);
|
||||||
$controller = new Controller($theme);
|
$controller = new Controller($theme);
|
||||||
$obj = $parser->source($page, null, $controller);
|
$obj = $parser->source($page, null, $controller);
|
||||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
$this->assertInstanceOf(PageCode::class, $obj);
|
||||||
|
|
||||||
$referenceFilePath = base_path().'/tests/fixtures/cms/reference/namespaces.php.stub';
|
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces.php.stub';
|
||||||
$this->assertFileExists($referenceFilePath);
|
$this->assertFileExists($referenceFilePath);
|
||||||
$referenceContents = $this->getContents($referenceFilePath);
|
$referenceContents = $this->getContents($referenceFilePath);
|
||||||
|
|
||||||
|
|
@ -290,9 +292,9 @@ class CodeParserTest extends TestCase
|
||||||
$this->assertFileExists($info['filePath']);
|
$this->assertFileExists($info['filePath']);
|
||||||
$controller = new Controller($theme);
|
$controller = new Controller($theme);
|
||||||
$obj = $parser->source($page, null, $controller);
|
$obj = $parser->source($page, null, $controller);
|
||||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
$this->assertInstanceOf(PageCode::class, $obj);
|
||||||
|
|
||||||
$referenceFilePath = base_path().'/tests/fixtures/cms/reference/namespaces-aliases.php.stub';
|
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces-aliases.php.stub';
|
||||||
$this->assertFileExists($referenceFilePath);
|
$this->assertFileExists($referenceFilePath);
|
||||||
$referenceContents = $this->getContents($referenceFilePath);
|
$referenceContents = $this->getContents($referenceFilePath);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue