-
- = $this->cell('CakeAdmin.Dashboard::welcome') ?>
-
+
+
+ = __('Menu') ?>
+
+ = $this->Menu->render('cakeadmin_main'); ?>
+
+
+
+
= __('Dashboard') ?>
-
-
-
- = $this->cell('CakeAdmin.Dashboard::gettingStarted') ?>
- = $this->cell('CakeAdmin.Dashboard::plugins'); ?>
- = $this->cell('CakeAdmin.Dashboard::gettingHelp'); ?>
-
-
- = $this->cell('CakeAdmin.Dashboard::latestPosts'); ?>
-
-
-
-
-
- = $this->cell('CakeAdmin.Dashboard::aboutUs') ?>
-
-
\ No newline at end of file
diff --git a/src/Template/Admin/Notifications/index.ctp b/src/Template/Admin/Notifications/index.ctp
deleted file mode 100644
index 2ac32da..0000000
--- a/src/Template/Admin/Notifications/index.ctp
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- unread): echo ''; endif; ?>
- = h($notification->get('title')) ?>
- unread): echo ' '; endif; ?>
-
- = h($notification->get('body')) ?>
- = h($notification->get('created')->timeAgoInWords([
- 'accuracy' => ['month' => 'month'],
- 'end' => '1 year'
- ])) ?>
-
-
-
-
\ No newline at end of file
diff --git a/src/Template/Admin/PostTypes/add.ctp b/src/Template/Admin/PostTypes/add.ctp
index 4d41afa..d064de7 100644
--- a/src/Template/Admin/PostTypes/add.ctp
+++ b/src/Template/Admin/PostTypes/add.ctp
@@ -1,31 +1,10 @@
-PostTypes->type($type);
-?>
-
-= $this->PostTypes->header() ?>
-
-= $this->PostTypes->indexButton() ?>
-
-
-= $this->PostTypes->createForm($entity) ?>
-
- = $this->PostTypes->fieldset([
- 'on' => ['both', 'add']
- ]) ?>
-
-= $this->PostTypes->submitForm() ?>
-= $this->PostTypes->endForm() ?>
+
+
+ = __('Menu') ?>
+
+ = $this->Menu->render('cakeadmin_main'); ?>
+
+
+
+
= __('Add {0}', [$this->PostType->name('singular')]) ?>
+
diff --git a/src/Template/Admin/PostTypes/edit.ctp b/src/Template/Admin/PostTypes/edit.ctp
index 8da4d55..17f3e8e 100644
--- a/src/Template/Admin/PostTypes/edit.ctp
+++ b/src/Template/Admin/PostTypes/edit.ctp
@@ -1,32 +1,10 @@
-PostTypes->type($type);
-?>
-
-= $this->PostTypes->header() ?>
-
-= $this->PostTypes->indexButton() ?>
-
-
-= $this->PostTypes->createForm($entity) ?>
-
- = $this->PostTypes->fieldset([
- 'label' => 'Edit ',
- 'on' => ['both', 'edit']
- ]) ?>
-
-= $this->PostTypes->submitForm() ?>
-= $this->PostTypes->endForm() ?>
+
+
+ = __('Menu') ?>
+
+ = $this->Menu->render('cakeadmin_main'); ?>
+
+
+
+
= __('Edit {0}', [$this->PostType->name('singular')]) ?>
+
diff --git a/src/Template/Admin/PostTypes/index.ctp b/src/Template/Admin/PostTypes/index.ctp
index b542e35..e13f6a7 100644
--- a/src/Template/Admin/PostTypes/index.ctp
+++ b/src/Template/Admin/PostTypes/index.ctp
@@ -1,42 +1,49 @@
-
+
+ = __('Menu') ?>
-$this->PostTypes->type($type);
-$this->PostTypes->data($data);
-?>
-
-= $this->PostTypes->header() ?>
-
-= $this->PostTypes->addButton() ?>
+ = $this->Menu->render('cakeadmin_main'); ?>
+
+
+
+
= __('View all {0}', [$this->PostType->name('plural')]) ?>
-
-= $this->PostTypes->searchFilter($searchFilters) ?>
+
+
+
+ PostType->tableColumns() as $column => $options): ?>
+ = $this->Paginator->sort($column) ?>
+
+ = __('Actions') ?>
+
+
+
+
+
+ PostType->tableColumns() as $column => $options): ?>
+ = h($item->get($options['get'])) ?>
+
+
+ = $this->PostType->viewLink($item) ?>
+ = $this->PostType->editLink($item) ?>
+ = $this->PostType->deleteLink($item) ?>
+
+
+
+
+
+
+
+
= $this->Paginator->counter() ?>
+
-
-
- = $this->PostTypes->tableHead() ?>
-
-
- = $this->PostTypes->tableBody() ?>
-
-
-
-
-
= $this->Paginator->counter(); ?>
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/src/Template/Admin/PostTypes/view.ctp b/src/Template/Admin/PostTypes/view.ctp
index b6020bb..f7ce131 100644
--- a/src/Template/Admin/PostTypes/view.ctp
+++ b/src/Template/Admin/PostTypes/view.ctp
@@ -1,5 +1,13 @@
-
+
+ = __('Menu') ?>
-debug($type);
+ = $this->Menu->render('cakeadmin_main'); ?>
+
+
+
+
= __('View {0}', [$this->PostType->name('singular')]) ?>
-?>
\ No newline at end of file
+
+
+
diff --git a/src/Template/Admin/Settings/index.ctp b/src/Template/Admin/Settings/index.ctp
deleted file mode 100644
index 1a48db8..0000000
--- a/src/Template/Admin/Settings/index.ctp
+++ /dev/null
@@ -1,27 +0,0 @@
-
= $prefix ?>
-
-= $this->Menu->menu('navbar', 'CakeAdmin.NavbarMenu') ?>
-
-Form->create();
-
-foreach ($settings as $id => $setting) {
-
- echo $this->Form->input($id . '.id', [
- 'type' => 'hidden',
- 'value' => $setting->id,
- ]);
-
- $name = explode('.', $setting->name);
-
- echo $this->Form->input($id . '.value', [
- 'type' => (($setting->type) ? $setting->type : 'text'),
- 'label' => ucfirst(end($name)) . (($setting->description) ? ' - ' . $setting->description : ''),
- 'options' => (($setting->options) ? $setting->options : ''),
- 'value' => $setting->value,
- ]);
-}
-
-echo $this->Form->button(__d('CakeAdmin', 'Submit'));
-
-echo $this->Form->end();
\ No newline at end of file
diff --git a/src/Template/Admin/Users/forgot.ctp b/src/Template/Admin/Users/forgot.ctp
deleted file mode 100644
index d929883..0000000
--- a/src/Template/Admin/Users/forgot.ctp
+++ /dev/null
@@ -1,11 +0,0 @@
-
- = $this->Flash->render('auth') ?>
- = $this->Form->create() ?>
-
- = __d('CakeAdmin', 'Forgot password') ?>
- = $this->Form->input('email') ?>
-
- = $this->Form->button(__d('CakeAdmin', 'Request')); ?>
- = $this->Form->end() ?>
- = $this->Html->link('Login', ['action' => 'login']); ?>
-
\ No newline at end of file
diff --git a/src/Template/Admin/Users/login.ctp b/src/Template/Admin/Users/login.ctp
index 7ac6ee1..1dd7c0d 100644
--- a/src/Template/Admin/Users/login.ctp
+++ b/src/Template/Admin/Users/login.ctp
@@ -1,32 +1,23 @@
set('title', __d('CakeAdmin', 'Login'));
-
?>
-
- = $this->Flash->render('auth') ?>
- = $this->Form->create() ?>
-
- = __d('CakeAdmin', 'Login') ?>
- = $this->Form->input(Configure::read('CA.fields.username')) ?>
- = $this->Form->input(Configure::read('CA.fields.password'), ['value' => '']) ?>
-
- = $this->Form->button(__d('CakeAdmin', 'Login')); ?>
- = $this->Form->end() ?>
- = $this->Html->link(__d('CakeAdmin', 'Forgot password'), ['action' => 'forgot']); ?>
+
+
+
+
+
= __('Login') ?>
+
+ = $this->Flash->render('auth') ?>
+ = $this->Form->create() ?>
+
+ = __d('CakeAdmin', 'Login') ?>
+ = $this->Form->input(Configure::read('CA.fields.username')) ?>
+ = $this->Form->input(Configure::read('CA.fields.password'), ['value' => '']) ?>
+
+ = $this->Form->button(__d('CakeAdmin', 'Login')); ?>
+ = $this->Form->end() ?>
+ = $this->Html->link(__d('CakeAdmin', 'Forgot password'), ['action' => 'forgot']); ?>
+
diff --git a/src/Template/Admin/Users/reset.ctp b/src/Template/Admin/Users/reset.ctp
deleted file mode 100644
index 363e292..0000000
--- a/src/Template/Admin/Users/reset.ctp
+++ /dev/null
@@ -1,11 +0,0 @@
-
- = $this->Flash->render('auth') ?>
- = $this->Form->create() ?>
-
- = __d('CakeAdmin', 'New Password') ?>
- = $this->Form->input('new_password', ['type' => 'password', 'value' => '']) ?>
- = $this->Form->input('confirm_password', ['type' => 'password', 'value' => '']) ?>
-
- = $this->Form->button(__d('CakeAdmin', 'Save')); ?>
- = $this->Form->end() ?>
-
\ No newline at end of file
diff --git a/src/Template/Bake/post_type.ctp b/src/Template/Bake/post_type.ctp
new file mode 100644
index 0000000..e54a929
--- /dev/null
+++ b/src/Template/Bake/post_type.ctp
@@ -0,0 +1,21 @@
+\PostType;
+
+use Bakkerij\CakeAdmin\PostType\PostType;
+
+/**
+ * <%= $name %> PostType
+ */
+class <%= $name %>PostType extends PostType
+{
+
+ public function initialize()
+ {
+ $this->name('<%= $ptname %>');
+ $this->slug('<%= $ptslug %>');
+
+ $this->model('<%= $ptmodel %>');
+ }
+
+}
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/about_us.ctp b/src/Template/Cell/Dashboard/about_us.ctp
deleted file mode 100644
index c7b7962..0000000
--- a/src/Template/Cell/Dashboard/about_us.ctp
+++ /dev/null
@@ -1,3 +0,0 @@
-
About Us
-DEVELOPERS DEVELOPERS DEVELOPERS
-
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/getting_help.ctp b/src/Template/Cell/Dashboard/getting_help.ctp
deleted file mode 100644
index 59ffeaa..0000000
--- a/src/Template/Cell/Dashboard/getting_help.ctp
+++ /dev/null
@@ -1,14 +0,0 @@
-
Getting Help
-
- $item): ?>
-
-
- = $title ?>
-
- = $item['description'] ?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/getting_started.ctp b/src/Template/Cell/Dashboard/getting_started.ctp
deleted file mode 100644
index 7724ce0..0000000
--- a/src/Template/Cell/Dashboard/getting_started.ctp
+++ /dev/null
@@ -1,14 +0,0 @@
-
Getting Started
-
- $item): ?>
-
-
- = $title ?>
-
- = $item['description'] ?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/latest_posts.ctp b/src/Template/Cell/Dashboard/latest_posts.ctp
deleted file mode 100644
index 21f8dc0..0000000
--- a/src/Template/Cell/Dashboard/latest_posts.ctp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
Latest Posts
-
-
-
- = $post['title'] ?>
-
-
- = "Author: " . $post['dc:creator'] . " | " . $time->timeAgoInWords() ?>
-
-
-
-
-
-
-Read more at
cakemanager.org .
-
-
-
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/plugins.ctp b/src/Template/Cell/Dashboard/plugins.ctp
deleted file mode 100644
index d059e56..0000000
--- a/src/Template/Cell/Dashboard/plugins.ctp
+++ /dev/null
@@ -1,14 +0,0 @@
-
Useful Plugins from the CakeManager Team
-
- $item): ?>
-
-
- = $title ?>
-
- = $item['description'] ?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Template/Cell/Dashboard/welcome.ctp b/src/Template/Cell/Dashboard/welcome.ctp
deleted file mode 100644
index 394ec53..0000000
--- a/src/Template/Cell/Dashboard/welcome.ctp
+++ /dev/null
@@ -1,5 +0,0 @@
-
= $welcome ?>
-
- The CakeManager Plugin allows you to easily manage your website. The CakeManager Team provides you with many useful plugins for CakePHP 3.x.
-
-
\ No newline at end of file
diff --git a/src/Template/Email/html/reset_password.ctp b/src/Template/Email/html/reset_password.ctp
deleted file mode 100644
index 0cf4c90..0000000
--- a/src/Template/Email/html/reset_password.ctp
+++ /dev/null
@@ -1,25 +0,0 @@
-
- Hello = $user->email ?>,
-
-
-
- You've got this e-mail because you lost your password at = $baseUrl ?> .
- Via the following url you will be able to set a new password: Reset new Password .
-
-
-
- After you've chosen your new password you are able to login at: = $loginUrl ?> .
-
-
-
-
- If you didn't request a new password, you can ignore this e-mail and continue your account at = $baseUrl ?>.
-
-
-
- Greetz,
-
-
-
- = $baseUrl ?>
-
\ No newline at end of file
diff --git a/src/Template/Email/text/reset_password.ctp b/src/Template/Email/text/reset_password.ctp
deleted file mode 100644
index 9176777..0000000
--- a/src/Template/Email/text/reset_password.ctp
+++ /dev/null
@@ -1,12 +0,0 @@
-Hello = $user->email ?>,
-
-You've got this e-mail because you lost your password at = $baseUrl ?>.
-Via the following url you will be able to set a new password: = $resetUrl ?>.
-
-After you've chosen your new password you are able to login at: = $loginUrl ?>.
-
-If you didn't request a new password, you can ignore this e-mail and continue your account at = $baseUrl ?>.
-
-Greetz,
-
-= $baseUrl ?>
diff --git a/src/Template/Layout/Email/html/default.ctp b/src/Template/Layout/Email/html/default.ctp
deleted file mode 100644
index 3b28b4c..0000000
--- a/src/Template/Layout/Email/html/default.ctp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
= $this->fetch('title') ?>
-
-
-= $this->fetch('content') ?>
-
-
\ No newline at end of file
diff --git a/src/Template/Layout/Email/text/default.ctp b/src/Template/Layout/Email/text/default.ctp
deleted file mode 100644
index ac2bcf1..0000000
--- a/src/Template/Layout/Email/text/default.ctp
+++ /dev/null
@@ -1,16 +0,0 @@
-
-= $this->fetch('content') ?>
diff --git a/src/Template/Layout/default.ctp b/src/Template/Layout/default.ctp
deleted file mode 100644
index bb49069..0000000
--- a/src/Template/Layout/default.ctp
+++ /dev/null
@@ -1,71 +0,0 @@
-assign('title', $title);
-?>
-
-
-
- = $this->Html->charset() ?>
-
-
- = $this->fetch('title') ?>
-
- = $this->Html->meta('icon') ?>
-
- = $this->Html->css('CakeAdmin.base') ?>
- = $this->Html->css('CakeAdmin.cake') ?>
- = $this->Html->css('CakeAdmin.custom') ?>
-
- = $this->fetch('meta') ?>
- = $this->fetch('css') ?>
- = $this->fetch('script') ?>
-
-
-
-
-
-
- = $this->Flash->render() ?>
-
-
-
-
= __d('CakeAdmin', 'Menu') ?>
-
- = $this->Menu->menu('main', 'CakeAdmin.MainMenu') ?>
-
-
-
-
- = $this->fetch('content') ?>
-
-
-
-
-
-
-
diff --git a/src/Template/Layout/login.ctp b/src/Template/Layout/login.ctp
deleted file mode 100644
index 69da831..0000000
--- a/src/Template/Layout/login.ctp
+++ /dev/null
@@ -1,61 +0,0 @@
-assign('title', $title);
-?>
-
-
-
- = $this->Html->charset() ?>
-
-
- = $this->fetch('title') ?>
-
- = $this->Html->meta('icon') ?>
-
- = $this->Html->css('CakeAdmin.base') ?>
- = $this->Html->css('CakeAdmin.cake') ?>
- = $this->Html->css('CakeAdmin.custom') ?>
-
- = $this->fetch('meta') ?>
- = $this->fetch('css') ?>
- = $this->fetch('script') ?>
-
-
-
-
-
-
- = $this->Flash->render() ?>
-
-
-
- = $this->fetch('content') ?>
-
-
-
-
-
-
-
diff --git a/src/View/Cell/DashboardCell.php b/src/View/Cell/DashboardCell.php
deleted file mode 100644
index 1a52214..0000000
--- a/src/View/Cell/DashboardCell.php
+++ /dev/null
@@ -1,155 +0,0 @@
-set('welcome', "Welcome to your CakeAdmin admin panel.");
- }
-
- /**
- * Latest Posts method.
- *
- * @return void
- */
- public function latestPosts()
- {
- $rss = file_get_contents('http://cakemanager.org/rss', false);
-
- if ($rss) {
- $xml = Xml::toArray(Xml::build($rss));
- $data = $xml['rss']['channel']['item'];
- }
-
- $this->set('posts', (isset($data) ? $data : []));
- }
-
- /**
- * Getting Started method
- *
- * @return void
- */
- public function gettingStarted()
- {
- $links = [
- 'CakeManager Docs' => [
- 'url' => 'http://cakemanager.org/docs/cakeadmin/1.0/',
- 'description' => 'Documentation about the CakeAdmin Plugin.'
- ],
- 'Quick Start Tutorial' => [
- 'url' => 'http://cakemanager.org/docs/cakeadmin/1.0/tutorials-and-examples/quick-start/',
- 'description' => 'Short tutorial about how to install the CakeAdmin Plugin',
- ]
- ];
-
- $this->set('list', $links);
- }
-
- /**
- * Getting Help method
- *
- * @return void
- */
- public function gettingHelp()
- {
- $links = [
- 'CakeManager Website' => [
- 'url' => 'http://cakemanager.org/',
- 'description' => 'Website of the CakeManager Team. Here you can find everything about us and our plugins.'
- ],
- 'Gitter' => [
- 'url' => 'https://gitter.im/cakemanager/cakephp-cakeadmin',
- 'description' => 'Chat Tool for GitHub to talk about issues and new features.',
- ],
- 'GitHub' => [
- 'url' => 'https://github.com/cakemanager/cakephp-cakeadmin/issues',
- 'description' => 'When there\'s something wrong, please open a new issue!',
- ],
- 'CakeAdmin Docs' => [
- 'url' => 'http://cakemanager.org/docs/cakeadmin/1.0/',
- 'description' => 'Documentation about the CakeAdmin Plugin.',
- ],
- 'CakePHP Utils Plugin Docs' => [
- 'url' => 'http://cakemanager.org/docs/utils/1.0/',
- 'description' => 'Documentation about the Utils Plugin.',
- ],
- ];
-
- $this->set('list', $links);
- }
-
- /**
- * Plugins method
- *
- * @return void
- */
- public function plugins()
- {
- $links = [
- 'Utils' => [
- 'url' => 'https://github.com/cakemanager/cakephp-utils',
- 'description' => 'Utilities for Cake 3.x.'
- ],
- 'Notifier' => [
- 'url' => 'https://github.com/cakemanager/cakephp-notifier',
- 'description' => 'Notification plugin for Cake 3.x'
- ],
- 'Who Is Online' => [
- 'url' => 'https://github.com/cakemanager/cakephp-whosonline',
- 'description' => 'Plugin to follow your users on your app.'
- ],
- 'PostTypes' => [
- 'url' => 'https://github.com/cakemanager/cakephp-posttypes',
- 'description' => 'Plugin to create dynamic CRUD for your admin-panel.'
- ],
- 'Settings' => [
- 'url' => 'https://github.com/cakemanager/cakephp-settings',
- 'description' => 'Plugin to save settings in your database and manage them.'
- ],
- ];
-
- $this->set('list', $links);
- }
-
- /**
- * About Us method
- *
- * @return void
- */
- public function aboutUs()
- {
- }
-}
diff --git a/src/View/Helper/HeaderLeftMenuHelper.php b/src/View/Helper/HeaderLeftMenuHelper.php
deleted file mode 100644
index fff2e30..0000000
--- a/src/View/Helper/HeaderLeftMenuHelper.php
+++ /dev/null
@@ -1,159 +0,0 @@
-' . $item['title'] . '';
-
- return $html;
- }
-
- /**
- * item
- *
- * Method to build an submenu item.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function subItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * beforeItem
- *
- * Method before an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function beforeItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * afterItem
- *
- * Method after an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function afterItem($item = [], $options = [])
- {
- return '';
- }
-}
diff --git a/src/View/Helper/MainMenuHelper.php b/src/View/Helper/MainMenuHelper.php
deleted file mode 100644
index 323ed7f..0000000
--- a/src/View/Helper/MainMenuHelper.php
+++ /dev/null
@@ -1,158 +0,0 @@
-' .
- $this->Html->link($item['title'], $item['url']) . '';
- return $html;
- }
-
- /**
- * item
- *
- * Method to build an submenu item.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function subItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * beforeItem
- *
- * Method before an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function beforeItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * afterItem
- *
- * Method after an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function afterItem($item = [], $options = [])
- {
- return '';
- }
-}
diff --git a/src/View/Helper/NavbarMenuHelper.php b/src/View/Helper/NavbarMenuHelper.php
deleted file mode 100644
index cc040a2..0000000
--- a/src/View/Helper/NavbarMenuHelper.php
+++ /dev/null
@@ -1,160 +0,0 @@
-';
- }
-
- /**
- * afterSubItem
- *
- * Method after a submenu item has been build.
- *
- * @param array $item The menu items.
- * @param array $options Options.
- * @return string
- */
- public function afterSubItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * beforeMenu
- *
- * Method before the menu has been build.
- *
- * @param array $menu The menu items.
- * @param array $options Options.
- * @return string
- */
- public function beforeMenu($menu = [], $options = [])
- {
- return '
';
- }
-
- /**
- * afterSubItem
- *
- * Method before a submenu item has been build.
- *
- * @param array $item The menu items.
- * @param array $options Options.
- * @return string
- */
- public function beforeSubItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * item
- *
- * Method to build an menu item.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function item($item = [], $options = [])
- {
- $html = '';
- $html .= (key_exists('active', $item) && $item['active'] ? '' : '');
- $html .= $this->Html->link($item['title'], $item['url']);
- $html .= (key_exists('active', $item) ? ' ' : '');
- $html .= ' ';
- return $html;
- }
-
- /**
- * item
- *
- * Method to build an submenu item.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function subItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * beforeItem
- *
- * Method before an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function beforeItem($item = [], $options = [])
- {
- return '';
- }
-
- /**
- * afterItem
- *
- * Method after an item has been build.
- *
- * @param array $item The menu item.
- * @param array $options Options.
- * @return string
- */
- public function afterItem($item = [], $options = [])
- {
- return '';
- }
-}
diff --git a/src/View/Helper/PostTypeHelper.php b/src/View/Helper/PostTypeHelper.php
new file mode 100644
index 0000000..c4c7340
--- /dev/null
+++ b/src/View/Helper/PostTypeHelper.php
@@ -0,0 +1,148 @@
+PostType->name('singular')`)
+ * - plural (calling `$this->PostType->name('plural')`)
+ *
+ * @param string|null $form Form
+ * @return mixed|string
+ */
+ public function name($form = null)
+ {
+ $name = $this->getPostType('name');
+
+ if ($form === 'singular') {
+ return Inflector::singularize($name);
+ }
+ if ($form === 'plural') {
+ return Inflector::pluralize($name);
+ }
+ return $name;
+ }
+
+ /**
+ * Returns slug
+ *
+ * @return string
+ */
+ public function slug()
+ {
+ return $this->getPostType('slug');
+ }
+
+ public function tableColumns()
+ {
+ return $this->getPostType('tableColumns');
+ }
+
+ public function indexLink()
+ {
+ return $this->Html->link(
+ __('List'),
+ [
+ '_name' => 'cakeadmin:posttype:index',
+ 'type' => $this->slug(),
+ ]
+ );
+ }
+
+ public function viewLink(EntityInterface $item)
+ {
+ if(!$this->getPostType()->action('view')) {
+ return;
+ }
+
+ return $this->Html->link(
+ __('View'),
+ [
+ '_name' => 'cakeadmin:posttype:view',
+ 'type' => $this->slug(),
+ $item->get('id')
+ ]
+ );
+ }
+
+ public function editLink(EntityInterface $item)
+ {
+ if(!$this->getPostType()->action('edit')) {
+ return;
+ }
+
+ return $this->Html->link(
+ __('Edit'),
+ [
+ '_name' => 'cakeadmin:posttype:edit',
+ 'type' => $this->slug(),
+ $item->get('id')
+ ]
+ );
+ }
+
+ public function deleteLink(EntityInterface $item)
+ {
+ if(!$this->getPostType()->action('delete')) {
+ return;
+ }
+
+ return $this->Form->postLink(
+ __('Delete'),
+ [
+ '_name' => 'cakeadmin:posttype:delete',
+ 'type' => $this->slug(),
+ $item->get('id')
+ ],
+ [
+ 'confirm' => __('Are you sure you want to delete # {0}?', $item->get('id'))
+ ]
+ );
+ }
+
+ /**
+ * Getter for PostType values.
+ *
+ * @param string|null $key Key like `name` or `slug`. Leave `null` to get full PostType
+ * @return mixed
+ */
+ protected function getPostType($key = null)
+ {
+ $postType = $this->config('data');
+ if ($key) {
+ return call_user_func([$postType, $key]);
+ }
+ return $postType;
+ }
+}
diff --git a/src/View/Helper/PostTypesHelper.php b/src/View/Helper/PostTypesHelper.php
deleted file mode 100644
index fd16be7..0000000
--- a/src/View/Helper/PostTypesHelper.php
+++ /dev/null
@@ -1,384 +0,0 @@
-_type = $type;
- }
- return $this->_type;
- }
-
- /**
- * data
- *
- * Setter and getter for $_data.
- *
- * @param array $data Data.
- * @return array|null
- */
- public function data($data = null)
- {
- if ($data) {
- $this->_data = $data;
- }
- return $this->_data;
- }
-
- /**
- * header
- *
- * Header of the page.
- *
- * ### Options
- * - `before` - Html before the header.
- * - `after` - Html after the header.
- *
- * @param array $options Options.
- * @return string
- */
- public function header($options = [])
- {
- $_options = [
- 'before' => '',
- 'after' => ' '
- ];
-
- $options = array_merge($_options, $options);
-
- return $options['before'] . h($this->_type['alias']) . $options['after'];
- }
-
- /**
- * indexButton
- *
- * An `index`-button with a link to the PostType List.
- *
- * ### Options
- * - `before` - Html before the button.
- * - `after` - Html after the button.
- *
- * The link will be created via the HtmlHelper.
- *
- * @param array $options Options.
- * @return string
- */
- public function indexButton($options = [])
- {
- $_options = [
- 'before' => 'All ',
- 'after' => '',
- ];
-
- $options = array_merge($_options, $options);
-
- $string = $options['before'] . h(Inflector::singularize($this->_type['alias'])) . $options['after'];
- return $this->Html->link($string, ['action' => 'add', 'type' => $this->_type['slug']]);
- }
-
- /**
- * addButton
- *
- * An `add`-button with a link to add a new PostType Entity.
- *
- * ### Options
- * - `before` - Html before the button.
- * - `after` - Html after the button.
- *
- * The link will be created via the HtmlHelper.
- *
- * @param array $options Options.
- * @return string
- */
- public function addButton($options = [])
- {
- $_options = [
- 'before' => 'New ',
- 'after' => '',
- ];
-
- $options = array_merge($_options, $options);
-
- $string = $options['before'] . h(Inflector::singularize($this->_type['alias'])) . $options['after'];
- return $this->Html->link($string, ['action' => 'add', 'type' => $this->_type['slug']]);
- }
-
- /**
- * searchFilter
- *
- * Filter-form to search with.
- *
- * @param array $searchFilters Filter-data.
- * @param array $options Options.
- * @return null|string
- */
- public function searchFilter($searchFilters, $options = [])
- {
- $_options = [];
-
- $options = array_merge($_options, $options);
-
- return ($searchFilters ? $this->Search->filterForm($searchFilters) : null);
- }
-
- /**
- * tableHead
- *
- * Generates the head of the table (all columns).
- *
- * ### Options
- * - `beforeActionHead` - Html before the action-column.
- * - `afterActionHead` - Html after the action-column.
- * - `actionsLabel` - Label of `Actions`.
- *
- * @param array $options Options.
- * @return string
- */
- public function tableHead($options = [])
- {
- $_options = [
- 'beforeActionHead' => '',
- 'afterActionHead' => ' ',
- 'actionsLabel' => __d('CakeAdmin', 'Actions'),
- ];
-
- $options = array_merge($_options, $options);
-
- $html = '';
-
- $html .= '';
-
- foreach ($this->type()['tableColumns'] as $column => $opt) :
- $html .= '';
- $html .= $this->Paginator->sort($column);
- $html .= ' ';
- endforeach;
-
- $html .= $options['beforeActionHead'] . $options['actionsLabel'] . $options['afterActionHead'];
- $html .= ' ';
-
- return $html;
- }
-
- /**
- * tableBody
- *
- * Generates the head of the table (all columns).
- *
- * ### Options
- * - `beforeActionBody` - Html before the actions-cell.
- * - `afterActionBody` - Html after the actions-cell.
- * - `viewLabel` - Label for the view-button.
- * - `editLabel` - Label for the edit-button.
- * - `deleteLabel` - Label for the delete-button.
- *
- * @param array $options Options.
- * @return string
- */
- public function tableBody($options = [])
- {
- $_options = [
- 'beforeActionBody' => '',
- 'afterActionBody' => ' ',
- 'viewLabel' => __d('CakeAdmin', 'View'),
- 'editLabel' => __d('CakeAdmin', 'Edit'),
- 'deleteLabel' => __d('CakeAdmin', 'Delete'),
- ];
-
- $options = array_merge($_options, $options);
-
- $html = '';
-
- foreach ($this->_data as $item) :
- $html .= '';
-
- foreach ($this->_type['tableColumns'] as $column => $opt) :
- $html .= '';
- $html .= $opt['before'];
- $html .= Hash::get($item->toArray(), $opt['get']);
- $html .= $opt['after'];
- $html .= ' ';
- endforeach;
-
- $html .= $options['beforeActionBody'];
-
- $html .= $this->Html->link($options['viewLabel'], [
- 'action' => 'view',
- 'type' => $this->type()['slug'],
- $item->get('id')
- ]) . ' ';
-
- $html .= $this->Html->link($options['editLabel'], [
- 'action' => 'edit',
- 'type' => $this->type()['slug'],
- $item->get('id')
- ]) . ' ';
-
- $html .= $this->Form->postLink($options['deleteLabel'], [
- 'action' => 'delete',
- 'type' => $this->type()['slug'],
- $item->get('id')
- ], [
- 'confirm' => __d('CakeAdmin', 'Are you sure you want to delete # {0}?', $item->get('id'))
- ]);
-
- $html .= $options['afterActionBody'];
-
- $html .= ' ';
- endforeach;
-
- return $html;
- }
-
- /**
- * createForm
- *
- * Initializer for a form.
- *
- * @param \Cake\ORM\Entity $entity Entity.
- * @param array $options Options.
- * @return mixed
- */
- public function createForm($entity, $options = [])
- {
- $options = array_merge($this->type()['formFields']['_create'], $options);
-
- return $this->Form->create($entity, $options);
- }
-
- /**
- * fieldset
- *
- * Generates a fieldset,
- *
- * ### Options
- * - `beforeLegend` - Html before the legend.
- * - `afterLegend` - Html after the legend.
- * - `label` - Label at top of the fieldset.
- * - `on` - Array with the validations (`both`, `add` or `edit`).
- *
- * @param array $options Options.
- * @return string
- */
- public function fieldset($options = [])
- {
- $_options = [
- 'beforeLegend' => '',
- 'afterLegend' => ' ',
- 'label' => __d('CakeAdmin', 'Add '),
- 'on' => ['both']
- ];
-
- $options = array_merge($_options, $options);
-
- $html = '';
-
- $html .= $options['beforeLegend'] . $options['label'] . $this->type()['alias'] . $options['afterLegend'];
-
- foreach ($this->type()['formFields'] as $field => $opt) :
- if (substr($field, 0, 1) !== '_') {
- if (in_array($opt['on'], $options['on'])) {
- echo $this->Form->input($field, $opt);
- }
- }
- endforeach;
-
- return $html;
- }
-
- /**
- * submitForm
- *
- * Submitbutton for the form.
- *
- * ### Options
- * - `submitLabel` - Label to use.
- * - `options` - Options for the button.
- *
- * @param array $options Options.
- * @return mixed
- */
- public function submitForm($options = [])
- {
- $_options = [
- 'submitLabel' => __d('CakeAdmin', 'Submit'),
- 'options' => [],
- ];
-
- $options = array_merge($_options, $options);
-
- return $this->Form->button($options['submitLabel'], $options['options']);
- }
-
- /**
- * endForm
- *
- * Ends the form.
- *
- * @return mixed
- */
- public function endForm()
- {
- return $this->Form->end();
- }
-}
diff --git a/tests/App/Model/Entity/Article.php b/tests/App/Model/Entity/Article.php
deleted file mode 100644
index 681c508..0000000
--- a/tests/App/Model/Entity/Article.php
+++ /dev/null
@@ -1,21 +0,0 @@
-hasMany('articles');
- }
-}
diff --git a/tests/App/Model/Table/BooksTable.php b/tests/App/Model/Table/BooksTable.php
deleted file mode 100644
index c301aff..0000000
--- a/tests/App/Model/Table/BooksTable.php
+++ /dev/null
@@ -1,71 +0,0 @@
-belongsTo('authors');
- }
-
- public function postType()
- {
- return [
- 'model' => 'Books',
- 'menu' => false,
- 'menuWeight' => 25,
- 'slug' => 'books',
- 'name' => 'Cake Books',
- 'alias' => 'CakeBooks',
- 'aliasLc' => 'cakebooks',
- 'singularAlias' => 'Cake Book',
- 'singularAliasLc' => 'cake book',
- 'description' => 'Books are written by authors.',
- 'actions' => [
- 'index' => false,
- 'add' => false,
- 'edit' => false,
- 'view' => false,
- 'delete' => false
- ],
- 'filters' => [
- 'title'
- ],
- 'contain' => [
- 'authors'
- ],
- 'query' => function ($query) {
- return $query;
- },
- 'tableColumns' => [
- 'id',
- 'author_id',
- 'title',
- 'body',
- 'published'
- ],
- 'formFields' => [
- 'id',
- 'author_id',
- 'title'
- ]
- ];
- }
-}
diff --git a/tests/App/Template/Error/error500.ctp b/tests/App/Template/Error/error500.ctp
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/App/Template/Layout/error.ctp b/tests/App/Template/Layout/error.ctp
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/App/View/AppView.php b/tests/App/View/AppView.php
deleted file mode 100644
index 5d22bc4..0000000
--- a/tests/App/View/AppView.php
+++ /dev/null
@@ -1,35 +0,0 @@
-loadHelper('Html');`
- *
- * @return void
- */
- public function initialize()
- {
- }
-}
diff --git a/tests/Fixture/AdministratorsFixture.php b/tests/Fixture/AdministratorsFixture.php
new file mode 100644
index 0000000..5dadc65
--- /dev/null
+++ b/tests/Fixture/AdministratorsFixture.php
@@ -0,0 +1,62 @@
+ ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
+ 'name' => ['type' => 'string', 'length' => 150, 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'email' => ['type' => 'string', 'length' => 50, 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'password' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'cakeadmin' => ['type' => 'integer', 'length' => 1, 'unsigned' => false, 'null' => true, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null],
+ 'request_key' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
+ 'created' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
+ 'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ '_options' => [
+ 'engine' => 'InnoDB',
+ 'collation' => 'utf8_general_ci'
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => '12bace86-66c3-48e0-8355-d90eaf724959',
+ 'name' => 'Lorem ipsum dolor sit amet',
+ 'email' => 'Lorem ipsum dolor sit amet',
+ 'password' => 'Lorem ipsum dolor sit amet',
+ 'cakeadmin' => 1,
+ 'request_key' => 'Lorem ipsum dolor sit amet',
+ 'created' => '2016-07-16 12:38:31',
+ 'modified' => '2016-07-16 12:38:31'
+ ],
+ ];
+}
diff --git a/tests/Fixture/BooksFixture.php b/tests/Fixture/BooksFixture.php
deleted file mode 100644
index 2e26dc0..0000000
--- a/tests/Fixture/BooksFixture.php
+++ /dev/null
@@ -1,44 +0,0 @@
- ['type' => 'integer'],
- 'author_id' => ['type' => 'integer', 'null' => true],
- 'title' => ['type' => 'string', 'null' => true],
- 'body' => 'text',
- 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
- '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
- ];
-
- /**
- * records property
- *
- * @var array
- */
- public $records = [
- ['author_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y'],
- ['author_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y'],
- ['author_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y']
- ];
-}
diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php
deleted file mode 100644
index ac7b1f3..0000000
--- a/tests/Fixture/UsersFixture.php
+++ /dev/null
@@ -1,128 +0,0 @@
- [
- 'type' => 'integer',
- 'length' => 11,
- 'unsigned' => false,
- 'null' => false,
- 'default' => null,
- 'comment' => '',
- 'autoIncrement' => true,
- 'precision' => null
- ],
- 'email' => [
- 'type' => 'string',
- 'length' => 50,
- 'null' => true,
- 'default' => null,
- 'comment' => '',
- 'precision' => null,
- 'fixed' => null
- ],
- 'password' => [
- 'type' => 'string',
- 'length' => 255,
- 'null' => true,
- 'default' => null,
- 'comment' => '',
- 'precision' => null,
- 'fixed' => null
- ],
- 'cakeadmin' => [
- 'type' => 'integer',
- 'length' => 11,
- 'unsigned' => false,
- 'null' => true,
- 'default' => '1',
- 'comment' => '',
- 'precision' => null,
- 'autoIncrement' => null
- ],
- 'request_key' => [
- 'type' => 'string',
- 'length' => 255,
- 'null' => true,
- 'default' => null,
- 'comment' => '',
- 'precision' => null,
- 'fixed' => null
- ],
- 'created' => [
- 'type' => 'datetime',
- 'length' => null,
- 'null' => true,
- 'default' => null,
- 'comment' => '',
- 'precision' => null
- ],
- 'modified' => [
- 'type' => 'datetime',
- 'length' => null,
- 'null' => true,
- 'default' => null,
- 'comment' => '',
- 'precision' => null
- ],
- '_constraints' => [
- 'primary' => [
- 'type' => 'primary',
- 'columns' => ['id'],
- 'length' => []
- ],
- ],
- '_options' => [
- 'engine' => 'InnoDB',
- 'collation' => 'latin1_swedish_ci'
- ],
- ];
-
- /**
- * Records
- *
- * @var array
- */
- public $records = [
- [
- 'email' => 'bob@cakeplugins.org',
- 'password' => '12345',
- 'cakeadmin' => 1,
- 'created' => '2015-12-18 15:37:51',
- 'modified' => '2015-12-18 15:37:51'
- ],
- [
- 'email' => 'unknown@cakeplugins.org',
- 'password' => '12345',
- 'cakeadmin' => 0,
- 'created' => '2015-12-18 15:37:51',
- 'modified' => '2015-12-18 15:37:51'
- ],
- ];
-}
diff --git a/tests/TestCase/Controller/Admin/DashboardControllerTest.php b/tests/TestCase/Controller/Admin/DashboardControllerTest.php
index cc80058..e2d9c4c 100644
--- a/tests/TestCase/Controller/Admin/DashboardControllerTest.php
+++ b/tests/TestCase/Controller/Admin/DashboardControllerTest.php
@@ -1,67 +1,22 @@
get('/admin/dashboard');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- public function testIndex()
+ public function testInitialization()
{
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/dashboard');
-
- $this->assertResponseSuccess();
- $this->assertNoRedirect();
-
- $this->assertLayout('default');
- $this->assertLayout('lightstrap');
- $this->assertTemplate('index');
- $this->assertTemplate('lightstrap');
-
- $this->assertResponseContains('Dashboard ');
+ $this->markTestIncomplete('Not implemented yet.');
}
}
diff --git a/tests/TestCase/Controller/Admin/NotificationsControllerTest.php b/tests/TestCase/Controller/Admin/NotificationsControllerTest.php
deleted file mode 100644
index 7ee35f0..0000000
--- a/tests/TestCase/Controller/Admin/NotificationsControllerTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-get('/admin/notifications');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- public function testIndex()
- {
- NotificationManager::instance()->notify([
- 'users' => [1],
- 'vars' => [
- 'title' => 'Testing the title',
- 'body' => 'Testing the body'
- ]
- ]);
-
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/notifications');
-
- $this->assertResponseSuccess();
- $this->assertNoRedirect();
-
- $viewVars = $this->_controller->viewVars;
-
- $this->assertArrayHasKey('notifications', $viewVars);
- $this->assertArrayHasKey(0, $viewVars['notifications']);
- $this->assertInstanceOf('Notifier\Model\Entity\Notification', $viewVars['notifications'][0]);
-
- $this->assertResponseContains('Testing the title');
- $this->assertResponseContains('Testing the body');
- }
-}
diff --git a/tests/TestCase/Controller/Admin/PostTypeControllerTest.php b/tests/TestCase/Controller/Admin/PostTypeControllerTest.php
new file mode 100644
index 0000000..57b56bb
--- /dev/null
+++ b/tests/TestCase/Controller/Admin/PostTypeControllerTest.php
@@ -0,0 +1,71 @@
+markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test view method
+ *
+ * @return void
+ */
+ public function testView()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test add method
+ *
+ * @return void
+ */
+ public function testAdd()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test edit method
+ *
+ * @return void
+ */
+ public function testEdit()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test delete method
+ *
+ * @return void
+ */
+ public function testDelete()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
diff --git a/tests/TestCase/Controller/Admin/PostTypesControllerTest.php b/tests/TestCase/Controller/Admin/PostTypesControllerTest.php
deleted file mode 100644
index 24857e6..0000000
--- a/tests/TestCase/Controller/Admin/PostTypesControllerTest.php
+++ /dev/null
@@ -1,465 +0,0 @@
-enableCsrfToken();
- $this->enableSecurityToken();
- }
-
- /**
- * Runs after each test.
- *
- * @return void
- */
- public function tearDown()
- {
- parent::tearDown();
-
- Configure::write('CA.PostTypes', []);
- Configure::write('CA.Models', []);
- }
-
- /**
- * Test if the index request is authorized.
- *
- * @return void
- */
- public function testIndexNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/index');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if exception is called if the posttype does not exist.
- *
- * @expectedException
- * @return void
- */
- public function testIndexNoPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/posttypes/articles/index');
-
- $this->assertResponseFailure();
- }
-
- /**
- * Test index request on registered posttype.
- *
- * @return void
- */
- public function testIndexWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/index');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains('Articles ');
-
- $this->assertLayout('default.ctp');
- $this->assertTemplate(DS . 'Template' . DS . 'Admin' . DS . 'PostTypes' . DS . 'index.ctp');
- }
-
- /**
- * Test if the view request is authorized.
- *
- * @return void
- */
- public function testViewNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/view/1');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if exception is called if the posttype does not exist.
- *
- * @return void
- */
- public function testViewNoPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/posttypes/articles/view/1');
-
- $this->assertResponseFailure();
- }
-
- /**
- * Test view request on registered posttype.
- *
- * @return void
- */
- public function testViewWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/view/1');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains('Articles ');
-
- $this->assertLayout('default.ctp');
- $this->assertTemplate(DS . 'Template' . DS . 'Admin' . DS . 'PostTypes' . DS . 'view.ctp');
- }
-
- /**
- * Test if the add request is authorized.
- *
- * @return void
- */
- public function testAddNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/add');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if exception is called if the posttype does not exist.
- *
- * @return void
- */
- public function testAddNoPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/posttypes/articles/add');
-
- $this->assertResponseFailure();
- }
-
- /**
- * Test add request on registered posttype.
- *
- * @return void
- */
- public function testAddWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/add');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains('Articles ');
-
- $this->assertLayout('default.ctp');
- $this->assertTemplate(DS . 'Template' . DS . 'Admin' . DS . 'PostTypes' . DS . 'add.ctp');
- }
-
- /**
- * Test add POST request on registered posttype.
- *
- * @return void
- */
- public function testAddPostWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $articles = TableRegistry::get('Articles');
-
- $this->post('/admin/posttypes/articles/add', [
- 'author_id' => 1,
- 'title' => 'Fourth article',
- 'body' => 'Fourth Article Body',
- 'published' => 'Y'
- ]);
-
- $this->assertResponseSuccess();
-
- $this->assertEquals(4, $articles->find()->count());
- }
-
- /**
- * Test if the edit request is authorized.
- *
- * @return void
- */
- public function testEditNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/edit/1');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if exception is called if the posttype does not exist.
- *
- * @return void
- */
- public function testEditNoPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/posttypes/articles/edit/1');
-
- $this->assertResponseFailure();
- }
-
- /**
- * Test edit request on registered posttype.
- *
- * @return void
- */
- public function testEditWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/edit/1');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains('Articles ');
-
- $this->assertLayout('default.ctp');
- $this->assertTemplate(DS . 'Template' . DS . 'Admin' . DS . 'PostTypes' . DS . 'edit.ctp');
- }
-
- /**
- * Test edit POST request on registered posttype.
- *
- * @return void
- */
- public function testEditPostWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $articles = TableRegistry::get('Articles');
-
- $article = $articles->get(1);
-
- $this->assertEquals('First Article', $article->title);
-
- $this->post('/admin/posttypes/articles/edit/1', [
- 'title' => 'First Article Edited',
- ]);
-
- $this->assertResponseSuccess();
-
- $article = $articles->get(1);
-
- $this->assertEquals('First Article Edited', $article->title);
- }
-
- /**
- * Test if the delete request is authorized.
- *
- * @return void
- */
- public function testDeleteNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->delete('/admin/posttypes/articles/delete/1');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if exception is called if the posttype does not exist.
- *
- * @return void
- */
- public function testDeleteNoPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->delete('/admin/posttypes/articles/delete/1');
-
- $this->assertResponseFailure();
- }
-
- /**
- * Test delete request on registered posttype.
- *
- * @return void
- */
- public function testDeleteWithPostType()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- Configure::write('CA.Models.articles', 'Articles');
-
- $articles = TableRegistry::get('Articles');
-
-
- $this->assertEquals(3, $articles->find()->count());
-
- $this->delete('/admin/posttypes/articles/delete/1');
-
- $this->assertResponseSuccess();
-
- $this->assertEquals(2, $articles->find()->count());
- }
-}
diff --git a/tests/TestCase/Controller/Admin/SettingsControllerTest.php b/tests/TestCase/Controller/Admin/SettingsControllerTest.php
deleted file mode 100644
index 20a91a2..0000000
--- a/tests/TestCase/Controller/Admin/SettingsControllerTest.php
+++ /dev/null
@@ -1,195 +0,0 @@
-enableCsrfToken();
- $this->enableSecurityToken();
- }
-
- /**
- * Runs after each test.
- *
- * @return void
- */
- public function tearDown()
- {
- parent::tearDown();
-
- Setting::clear(true);
-
- Configure::write('CA.PostTypes', []);
- Configure::write('CA.Models', []);
- }
-
- /**
- * Test if the index request is authorized.
- *
- * @return void
- */
- public function testIndexNotAuthorized()
- {
- Configure::write('CA.Models.articles', 'Articles');
-
- $this->get('/admin/posttypes/articles/index');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin');
- }
-
- /**
- * Test if the index request uses the default key and shows the form.
- *
- * @return void
- */
- public function testIndexWithDefaultKey()
- {
- Setting::write('App.FirstKey', 'First Value');
- Setting::write('App.SecondKey', 'Second Value');
-
- Setting::write('CA.ThirthKey', 'Thirth Value');
-
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/settings');
-
- $this->assertResponseSuccess();
- $this->assertNoRedirect();
-
- $viewVars = $this->_controller->viewVars;
-
- $settingVar = $viewVars['settings']->toArray();
-
- $this->assertEquals(2, count($settingVar));
- $this->assertEquals('App.FirstKey', $settingVar[0]->name);
- $this->assertEquals('App.SecondKey', $settingVar[1]->name);
-
- $formElement = 'FirstKey
';
- $this->assertResponseContains($formElement);
-
- $formElement = 'SecondKey
';
- $this->assertResponseContains($formElement);
- }
-
- /**
- * Test if the index request can handle custom keys and shows the form.
- *
- * @return void
- */
- public function testIndexWithCustomKey()
- {
- Setting::write('App.FirstKey', 'First Value');
- Setting::write('App.SecondKey', 'Second Value');
-
- Setting::write('CA.ThirthKey', 'Thirth Value');
-
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/settings/CA');
-
- $this->assertResponseSuccess();
- $this->assertNoRedirect();
-
- $viewVars = $this->_controller->viewVars;
-
- $settingVar = $viewVars['settings']->toArray();
-
- $this->assertEquals(1, count($settingVar));
- $this->assertEquals('CA.ThirthKey', $settingVar[0]->name);
-
- $formElement = 'ThirthKey
';
- $this->assertResponseContains($formElement);
- }
-
- public function testIndexPostWithDefaultKey()
- {
- Setting::write('App.FirstKey', 'First Value');
- Setting::write('App.SecondKey', 'Second Value');
-
- Setting::write('CA.ThirthKey', 'Thirth Value');
-
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $settings = TableRegistry::get('Settings.Configurations');
-
- $this->assertEquals('First Value', $settings->findByName('App.FirstKey')->toArray()[0]['value']);
-
- $this->post('/admin/settings', [
- [
- 'id' => '1',
- 'value' => 'First Value Edited'
- ]
- ]);
-
- $this->assertResponseSuccess();
-
- $this->assertEquals('First Value Edited', $settings->findByName('App.FirstKey')->toArray()[0]['value']);
- }
-}
diff --git a/tests/TestCase/Controller/Admin/UsersControllerTest.php b/tests/TestCase/Controller/Admin/UsersControllerTest.php
index fbfa267..b012954 100644
--- a/tests/TestCase/Controller/Admin/UsersControllerTest.php
+++ b/tests/TestCase/Controller/Admin/UsersControllerTest.php
@@ -1,375 +1,22 @@
enableCsrfToken();
- $this->enableSecurityToken();
- }
-
- /**
- * Runs after each test.
- *
- * @return void
- */
- public function tearDown()
- {
- parent::tearDown();
- }
-
- /**
- * Test login request.
- *
- * @return void
- */
- public function testLogin()
- {
- $this->get('/admin/login');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains(' ');
- $this->assertResponseContains(' ');
- }
-
- /**
- * Test login POST request.
- *
- * @return void
- */
- public function testLoginPost()
- {
- $administrators = TableRegistry::get('CakeAdmin.Administrators');
-
- $details = [
- 'email' => 'test@cakeplugins.org',
- 'password' => '12345'
- ];
-
- $administrators->save($administrators->newEntity($details));
-
- $this->post('/admin/login', [
- 'email' => 'test@cakeplugins.org',
- 'password' => '12345'
- ]);
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin/dashboard');
-
- $this->assertSession('3', 'Auth.CakeAdmin.id');
- $this->assertSession('test@cakeplugins.org', 'Auth.CakeAdmin.email');
- $this->assertSession('1', 'Auth.CakeAdmin.cakeadmin');
- }
-
- /**
- * Test login POST request fail.
- *
- * @return void
- */
- public function testLoginPostFail()
- {
- $administrators = TableRegistry::get('CakeAdmin.Administrators');
-
- $details = [
- 'email' => 'test@cakeplugins.org',
- 'password' => '12345'
- ];
-
- $administrators->save($administrators->newEntity($details));
-
- $this->post('/admin/login', [
- 'email' => 'test@cakeplugins.org',
- 'password' => '123456'
- ]);
-
- $this->assertResponseSuccess();
- $this->assertNoRedirect();
-
- $this->assertResponseContains('Invalid username or password, try again');
-
- $this->assertSession(null, 'Auth.CakeAdmin');
- }
-
- /**
- * Test login request when an user has been logged in. The user should be redirected.
- *
- * @return void
- */
- public function testLoginLoggedin()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/login');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/admin/dashboard');
- }
-
- /**
- * Test if `/admin` request will be the same as the `/admin/login` request.
- *
- * @return void
- */
- public function testLoginAdminRequest()
- {
- $this->get('/admin');
-
- $this->assertResponseSuccess();
-
- $request = $this->_controller->request;
-
- $this->assertEquals('CakeAdmin', $request->params['plugin']);
- $this->assertEquals('Users', $request->params['controller']);
- $this->assertEquals('login', $request->params['action']);
- $this->assertEquals('admin', $request->params['prefix']);
- }
-
- /**
- * Test if the email in the query url will be used in the form.
- * For example: `/admin/login?email=bob@cakeplugins.org`.
- *
- * @return void
- */
- public function testLoginWithEmailInQuery()
- {
- $this->get('/admin/login?email=bob@cakeplugins.org');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains(' ');
- }
-
- /**
- * Test logout request.
- *
- * @return void
- */
- public function testLogout()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->get('/admin/logout');
-
- $this->assertSession([], 'Auth');
- $this->assertSession('You are now logged out.', 'Flash.flash.0.message');
- }
-
- /**
- * Test forgot request.
- *
- * @return void
- */
- public function testForgot()
- {
- $this->markTestIncomplete('This will be tested by LeoRuhland because of the theming');
- }
/**
- * Test forgot POST request.
+ * Test initial setup
*
* @return void
*/
- public function testForgotPost()
+ public function testInitialization()
{
- $administrators = TableRegistry::get('CakeAdmin.Administrators');
-
- $this->assertNull($administrators->get(1)->get('request_key'));
-
- EventManager::instance()->on(
- 'Dispatcher.beforeDispatch',
- ['priority' => 998],
- function ($event) {
- $mailer = $this->getMock('CakeAdmin\Mailer\CakeAdminMailer', ['send']);
-
- $mailer->expects($this->once())
- ->method('send')
- ->with($this->equalTo('resetPassword'))
- ->will($this->returnValue(true));
-
- $this->_controller = $this->getMock(
- 'CakeAdmin\Controller\Admin\UsersController',
- ['getMailer'],
- [$event->data['request'], $event->data['response']]
- );
-
- $this->_controller->expects($this->once())
- ->method('getMailer')
- ->with($this->equalTo('CakeAdmin.CakeAdmin'))
- ->will($this->returnValue($mailer));
-
- $events = $this->_controller->eventManager();
- $events->on('View.beforeRender', function ($event, $viewFile) {
- if (!$this->_viewName) {
- $this->_viewName = $viewFile;
- }
- });
- $events->on('View.beforeLayout', function ($event, $viewFile) {
- $this->_layoutName = $viewFile;
- });
-
- $event->data['controller'] = $this->_controller;
-
- $event->stopPropagation();
- }
- );
-
- $this->post('/admin/users/forgot', [
- 'email' => 'bob@cakeplugins.org'
- ]);
-
- $this->assertNotNull($administrators->get(1)->get('request_key'));
- }
-
- /**
- * Test forgot request when an user has been logged in. The user should be redirected.
- *
- * @return void
- */
- public function testForgotLoggedin()
- {
- $this->session([
- 'Auth' => [
- 'CakeAdmin' => [
- 'id' => 1,
- 'email' => 'bob@cakeplugins.org',
- 'cakeadmin' => 1
- ]
- ]
- ]);
-
- $this->post('/admin/users/forgot');
-
- $this->assertResponseSuccess();
- $this->assertRedirect('/login');
- }
-
- /**
- * Test reset request.
- *
- * @return void
- */
- public function testReset()
- {
- $administrators = TableRegistry::get('CakeAdmin.Administrators');
-
- $administrator = $administrators->get(1);
- $administrator->set('request_key', 'custom_request_key');
- $administrators->save($administrator);
-
- $this->get('/admin/users/reset/bob@cakeplugins.org/custom_request_key');
-
- $this->assertResponseSuccess();
-
- $this->assertResponseContains('