diff --git a/config/Migrations/20160308182244_TranslateInitialMigration.php b/config/Migrations/20160308182244_TranslateInitialMigration.php index 25f26af..7602ab8 100644 --- a/config/Migrations/20160308182244_TranslateInitialMigration.php +++ b/config/Migrations/20160308182244_TranslateInitialMigration.php @@ -1,4 +1,5 @@ migrate('Croogo/Translate'); } -/** - * onDeactivate will be called if this returns true - * - * @param object $controller Controller - * @return boolean - */ + /** + * onDeactivate will be called if this returns true + * + * @param object $controller Controller + * @return boolean + */ public function beforeDeactivation(&$controller) { return true; } -/** - * Called after deactivating the plugin in ExtensionsPluginsController::admin_toggle() - * - * @param object $controller Controller - * @return void - */ + /** + * Called after deactivating the plugin in ExtensionsPluginsController::admin_toggle() + * + * @param object $controller Controller + * @return void + */ public function onDeactivation(&$controller) { $Acos = TableRegistry::get('Croogo/Acl.Acos'); diff --git a/config/Seeds/I18nSeed.php b/config/Seeds/I18nSeed.php index 2b95918..1bc1e67 100644 --- a/config/Seeds/I18nSeed.php +++ b/config/Seeds/I18nSeed.php @@ -1,4 +1,5 @@ '1', 'field' => 'title', 'content' => 'Halo Dunia', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '2', @@ -38,10 +39,10 @@ public function run() 'foreign_key' => '1', 'field' => 'excerpt', 'content' => '', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '3', @@ -50,10 +51,10 @@ public function run() 'foreign_key' => '1', 'field' => 'body', 'content' => '
Selamat Datang di Croogo. Ini adalah tulisan pertama anda. Anda dapat mengedit atau menghapusnya dari panel admin.
', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '4', @@ -62,10 +63,10 @@ public function run() 'foreign_key' => '2', 'field' => 'title', 'content' => 'Tentang', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '5', @@ -74,10 +75,10 @@ public function run() 'foreign_key' => '2', 'field' => 'excerpt', 'content' => '', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '6', @@ -86,10 +87,10 @@ public function run() 'foreign_key' => '2', 'field' => 'body', 'content' => 'Ini merupakan contoh halaman Croogo, Anda dapat menyunting ini untuk menaruh informasi tentang diri Anda atau situs Anda.
', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '7', @@ -98,10 +99,10 @@ public function run() 'foreign_key' => '8', 'field' => 'title', 'content' => 'Tentang', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '8', @@ -110,10 +111,10 @@ public function run() 'foreign_key' => '8', 'field' => 'description', 'content' => '', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '9', @@ -122,10 +123,10 @@ public function run() 'foreign_key' => '7', 'field' => 'title', 'content' => 'Depan', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '10', @@ -134,10 +135,10 @@ public function run() 'foreign_key' => '7', 'field' => 'description', 'content' => '', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '11', @@ -146,10 +147,10 @@ public function run() 'foreign_key' => '15', 'field' => 'title', 'content' => 'Kontak', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '12', @@ -158,10 +159,10 @@ public function run() 'foreign_key' => '15', 'field' => 'description', 'content' => '', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '13', @@ -170,10 +171,10 @@ public function run() 'foreign_key' => '7', 'field' => 'title', 'content' => 'Kategori', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '14', @@ -182,10 +183,10 @@ public function run() 'foreign_key' => '7', 'field' => 'body', 'content' => '[vocabulary:categories type="blog"]', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '15', @@ -194,10 +195,10 @@ public function run() 'foreign_key' => '3', 'field' => 'title', 'content' => 'Tentang', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '16', @@ -206,10 +207,10 @@ public function run() 'foreign_key' => '3', 'field' => 'body', 'content' => 'Ini adalah isi dari blok Anda. Dapat dimodifikasi di panel admin.', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], [ 'id' => '17', @@ -218,10 +219,10 @@ public function run() 'foreign_key' => '9', 'field' => 'title', 'content' => 'Tulisan Baru', - 'updated' => NULL, - 'updated_by' => NULL, - 'created' => NULL, - 'created_by' => NULL, + 'updated' => null, + 'updated_by' => null, + 'created' => null, + 'created_by' => null, ], ]; diff --git a/config/bootstrap.php b/config/bootstrap.php index 4201922..c033910 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -1,7 +1,6 @@ on( 'Server.buildMiddleware', - function($event, $stack) use ($siteLocale, $languages) { + function ($event, $stack) use ($siteLocale, $languages) { $stack->add(new I18nMiddleware([ 'defaultLanguage' => $siteLocale, 'languages' => $languages, diff --git a/config/routes.php b/config/routes.php index c113534..6eef1fc 100644 --- a/config/routes.php +++ b/config/routes.php @@ -17,7 +17,7 @@ Router::plugin('Croogo/Translate', ['path' => '/'], function (RouteBuilder $route) { $route->prefix('admin', function (RouteBuilder $route) { - $route->scope('/translate', [], function(RouteBuilder $route) { + $route->scope('/translate', [], function (RouteBuilder $route) { $route->fallbacks(); }); }); diff --git a/src/Controller/Admin/TranslateController.php b/src/Controller/Admin/TranslateController.php index 1c42759..7e16ef1 100644 --- a/src/Controller/Admin/TranslateController.php +++ b/src/Controller/Admin/TranslateController.php @@ -3,10 +3,8 @@ namespace Croogo\Translate\Controller\Admin; use Cake\Core\Configure; -use Cake\Utility\Hash; -use Cake\Utility\Inflector; use Cake\ORM\TableRegistry; -use Croogo\Translate\Controller\Admin\AppController; +use Cake\Utility\Inflector; /** * Translate Controller @@ -28,19 +26,20 @@ public function initialize() $this->loadModel('Croogo/Settings.Languages'); } -/** - * index - * - * @param int $id - * @param string $modelAlias - * @return void - */ + /** + * index + * + * @param int $id + * @param string $modelAlias + * @return void + */ public function index() { $id = $this->getRequest()->query('id'); $modelAlias = $this->getRequest()->query('model'); if ($id == null) { $this->Flash->error(__d('croogo', 'Invalid ID.')); + return $this->redirect([ 'plugin' => null, 'controller' => Inflector::pluralize($modelAlias), @@ -54,6 +53,7 @@ public function index() if (!is_array($config)) { $this->Flash->error(__d('croogo', 'Invalid model.')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => Inflector::pluralize($modelAlias), @@ -66,6 +66,7 @@ public function index() $record = $Model->get($id); if (!isset($record->id)) { $this->Flash->error(__d('croogo', 'Invalid record.')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => $model, @@ -81,7 +82,7 @@ public function index() $languages = $this->Languages->find('list', [ 'keyField' => 'locale', - 'valueField' => function($language) { + 'valueField' => function ($language) { return $language->get('label'); }, 'conditions' => [ @@ -92,13 +93,13 @@ public function index() $this->set(compact('translations', 'record', 'modelAlias', 'displayField', 'id', 'languages')); } -/** - * edit - * - * @param int $id - * @param string $modelAlias - * @return void - */ + /** + * edit + * + * @param int $id + * @param string $modelAlias + * @return void + */ public function edit($id = null) { $id = $this->getRequest()->query('id'); @@ -107,6 +108,7 @@ public function edit($id = null) if (!$id && empty($this->getRequest()->data)) { $this->Flash->error(__d('croogo', 'Invalid ID.')); + return $this->redirect([ 'plugin' => null, 'controller' => Inflector::pluralize($modelAlias), @@ -116,6 +118,7 @@ public function edit($id = null) if (!$this->getRequest()->query('locale')) { $this->Flash->error(__d('croogo', 'Invalid locale')); + return $this->redirect([ 'plugin' => null, 'controller' => Inflector::pluralize($modelAlias), @@ -134,6 +137,7 @@ public function edit($id = null) ])->first(); if (!$language->id) { $this->Flash->error(__d('croogo', 'Invalid Language')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => $model, @@ -146,6 +150,7 @@ public function edit($id = null) $record = $Model->get($id); if (!$record->id) { $this->Flash->error(__d('croogo', 'Invalid record.')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => $model, @@ -174,7 +179,7 @@ public function edit($id = null) 'controller' => 'Translate', 'action' => 'index', '?' => [ - 'id'=> $id, + 'id' => $id, 'model' => $modelAlias, 'locale' => $locale, ], @@ -182,29 +187,37 @@ public function edit($id = null) if (isset($this->getRequest()->data['apply'])) { $redirect['action'] = 'edit'; } + return $this->redirect($redirect); } else { $this->Flash->error(__d('croogo', 'Record could not be translated. Please, try again.')); } } $this->set(compact( - 'entity', 'fields', 'language', 'model', 'modelAlias', - 'displayField', 'id', 'locale' + 'entity', + 'fields', + 'language', + 'model', + 'modelAlias', + 'displayField', + 'id', + 'locale' )); } -/** - * delete - * - * @param int $id - * @param string $modelAlias - * @param string $locale - * @return void - */ + /** + * delete + * + * @param int $id + * @param string $modelAlias + * @param string $locale + * @return void + */ public function delete($id = null, $modelAlias = null, $locale = null) { if ($locale == null || $id == null) { $this->Flash->error(__d('croogo', 'Invalid Locale or ID')); + return $this->redirect([ 'plugin' => null, 'controller' => Inflector::pluralize($modelAlias), @@ -218,6 +231,7 @@ public function delete($id = null, $modelAlias = null, $locale = null) if (!is_array($config)) { $this->Flash->error(__d('croogo', 'Invalid model.')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => $model, @@ -229,6 +243,7 @@ public function delete($id = null, $modelAlias = null, $locale = null) $record = $Model->get($id); if (!isset($record->id)) { $this->Flash->error(__d('croogo', 'Invalid record.')); + return $this->redirect([ 'plugin' => $plugin, 'controller' => $model, diff --git a/src/Event/TranslateEventHandler.php b/src/Event/TranslateEventHandler.php index 5e22ee3..875c6cd 100644 --- a/src/Event/TranslateEventHandler.php +++ b/src/Event/TranslateEventHandler.php @@ -64,5 +64,4 @@ public function onBeforeRender($event) ]); $View->end(); } - } diff --git a/src/Middleware/I18nMiddleware.php b/src/Middleware/I18nMiddleware.php index d722aac..5e329af 100644 --- a/src/Middleware/I18nMiddleware.php +++ b/src/Middleware/I18nMiddleware.php @@ -9,7 +9,6 @@ use Cake\Utility\Hash; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Zend\Diactoros\Response\RedirectResponse; /** * I18nMiddleware diff --git a/src/Model/Behavior/TranslateBehavior.php b/src/Model/Behavior/TranslateBehavior.php index 66092f8..c95552f 100644 --- a/src/Model/Behavior/TranslateBehavior.php +++ b/src/Model/Behavior/TranslateBehavior.php @@ -5,7 +5,6 @@ use ArrayObject; use Cake\Event\Event; use Cake\I18n\I18n; -use Cake\Log\Log; use Cake\ORM\Behavior\TranslateBehavior as CakeTranslateBehavior; class TranslateBehavior extends CakeTranslateBehavior @@ -17,5 +16,4 @@ public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $opti $data['_locale'] = I18n::defaultLocale(); } } - } diff --git a/src/Routing/Filter/LocaleSelectorFilter.php b/src/Routing/Filter/LocaleSelectorFilter.php index 24d5d8c..06d9ee8 100644 --- a/src/Routing/Filter/LocaleSelectorFilter.php +++ b/src/Routing/Filter/LocaleSelectorFilter.php @@ -74,5 +74,4 @@ public function beforeDispatch(Event $event) I18n::setLocale($locale); } - } diff --git a/src/Template/Admin/Translate/edit.ctp b/src/Template/Admin/Translate/edit.ctp index c5e720a..063cb62 100644 --- a/src/Template/Admin/Translate/edit.ctp +++ b/src/Template/Admin/Translate/edit.ctp @@ -1,6 +1,6 @@ extend('/Common/admin_edit'); $this->assign('title', sprintf(__d('croogo', 'Translate content: %s (%s)'), $language->title, $language->native)); @@ -13,7 +13,7 @@ $this->Breadcrumbs ->add($entity->get($displayField)) ->add( __d('croogo', 'Translations'), - array( + [ 'plugin' => 'Croogo/Translate', 'controller' => 'Translate', 'action' => 'index', @@ -21,12 +21,12 @@ $this->Breadcrumbs 'id' => $id, 'model' => $modelAlias, ], - ) + ] ) ->add(__d('croogo', 'Translate (%s)', $language->title), $this->getRequest()->getRequestTarget()); -$this->append('form-start', $this->Form->create($entity, array( - 'url' => array( +$this->append('form-start', $this->Form->create($entity, [ + 'url' => [ 'plugin' => 'Croogo/Translate', 'controller' => 'Translate', 'action' => 'edit', @@ -36,8 +36,8 @@ $this->append('form-start', $this->Form->create($entity, array( 'model' => $modelAlias, 'locale' => $locale, ], - ) -))); + ] +])); $this->append('tab-heading'); echo $this->Croogo->adminTab(__d('croogo', 'Translate'), '#translate-main'); @@ -47,22 +47,22 @@ $this->end(); $this->append('tab-content'); echo $this->Html->tabStart('translate-main'); - foreach ($fields as $field): - $name = '_translations.' . $locale . '.' . $field; - echo $this->Form->input($name, [ - 'default' => $entity->get($field), - ]); - endforeach; +foreach ($fields as $field) : + $name = '_translations.' . $locale . '.' . $field; + echo $this->Form->input($name, [ + 'default' => $entity->get($field), + ]); +endforeach; echo $this->Html->tabEnd(); echo $this->Html->tabStart('translate-original'); - foreach ($fields as $field): - $name = '_original.' . $field; - echo $this->Form->input($name, [ - 'value' => $entity->$field, - 'readonly' => true, - ]); - endforeach; +foreach ($fields as $field) : + $name = '_original.' . $field; + echo $this->Form->input($name, [ + 'value' => $entity->$field, + 'readonly' => true, + ]); +endforeach; echo $this->Html->tabEnd(); $this->end(); @@ -89,4 +89,4 @@ $this->start('panels'); ]); echo $this->Html->div('card-buttons d-flex justify-content-center', $out); echo $this->Html->endBox(); -$this->end(); + $this->end(); diff --git a/src/Template/Admin/Translate/index.ctp b/src/Template/Admin/Translate/index.ctp index 2b1b74b..79e3185 100644 --- a/src/Template/Admin/Translate/index.ctp +++ b/src/Template/Admin/Translate/index.ctp @@ -5,7 +5,8 @@ use Cake\Utility\Inflector; $this->extend('Croogo/Core./Common/admin_index'); -$plugin = 'Croogo/Nodes'; $controller = 'Nodes'; +$plugin = 'Croogo/Nodes'; +$controller = 'Nodes'; $modelPath = $this->getRequest()->query('model'); list($plugin, $model) = pluginSplit($modelPath); $controller = $model; @@ -15,27 +16,27 @@ $crumbLabel = $model == 'Nodes' ? __d('croogo', 'Content') : Inflector::pluraliz $this->Breadcrumbs ->add( $crumbLabel, - array( + [ 'plugin' => Inflector::underscore($plugin), 'controller' => Inflector::underscore($controller), 'action' => 'index', - ) + ] ) ->add( $record->get($displayField), - array( + [ 'plugin' => Inflector::underscore($plugin), 'controller' => Inflector::underscore($controller), 'action' => 'edit', $record->id, - ) + ] ) ->add(__d('croogo', 'Translations'), $this->getRequest()->getRequestTarget()); $this->start('action-buttons'); $translateButton = $this->Html->link( __d('croogo', 'Translate in a new language'), - array( + [ 'plugin' => 'Croogo/Settings', 'controller' => 'Languages', 'action' => 'select', @@ -43,20 +44,20 @@ $this->start('action-buttons'); 'id' => $record->id, 'model' => $modelAlias, ], - ), - array( + ], + [ 'button' => 'secondary', 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', - ) + ] ); - if (!empty($languages)): + if (!empty($languages)) : $out = null; - foreach ($languages as $languageAlias => $languageDisplay): - if ($languageAlias == Configure::read('App.defaultLocale')): + foreach ($languages as $languageAlias => $languageDisplay) : + if ($languageAlias == Configure::read('App.defaultLocale')) : continue; endif; - $out .= $this->Croogo->adminAction($languageDisplay, array( + $out .= $this->Croogo->adminAction($languageDisplay, [ 'prefix' => 'admin', 'plugin' => 'Croogo/Translate', 'controller' => 'Translate', @@ -66,70 +67,72 @@ $this->start('action-buttons'); 'model' => $modelAlias, 'locale' => $languageAlias, ], - ), array( + ], [ 'button' => false, 'list' => true, 'class' => 'dropdown-item', - )); + ]); endforeach; - echo $this->Html->div('btn-group', + echo $this->Html->div( + 'btn-group', $translateButton . - $this->Html->tag('ul', $out, array('class' => 'dropdown-menu')) + $this->Html->tag('ul', $out, ['class' => 'dropdown-menu']) ); endif; -$this->end(); + $this->end(); -if (count($translations) == 0): - echo $this->Html->para(null, __d('croogo', 'No translations available.')); - return; -endif; + if (count($translations) == 0) : + echo $this->Html->para(null, __d('croogo', 'No translations available.')); -$this->append('table-heading'); - $tableHeaders = $this->Html->tableHeaders(array( + return; + endif; + + $this->append('table-heading'); + $tableHeaders = $this->Html->tableHeaders([ '', __d('croogo', 'Original'), __d('croogo', 'Title'), __d('croogo', 'Locale'), __d('croogo', 'Actions'), - )); + ]); echo $tableHeaders; -$this->end(); + $this->end(); -$this->append('table-body'); - $rows = array(); - foreach ($translations->_translations as $locale => $entity): - $actions = array(); - $actions[] = $this->Croogo->adminRowAction('', array( + $this->append('table-body'); + $rows = []; + foreach ($translations->_translations as $locale => $entity) : + $actions = []; + $actions[] = $this->Croogo->adminRowAction('', [ 'action' => 'edit', '?' => [ 'id' => $id, 'model' => $modelAlias, 'locale' => $locale, ], - ), array( + ], [ 'icon' => $this->Theme->getIcon('update'), 'tooltip' => __d('croogo', 'Edit this item'), - )); - $actions[] = $this->Croogo->adminRowAction('', array( + ]); + $actions[] = $this->Croogo->adminRowAction('', [ 'action' => 'delete', $id, urlencode($modelAlias), $locale, - ), array( + ], [ 'icon' => $this->Theme->getIcon('delete'), 'tooltip' => __d('croogo', 'Remove this item'), 'method' => 'post', - ), __d('croogo', 'Are you sure?')); + ], __d('croogo', 'Are you sure?')); $actions = $this->Html->div('item-actions', implode(' ', $actions)); - $rows[] = array( + $rows[] = [ '', $record->title, $entity->title, $locale, $actions, - ); + ]; endforeach; echo $this->Html->tableCells($rows); -$this->end(); + $this->end(); diff --git a/src/Translations.php b/src/Translations.php index d9a6032..3af08dc 100644 --- a/src/Translations.php +++ b/src/Translations.php @@ -11,25 +11,24 @@ namespace Croogo\Translate; use Cake\Core\Configure; -use Cake\Log\Log; -use Cake\Utility\Inflector; use Croogo\Core\Croogo; class Translations { -/** - * Read configured Translate.models and hook the appropriate behaviors - */ + /** + * Read configured Translate.models and hook the appropriate behaviors + */ public static function translateModels() { - $path ='prefix:admin/plugin:Croogo%2fTranslate/controller:Translate/action:index/?id=:id&model={{model}}'; + $path = 'prefix:admin/plugin:Croogo%2fTranslate/controller:Translate/action:index/?id=:id&model={{model}}'; foreach (Configure::read('Translate.models') as $encoded => $config) { $model = base64_decode($encoded); Croogo::hookBehavior($model, 'Croogo/Translate.Translate', $config); $action = str_replace('.', '.Admin/', $model . '/index'); $url = str_replace('{{model}}', urlencode($model), $path); - Croogo::hookAdminRowAction($action, + Croogo::hookAdminRowAction( + $action, __d('croogo', 'Translate'), [ $url => [ @@ -42,5 +41,4 @@ public static function translateModels() ); } } - } diff --git a/tests/TestCase/Controller/TranslateControllerTest.php b/tests/TestCase/Controller/TranslateControllerTest.php index 1f92d93..eac3503 100644 --- a/tests/TestCase/Controller/TranslateControllerTest.php +++ b/tests/TestCase/Controller/TranslateControllerTest.php @@ -29,9 +29,9 @@ class TranslateControllerTest extends CroogoControllerTestCase 'plugin.Croogo/Users.Role', ]; -/** - * setUp - */ + /** + * setUp + */ public function setUp() { parent::setUp(); @@ -55,9 +55,9 @@ public function setUp() $this->TranslateController->Security->Session = $this->getMock('Session'); } -/** - * test admin_index action - */ + /** + * test admin_index action + */ public function testAdminIndex() { $this->testAction('/admin/translate/translate/index/2/Node'); @@ -65,9 +65,9 @@ public function testAdminIndex() $this->assertEquals('Node', $this->vars['modelAlias']); } -/** - * test admin_edit action with invalid language - */ + /** + * test admin_edit action with invalid language + */ public function testAdminEditWithBogusLanguage() { $this->expectFlashAndRedirect('Invalid Language', null, [ @@ -78,9 +78,9 @@ public function testAdminEditWithBogusLanguage() $this->testAction('/admin/translate/translate/edit/2/Node/locale:lol'); } -/** - * test admin_edit action - */ + /** + * test admin_edit action + */ public function testAdminEdit() { $this->testAction('/admin/translate/translate/edit/2/Node/locale:eng'); @@ -90,9 +90,9 @@ public function testAdminEdit() $this->assertEquals(2, $this->controller->request->data['Node']['id']); } -/** - * test saving translation with admin_edit action - */ + /** + * test saving translation with admin_edit action + */ public function testSaveWithAdminEdit() { $this->expectFlashAndRedirect('Record has been translated'); diff --git a/tests/TestCase/Model/Behavior/CroogoTranslateBehaviorTest.php b/tests/TestCase/Model/Behavior/CroogoTranslateBehaviorTest.php index 094f782..4f73cd5 100644 --- a/tests/TestCase/Model/Behavior/CroogoTranslateBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/CroogoTranslateBehaviorTest.php @@ -36,11 +36,11 @@ class CroogoTranslateBehaviorTest extends CroogoTestCase public $Node = null; -/** - * setUp - * - * @return void - */ + /** + * setUp + * + * @return void + */ public function setUp() { parent::setUp(); @@ -55,11 +55,11 @@ public function setUp() ]); } -/** - * tearDown - * - * @return void - */ + /** + * tearDown + * + * @return void + */ public function tearDown() { parent::tearDown(); @@ -67,11 +67,11 @@ public function tearDown() ClassRegistry::flush(); } -/** - * testSaveTranslation - * - * @return void - */ + /** + * testSaveTranslation + * + * @return void + */ public function testSaveTranslation() { $translationData = [ @@ -84,9 +84,9 @@ public function testSaveTranslation() $this->assertEqual($about['Node']['title'], 'About [Translated in Bengali]'); } -/** - * testSaveTranslationShouldFlushCacheOfModelBeingTranslated - */ + /** + * testSaveTranslationShouldFlushCacheOfModelBeingTranslated + */ public function testSaveTranslationShouldFlushCacheOfModelBeingTranslated() { $translationData = ['Node' => ['title' => 'Some french content']]; @@ -103,9 +103,9 @@ public function testSaveTranslationShouldFlushCacheOfModelBeingTranslated() $this->__addNewTranslation(2, 'fra', $translationData); } -/** - * __addNewTranslation - */ + /** + * __addNewTranslation + */ private function __addNewTranslation($id, $locale, $translationData) { $this->Node->id = $id;