Skip to content

Commit

Permalink
add test, fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Jul 11, 2019
1 parent 2afdbe5 commit f6fa1fa
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/admin/apis/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function actionControllerActions($module, $controller)

/**
* Get actions for a given controller.
*
*
* @param object $controller
* @since 2.0.0
* @see Replace with luya core object helper
Expand Down
26 changes: 13 additions & 13 deletions src/admin/apis/NavController.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,16 @@ public function actionCreateModule()
}

$create = $model->createModule(
$parentNavId,
$navContainerId,
$this->postArg('lang_id'),
$this->postArg('title'),
$this->postArg('alias'),
$this->postArg('module_name'),
$parentNavId,
$navContainerId,
$this->postArg('lang_id'),
$this->postArg('title'),
$this->postArg('alias'),
$this->postArg('module_name'),
$this->postArg('description'),
$this->postArg('controller_name'),
$this->postArg('action_name'),
$this->postArg('action_params', [])
$this->postArg('controller_name'),
$this->postArg('action_name'),
$this->postArg('action_params', [])
);
if (is_array($create)) {
Yii::$app->response->statusCode = 422;
Expand All @@ -368,12 +368,12 @@ public function actionCreateModuleItem()
$create = $model->createModuleItem(
$this->postArg('nav_id'),
$this->postArg('lang_id'),
$this->postArg('title'),
$this->postArg('alias'),
$this->postArg('title'),
$this->postArg('alias'),
$this->postArg('module_name'),
$this->postArg('description'),
$this->postArg('controller_name'),
$this->postArg('action_name'),
$this->postArg('controller_name'),
$this->postArg('action_name'),
$this->postArg('action_params', [])
);
if (is_array($create)) {
Expand Down
4 changes: 2 additions & 2 deletions src/admin/apis/RedirectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class RedirectController extends \luya\admin\ngrest\base\Api

/**
* Find a redirect object for a given path info.
*
*
* An example using path would be: Yii::$app->request->pathInfo
*
*
* url: https://example.com/hello/world
* path: hello/world
*
Expand Down
1 change: 0 additions & 1 deletion src/admin/importers/BlockImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ protected function handleBlockDefintionInDirectories(array $directories, $blockD
{
$results = [];
foreach ($directories as $directoryPath) {

$path = rtrim($directoryPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($blockDefinition, DIRECTORY_SEPARATOR);

$path = $this->replaceDsSeparator($path);
Expand Down
2 changes: 1 addition & 1 deletion src/admin/importers/CmslayoutImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected function importLayoutFile($file, $aliased)
}

return $layoutItem->id;
}
}

// add item into the database table
$data = new Layout();
Expand Down
2 changes: 1 addition & 1 deletion src/admin/messages/ru/cmsadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'menu_group_item_env_container' => 'Контейнеры',
'menu_group_item_env_layouts' => 'Макеты',
'menu_group_elements' => 'Элементы контента',
'menu_group_item_elements_blocks' => 'Блоки',
'menu_group_item_elements_blocks' => 'Блоки',
'menu_group_item_elements_group' => 'Группы блоков',
'btn_abort' => 'Отмена',
'btn_refresh' => 'Обновить',
Expand Down
6 changes: 3 additions & 3 deletions src/base/BlockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ public function getIsDirtyDialogEnabled();

/**
* This method is called whenever a block inside a placeholder is rendered.
*
*
* This allows you to change the render behavior of every block inside a placeholder. An example of
* adding a wrapper div to the iteration:
*
*
* ```php
* public function placeholderRenderIteration(BlockInterface $block)
* {
* return '<div class="block-wrapper">'.$block->renderFrontend().'</div>';
* }
* ```
*
*
* This also allows you to determined whether the block should be rendered or not as the response is the content
* of the block inside the placholder.
*
Expand Down
7 changes: 4 additions & 3 deletions src/base/InternalBaseBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ public function getExtraValue($key, $default = false)
$this->getExtraVarValues();
$this->_assignExtraVars = true;
}
return (isset($this->_extraVars[$key])) ? $this->_extraVars[$key] : $default;

return isset($this->_extraVars[$key]) ? $this->_extraVars[$key] : $default;
}

/**
Expand Down Expand Up @@ -483,7 +484,7 @@ public function addVar(array $varConfig, $append = false)
*/
public function getConfigPlaceholdersExport()
{
$array = (array_key_exists('placeholders', $this->config())) ? $this->config()['placeholders'] : [];
$array = array_key_exists('placeholders', $this->config()) ? $this->config()['placeholders'] : [];

$holders = [];

Expand All @@ -505,7 +506,7 @@ public function getConfigPlaceholdersExport()
*/
public function getConfigPlaceholdersByRowsExport()
{
$array = (array_key_exists('placeholders', $this->config())) ? $this->config()['placeholders'] : [];
$array = array_key_exists('placeholders', $this->config()) ? $this->config()['placeholders'] : [];

$rows = [];

Expand Down
1 change: 0 additions & 1 deletion src/frontend/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function bootstrap($app)
// handle not found exceptions
$app->errorHandler->on(ErrorHandler::EVENT_BEFORE_EXCEPTION_RENDER, function (ErrorHandlerExceptionRenderEvent $event) use ($app) {
if ($event->exception instanceof NotFoundHttpException) {

$errorPageNavId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
/** @var $item Item */
$item = $app->menu->find()->with(['hidden'])->where(['nav_id' => $errorPageNavId])->one();
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,4 @@ protected function findInternalRedirect()

return false;
}


}
2 changes: 1 addition & 1 deletion src/injectors/ActiveQuerySelectInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ public function setup()
// provide the extra data
$this->context->addExtraVar($this->varName, $this->getExtraAssignSingleData());
}
}
}
4 changes: 2 additions & 2 deletions src/menu/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ public function getParents()

