diff --git a/.gitignore b/.gitignore
index 244d127..70d7de1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
/config/Migrations/schema-dump-default.lock
/vendor/
/.idea/
+/tmp
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index cde4ac6..e2f3d2c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,10 +1,9 @@
-This is free and unencumbered software released into the public domain.
+MIT License
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
+Copyright (c) 2025 HI POWERED DEV, LLC
-In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-For more information, please refer to
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/composer.json b/composer.json
index 04f5c36..7b326d4 100644
--- a/composer.json
+++ b/composer.json
@@ -2,13 +2,14 @@
"name": "hi-powered-dev/cake-contact-us",
"description": "Contact Us plugin for CakePHP",
"type": "cakephp-plugin",
- "license": "UNLICENSE",
+ "license": "MIT",
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0.1"
},
"require-dev": {
- "phpunit/phpunit": "^10.1"
+ "phpunit/phpunit": "^10.1",
+ "cakephp/migrations": "^4.0.0"
},
"autoload": {
"psr-4": {
@@ -18,7 +19,8 @@
"autoload-dev": {
"psr-4": {
"CakeContactUs\\Test\\": "tests/",
- "Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
+ "Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
+ "TestApp\\": "tests/test_app/src/"
}
}
}
diff --git a/config/Migrations/20250103091420_CreateContactUsFormSubmissions.php b/config/Migrations/20250103091420_CreateContactUsFormSubmissions.php
index 52a0ad0..a5f936b 100644
--- a/config/Migrations/20250103091420_CreateContactUsFormSubmissions.php
+++ b/config/Migrations/20250103091420_CreateContactUsFormSubmissions.php
@@ -27,7 +27,7 @@ class CreateContactUsFormSubmissions extends AbstractMigration
$table->addColumn('client_ip', 'string', [
'default' => null,
'limit' => 45,
- 'null' => false,
+ 'null' => true,
]);
$table->addColumn('name', 'string', [
'default' => null,
diff --git a/src/Controller/Component/ContactUsComponent.php b/src/Controller/Component/ContactUsComponent.php
index d2353a9..a2615fa 100644
--- a/src/Controller/Component/ContactUsComponent.php
+++ b/src/Controller/Component/ContactUsComponent.php
@@ -70,6 +70,7 @@ class ContactUsComponent extends Component
if ($this->getConfig('requireCaptcha')) {
$this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha');
}
+
return $this->ContactUsFormSubmissions->newEmptyEntity();
}
@@ -81,7 +82,12 @@ class ContactUsComponent extends Component
if (!isset($postData)) {
$postData = $this->getController()->getRequest()->getData();
}
- $postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ? $postData['client_ip'] : $this->getController()->getRequest()->clientIp();
+ $postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ?
+ $postData['client_ip'] :
+ ($this->getConfig('clientIpHeader') ?
+ $this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) :
+ $this->getController()->getRequest()->clientIp()
+ );
$postData['submitted_at'] = DateTime::now();
$event = $this->getController()->dispatchEvent(CakeContactUsPlugin::EVENT_BEFORE_CONTACT_US_FORM_SAVED, [
@@ -119,7 +125,10 @@ class ContactUsComponent extends Component
Log::debug(print_r('$contactUsFormSubmission->getErrors()', true));
Log::debug(print_r($contactUsFormSubmission->getErrors(), true));
}
+
+
$contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission);
+
if ($contactUsFormSubmissionSaved) {
return $this->_afterFormSaved($contactUsFormSubmissionSaved);
}
@@ -140,7 +149,6 @@ class ContactUsComponent extends Component
protected function _afterFormSaved(EntityInterface $contactUsFormSubmissionSaved)
{
$message = __d('cake_contact_us', 'Message received, thank you. We will be in touch soon.');
-
$event = $this->getController()->dispatchEvent(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED, [
'contactUsFormSubmission' => $contactUsFormSubmissionSaved,
], $this->getController());
diff --git a/src/Model/Table/ContactUsFormSubmissionsTable.php b/src/Model/Table/ContactUsFormSubmissionsTable.php
index 36c3712..243ed59 100644
--- a/src/Model/Table/ContactUsFormSubmissionsTable.php
+++ b/src/Model/Table/ContactUsFormSubmissionsTable.php
@@ -73,8 +73,7 @@ class ContactUsFormSubmissionsTable extends Table
$validator
->scalar('client_ip')
->maxLength('client_ip', 45)
- ->requirePresence('client_ip', 'create')
- ->notEmptyString('client_ip');
+ ->allowEmptyString('client_ip');
$validator
->scalar('name')
@@ -84,7 +83,7 @@ class ContactUsFormSubmissionsTable extends Table
// email
$validator->email('email');
- if ($fields['email']) {
+ if ($fields['email'] ?? false) {
$validator->notEmptyString('email');
} else {
$validator->allowEmptyString('email');
@@ -94,7 +93,7 @@ class ContactUsFormSubmissionsTable extends Table
$validator
->scalar('subject')
->maxLength('subject', 255);
- if ($fields['subject']) {
+ if ($fields['subject'] ?? false) {
$validator->notEmptyString('subject');
} else {
$validator->allowEmptyString('subject');
@@ -129,7 +128,7 @@ class ContactUsFormSubmissionsTable extends Table
}
$now = DateTime::now()->format(CakeContactUsPlugin::CAKE_CONTACT_US_MYSQL_DATETIME);
$updateData = [];
- if (Configure::read('ContactUs.email.confirmation.enabled') && isset($contactUsFormSubmission->email)) {
+ if (Configure::read('ContactUs.fields.email.confirmation') && isset($contactUsFormSubmission->email)) {
$mailer = Configure::read('ContactUs.email.mailerClass', 'CakeContactUs.ContactUsFormSubmissions');
try {
$this->getMailer($mailer)->send('confirmation', [$contactUsFormSubmission]);
@@ -139,7 +138,7 @@ class ContactUsFormSubmissionsTable extends Table
}
}
- if (Configure::readOrFail('ContactUs.email.backend.enabled')) {
+ if (Configure::readOrFail('ContactUs.fields.email.backend')) {
$mailer = Configure::read('ContactUs.email.mailerClass', 'CakeContactUs.ContactUsFormSubmissions');
try {
$this->getMailer($mailer)->send('backend', [$contactUsFormSubmission]);
diff --git a/templates/element/ContactUsFormSubmissions/form.php b/templates/element/ContactUsFormSubmissions/form.php
index 2bef41d..8e9a642 100644
--- a/templates/element/ContactUsFormSubmissions/form.php
+++ b/templates/element/ContactUsFormSubmissions/form.php
@@ -8,9 +8,9 @@ $fields = \Cake\Core\Configure::readOrFail('ContactUs.fields');
?>
Form->control('name');
-echo $fields['email'] ? $this->Form->control('email', ['required' => true]) : '';
-echo $fields['subject'] ? $this->Form->control('subject', ['required' => true]) : '';
+echo isset($fields['email']) && $fields['email'] ? $this->Form->control('email', ['required' => true]) : '';
+echo isset($fields['subject']) && $fields['subject'] ? $this->Form->control('subject', ['required' => true]) : '';
echo $this->Form->control('message');
-echo $fields['captcha'] ? $this->Captcha->render(['placeholder' => __('Please solve the riddle')]) : '';
+echo isset($fields['captcha']) && $fields['captcha'] ? $this->Captcha->render(['placeholder' => __('Please solve the riddle')]) : '';
?>
diff --git a/tests/TestCase/Controller/ContactUsFormSubmissionsControllerTest.php b/tests/TestCase/Controller/ContactUsFormSubmissionsControllerTest.php
index 39b310d..bac24d6 100644
--- a/tests/TestCase/Controller/ContactUsFormSubmissionsControllerTest.php
+++ b/tests/TestCase/Controller/ContactUsFormSubmissionsControllerTest.php
@@ -3,20 +3,32 @@ declare(strict_types=1);
namespace CakeContactUs\Test\TestCase\Controller;
+use App\Model\Table\ContactUsFormSubmissionsTable;
+use Cake\Controller\Controller;
+use Cake\Event\EventList;
+use Cake\Event\EventManager;
+use Cake\Http\ServerRequest;
+use Cake\ORM\Table;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
+use CakeContactUs\CakeContactUsPlugin;
use CakeContactUs\Controller\ContactUsFormSubmissionsController;
use PHPUnit\Exception;
/**
* CakeContactUs\Controller\ContactUsFormSubmissionsController Test Case
*
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController
+ * @uses ContactUsFormSubmissionsController
*/
class ContactUsFormSubmissionsControllerTest extends TestCase
{
use IntegrationTestTrait;
+ /**
+ * @var ContactUsFormSubmissionsTable|Table
+ */
+ protected $ContactUsFormSubmissions;
+
/**
* Fixtures
*
@@ -35,6 +47,8 @@ class ContactUsFormSubmissionsControllerTest extends TestCase
{
parent::setUp();
$this->ContactUsFormSubmissions = $this->getTableLocator()->get('ContactUsFormSubmissions');
+
+ EventManager::instance()->setEventList(new EventList());
}
/**
@@ -49,139 +63,20 @@ class ContactUsFormSubmissionsControllerTest extends TestCase
parent::tearDown();
}
- /**
- * Test index method
- *
- * Tests the index action with an unauthenticated user (not logged in)
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::index()
- * @throws Exception
- *
- * @return void
- */
- public function testIndexGetUnauthenticated(): void
- {
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'index',
- ];
- $this->get($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('login');
- }
-
- /**
- * Test index method
- *
- * Tests the index action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::index()
- * @throws Exception
- *
- * @return void
- */
- public function testIndexGetLoggedIn(): void
- {
- // $this->loginUserByRole('admin');
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'index',
- ];
- $this->get($url);
- $this->assertResponseCode(200);
- }
-
- /**
- * Test view method
- *
- * Tests the view action with an unauthenticated user (not logged in)
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::view()
- * @throws Exception
- *
- * @return void
- */
- public function testViewGetUnauthenticated(): void
- {
- $id = 1;
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'view',
- $id,
- ];
- $this->get($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('login');
- }
-
- /**
- * Test view method
- *
- * Tests the view action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::view()
- * @throws Exception
- *
- * @return void
- */
- public function testViewGetLoggedIn(): void
- {
- $id = 1;
- // $this->loginUserByRole('admin');
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'view',
- $id,
- ];
- $this->get($url);
- $this->assertResponseCode(200);
- }
-
- /**
- * Test add method
- *
- * Tests the add action with an unauthenticated user (not logged in)
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::add()
- * @throws Exception
- *
- * @return void
- */
- public function testAddGetUnauthenticated(): void
- {
- $cntBefore = $this->ContactUsFormSubmissions->find()->count();
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'add',
- ];
- $this->get($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('login');
-
- $cntAfter = $this->ContactUsFormSubmissions->find()->count();
- $this->assertEquals($cntBefore, $cntAfter);
- }
-
/**
* Test add method
*
* Tests the add action with a logged in user
*
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::add()
- * @throws Exception
- *
* @return void
+ * @throws Exception
+ *
+ * @uses ContactUsFormSubmissionsController::add
*/
- public function testAddGetLoggedIn(): void
+ public function testAddGet(): void
{
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
- // $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
@@ -199,28 +94,31 @@ class ContactUsFormSubmissionsControllerTest extends TestCase
*
* Tests a POST request to the add action with a logged in user
*
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::add()
- * @throws Exception
- *
* @return void
+ * @throws Exception
+ *
+ * @uses ContactUsFormSubmissionsController::add
*/
- public function testAddPostLoggedInSuccess(): void
+ public function testAddPostSuccess(): void
{
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
- // $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
- $data = [];
+ $data = [
+ 'name' => 'valid name',
+ 'email' => 'valid_email@test.com',
+ 'message' => 'valid message goes here',
+ ];
$this->post($url, $data);
$this->assertResponseCode(302);
- $this->assertRedirectContains('contactusformsubmissions/view');
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
+ $this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
}
/**
@@ -228,10 +126,10 @@ class ContactUsFormSubmissionsControllerTest extends TestCase
*
* Tests a POST request to the add action with a logged in user
*
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::add()
- * @throws Exception
- *
* @return void
+ * @throws Exception
+ *
+ * @uses ContactUsFormSubmissionsController::add
*/
public function testAddPostLoggedInFailure(): void
{
@@ -243,176 +141,17 @@ class ContactUsFormSubmissionsControllerTest extends TestCase
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
- $data = [];
+ $data = [
+ 'name' => 'valid name',
+ 'email' => 'not_valid_email',
+ 'message' => 'this is a valid message ',
+ ];
$this->post($url, $data);
$this->assertResponseCode(200);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
- }
+ $this->assertEventFired(CakeContactUsPlugin::EVENT_BEFORE_CONTACT_US_FORM_SAVED);
- /**
- * Test edit method
- *
- * Tests the edit action with an unauthenticated user (not logged in)
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::edit()
- * @throws Exception
- *
- * @return void
- */
- public function testEditGetUnauthenticated(): void
- {
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'edit',
- 1,
- ];
- $this->get($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('login');
- }
-
- /**
- * Test edit method
- *
- * Tests the edit action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::edit()
- * @throws Exception
- *
- * @return void
- */
- public function testEditGetLoggedIn(): void
- {
- // $this->loginUserByRole('admin');
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'edit',
- 1,
- ];
- $this->get($url);
- $this->assertResponseCode(200);
- }
-
- /**
- * Test edit method
- *
- * Tests a PUT request to the edit action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::edit()
- * @throws Exception
- *
- * @return void
- */
- public function testEditPutLoggedInSuccess(): void
- {
- // $this->loginUserByRole('admin');
- $id = 1;
- $before = $this->ContactUsFormSubmissions->get($id);
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'edit',
- $id,
- ];
- $data = [
- // test new data here
- ];
- $this->put($url, $data);
-
- $this->assertResponseCode(302);
- $this->assertRedirectContains('contactusformsubmissions/view');
-
- $after = $this->ContactUsFormSubmissions->get($id);
- // assert saved properly below
- }
-
- /**
- * Test edit method
- *
- * Tests a PUT request to the edit action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::edit()
- * @throws Exception
- *
- * @return void
- */
- public function testEditPutLoggedInFailure(): void
- {
- // $this->loginUserByRole('admin');
- $id = 1;
- $before = $this->ContactUsFormSubmissions->get($id);
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'edit',
- $id,
- ];
- $data = [];
- $this->put($url, $data);
- $this->assertResponseCode(200);
- $after = $this->ContactUsFormSubmissions->get($id);
-
- // assert save failed below
- }
-
- /**
- * Test delete method
- *
- * Tests the delete action with an unauthenticated user (not logged in)
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::delete()
- * @throws Exception
- *
- * @return void
- */
- public function testDeleteUnauthenticated(): void
- {
- $cntBefore = $this->ContactUsFormSubmissions->find()->count();
-
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'delete',
- 1,
- ];
- $this->delete($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('login');
-
- $cntAfter = $this->ContactUsFormSubmissions->find()->count();
- $this->assertEquals($cntBefore, $cntAfter);
- }
-
- /**
- * Test delete method
- *
- * Tests the delete action with a logged in user
- *
- * @uses \CakeContactUs\Controller\ContactUsFormSubmissionsController::delete()
- * @throws Exception
- *
- * @return void
- */
- public function testDeleteLoggedIn(): void
- {
- $cntBefore = $this->ContactUsFormSubmissions->find()->count();
-
- // $this->loginUserByRole('admin');
- $url = [
- 'plugin' => 'CakeContactUs',
- 'controller' => 'ContactUsFormSubmissions',
- 'action' => 'delete',
- 1,
- ];
- $this->delete($url);
- $this->assertResponseCode(302);
- $this->assertRedirectContains('contactusformsubmissions');
-
- $cntAfter = $this->ContactUsFormSubmissions->find()->count();
- $this->assertEquals($cntBefore - 1, $cntAfter);
}
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 3437b66..87170ad 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,43 +1,112 @@
'TestApp',
+ 'encoding' => 'UTF-8',
+ 'paths' => [
+ 'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
+ 'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
+ 'templates' => [
+ PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
+ ],
+ ],
+]);
+
+Configure::write('debug', true);
+Configure::write('ContactUs', [
+ 'fields' => [
+ 'captcha' => false,
+ 'email' => [
+ 'confirmation' => false,
+ 'backend' => false,
+ ],
+ ],
+]);
+
+$cache = [
+ 'default' => [
+ 'engine' => 'File',
+ 'path' => CACHE,
+ ],
+ '_cake_translations_' => [
+ 'className' => 'File',
+ 'prefix' => 'crud_myapp_cake_core_',
+ 'path' => CACHE . 'persistent/',
+ 'serialize' => true,
+ 'duration' => '+10 seconds',
+ ],
+ '_cake_model_' => [
+ 'className' => 'File',
+ 'prefix' => 'crud_my_app_cake_model_',
+ 'path' => CACHE . 'models/',
+ 'serialize' => 'File',
+ 'duration' => '+10 seconds',
+ ],
+];
+
+Cache::setConfig($cache);
+
+class_alias(AppController::class, 'App\Controller\AppController');
+
+Plugin::getCollection()->add(new CakeContactUsPlugin());
+
+Chronos::setTestNow(Chronos::now());
+
+if (!getenv('DB_URL')) {
+ putenv('DB_URL=sqlite:///:memory:');
+}
+
+ConnectionManager::setConfig('test', [
+ 'className' => Connection::class,
+ 'url' => getenv('DB_URL') ?: null,
+ 'timezone' => 'UTC',
+ 'quoteIdentifiers' => false,
+ 'cacheMetadata' => true,
+]);
/**
* Load schema from a SQL dump file.
@@ -49,7 +118,9 @@ if (file_exists($root . '/config/bootstrap.php')) {
* using migrations to provide schema for your plugin,
* and using \Migrations\TestSuite\Migrator to load schema.
*/
-use Cake\TestSuite\Fixture\SchemaLoader;
-
// Load a schema dump file.
-(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');
+//(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');
+
+
+$migrator = new Migrator();
+$migrator->run(['plugin' => 'CakeContactUs']);
diff --git a/tests/config/bootstrap.php b/tests/config/bootstrap.php
new file mode 100644
index 0000000..b3d9bbc
--- /dev/null
+++ b/tests/config/bootstrap.php
@@ -0,0 +1 @@
+addPlugin('CakeContactUs');
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function middleware(MiddlewareQueue $middleware): MiddlewareQueue {
+ $middleware->add(new RoutingMiddleware($this));
+
+ return $middleware;
+ }
+
+ public function routes(RouteBuilder $routes): void
+ {
+ parent::routes($routes); // TODO: Change the autogenerated stub
+ $routes->setRouteClass(DashedRoute::class);
+
+ $routes->plugin('CakeContactUs', ['path' => '/cake-contact-us'], function (RouteBuilder $pluginRoutes):void {
+ $pluginRoutes->fallbacks();
+ });
+ }
+
+}
diff --git a/tests/test_app/src/Controller/AppController.php b/tests/test_app/src/Controller/AppController.php
new file mode 100644
index 0000000..7387589
--- /dev/null
+++ b/tests/test_app/src/Controller/AppController.php
@@ -0,0 +1,16 @@
+loadComponent('Flash');
+ }
+}
diff --git a/tests/test_app/src/View/AppView.php b/tests/test_app/src/View/AppView.php
new file mode 100644
index 0000000..e885cc1
--- /dev/null
+++ b/tests/test_app/src/View/AppView.php
@@ -0,0 +1,11 @@
+layout = 'error';
+
+if (Configure::read('debug')):
+ $this->layout = 'dev_error';
+
+ $this->assign('title', $message);
+ $this->assign('templateName', 'error500.ctp');
+
+ $this->start('file');
+?>
+queryString)) : ?>
+
+ SQL Query:
+ = h($error->queryString) ?>
+
+
+params)) : ?>
+ SQL Query Params:
+ params) ?>
+
+
+ Error in:
+ = sprintf('%s, line %s', str_replace(ROOT, 'ROOT', $error->getFile()), $error->getLine()) ?>
+
+element('auto_table_warning');
+
+ if (extension_loaded('xdebug')):
+ xdebug_print_function_stack();
+ endif;
+
+ $this->end();
+endif;
+?>
+= __d('cake', 'An Internal Error Has Occurred') ?>
+
+ = __d('cake', 'Error') ?>:
+ = h($message) ?>
+
diff --git a/tests/test_app/templates/layout/ajax.php b/tests/test_app/templates/layout/ajax.php
new file mode 100644
index 0000000..13b3dea
--- /dev/null
+++ b/tests/test_app/templates/layout/ajax.php
@@ -0,0 +1,6 @@
+
+= $this->fetch('content') ?>
diff --git a/tests/test_app/templates/layout/default.php b/tests/test_app/templates/layout/default.php
new file mode 100644
index 0000000..13b3dea
--- /dev/null
+++ b/tests/test_app/templates/layout/default.php
@@ -0,0 +1,6 @@
+
+= $this->fetch('content') ?>
diff --git a/tests/test_app/webroot/images/2c386086-f4c5-4093-bea5-ee9c29479f58.png b/tests/test_app/webroot/images/2c386086-f4c5-4093-bea5-ee9c29479f58.png
new file mode 100644
index 0000000..394fa42
Binary files /dev/null and b/tests/test_app/webroot/images/2c386086-f4c5-4093-bea5-ee9c29479f58.png differ
diff --git a/tests/test_app/webroot/images/cake_icon.png b/tests/test_app/webroot/images/cake_icon.png
new file mode 100644
index 0000000..394fa42
Binary files /dev/null and b/tests/test_app/webroot/images/cake_icon.png differ