/**
* Go down to a given element which is evalutaed trough a callable.
*
*
* Iterate trough parent elements until the last.
*
*
* ```php
* $item = Yii::$app->menu->current->down(function(Item $item) {
* if ($item->depth == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/models/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function reindex($e)
*
* This method is mainly to find all recursive children of a nav item when moving a page into a container
* all childrens requires to update its container id as well, so this method contains the data of its children
*
*
* @return array An array where each entry is a Nav object
*/
public function getRecursiveChildren()
Expand Down
2 changes: 1 addition & 1 deletion src/models/NavItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function copyPageItem(NavItem $targetNavItem)
if ($blockItem->save()) {
// store the old block id with the new block id
$idLink[$block['id']] = $blockItem->id;
}
}

unset($blockItem);
}
Expand Down
6 changes: 3 additions & 3 deletions src/models/NavItemModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @property string $controller_name
* @property string $action_name
* @property string $action_params
*
*
* @author Basil Suter <[email protected]>
* @since 1.0.0
*/
Expand Down Expand Up @@ -59,11 +59,11 @@ public function init()
{
parent::init();

$this->on(self::EVENT_AFTER_FIND, function() {
$this->on(self::EVENT_AFTER_FIND, function () {
$this->action_params = $this->getDecodedActionParams();
});

$this->on(self::EVENT_BEFORE_VALIDATE, function() {
$this->on(self::EVENT_BEFORE_VALIDATE, function () {
$this->action_params = $this->getEncodedActionParams();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/LangSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private static function getDataArray()

/**
* Prefix the current link with the dedicated host info.
*
*
* Assuming hostInfoMapping is defined in composition component, the correct domain will be taken from the
* language information.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/src/frontend/BootstrapErrorPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function testBootstrap()
$this->expectException('yii\web\HeadersAlreadySentException');
$this->app->errorHandler->trigger(ErrorHandler::EVENT_BEFORE_EXCEPTION_RENDER, $event);
}
}
}
4 changes: 2 additions & 2 deletions tests/src/injectors/ActiveQuerySelectInjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testVariableNotFoundId()
{
$block = new TestBlock();
$block->setVarValues([
'foobar' => 2,
'foobar' => 0,
]);

$injector = new ActiveQuerySelectInjector([
Expand All @@ -72,4 +72,4 @@ public function testVariableNotFoundId()

$this->assertFalse($block->getExtraValue('foobar'));
}
}
}
4 changes: 2 additions & 2 deletions tests/src/menu/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ public function testGoDown()
$itemWithParent = (new Query)->where(['nav_id' => 10])->one();

$this->assertSame(2, $itemWithParent->depth);
$f = $itemWithParent->down(function(Item $item) {
$f = $itemWithParent->down(function (Item $item) {
if ($item->depth == 1) {
return $item;
}
});

$this->assertSame(1, $f->depth);

$this->assertFalse($itemWithParent->down(function(Item $item) {
$this->assertFalse($itemWithParent->down(function (Item $item) {
// just do nothing means pass all elements.
}));
}
Expand Down

0 comments on commit f6fa1fa

Please sign in to comment.