WIP - phpstan and phpcs - tests failing currently

This commit is contained in:
2026-01-24 01:20:17 -08:00
parent 31650e55c2
commit 37b7bca3be
17 changed files with 888 additions and 822 deletions

View File

@@ -8,28 +8,28 @@ use Cake\TestSuite\Fixture\TestFixture;
/**
* ContactUsFormSubmissionsFixture
*/
class ContactUsFormSubmissionsFixture extends TestFixture
{
/**
class ContactUsFormSubmissionsFixture extends TestFixture {
/**
* Init method
*
* @return void
*/
public function init(): void
{
$this->records = [
[
'id' => '76fbe7fb-1949-4670-a3d2-c0b48eb98e8d',
'submitted_at' => '2025-01-03 09:16:50',
'client_ip' => 'Lorem ipsum dolor sit amet',
'name' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'subject' => 'Lorem ipsum dolor sit amet',
'message' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
'confirm_email_sent' => '2025-01-03 09:16:50',
'backend_email_sent' => '2025-01-03 09:16:50',
],
];
parent::init();
}
public function init(): void {
$this->records = [
[
'id' => '76fbe7fb-1949-4670-a3d2-c0b48eb98e8d',
'submitted_at' => '2025-01-03 09:16:50',
'client_ip' => 'Lorem ipsum dolor sit amet',
'name' => 'Lorem ipsum dolor sit amet',
'email' => 'Lorem ipsum dolor sit amet',
'subject' => 'Lorem ipsum dolor sit amet',
'message' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
'confirm_email_sent' => '2025-01-03 09:16:50',
'backend_email_sent' => '2025-01-03 09:16:50',
],
];
parent::init();
}
}

View File

@@ -4,42 +4,74 @@ declare(strict_types=1);
namespace CakeContactUs\Test\TestCase\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Http\ServerRequest;
use Cake\TestSuite\TestCase;
use CakeContactUs\Controller\Component\ContactUsComponent;
use CakeContactUs\Model\Entity\ContactUsFormSubmission;
/**
* CakeContactUs\Controller\Component\ContactUsComponent Test Case
*/
class ContactUsComponentTest extends TestCase
{
class ContactUsComponentTest extends TestCase {
protected ContactUsComponent $component;
protected Controller $controller;
/**
* Test subject
* Fixtures
*
* @var \CakeContactUs\Controller\Component\ContactUsComponent
* @var array<string>
*/
protected $ContactUs;
/**
protected array $fixtures = [
'plugin.CakeContactUs.ContactUsFormSubmissions',
];
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$registry = new ComponentRegistry();
$this->ContactUs = new ContactUsComponent($registry);
}
protected function setUp(): void {
parent::setUp();
$request = new ServerRequest();
$this->controller = new Controller($request);
$registry = new ComponentRegistry($this->controller);
$this->component = new ContactUsComponent($registry);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ContactUs);
protected function tearDown(): void {
unset($this->component);
parent::tearDown();
parent::tearDown();
}
public function testNewContactUsFormWithoutCaptcha()
{
$this->assertInstanceOf(ContactUsFormSubmission::class, $this->component->newContactUsForm());
}
public function testNewContactUsFormWithCaptcha()
{
$this->component->setConfig('requireCaptcha', true);
$this->assertInstanceOf(ContactUsFormSubmission::class, $this->component->newContactUsForm());
}
public function testProcessContactUsFormSaved()
{
$numSubmissionsBefore = $this->fetchTable('CakeContactUs/ContactUsFormSubmissions')->find()->count();
$result = $this->component->processContactUsForm($this->component->newContactUsForm(), [
'name' => 'Jane Doe',
'email' => 'test@example.com',
]);
$this->assertNotInstanceOf(ContactUsFormSubmission::class, $result);
$numSubmissionsAfter = $this->fetchTable('CakeContactUs/ContactUsFormSubmissions')->find()->count();
$this->assertEquals($numSubmissionsBefore + 1, $numSubmissionsAfter);
}
}

View File

@@ -3,317 +3,304 @@ declare(strict_types=1);
namespace CakeContactUs\Test\TestCase\Controller;
use App\Model\Table\ContactUsFormSubmissionsTable;
use Cake\Controller\Controller;
use Cake\Core\Configure;
use Cake\Event\EventList;
use Cake\Event\EventManager;
use Cake\Http\ServerRequest;
use Cake\Mailer\Transport\DebugTransport;
use Cake\ORM\Table;
use Cake\TestSuite\EmailTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
use CakeContactUs\CakeContactUsPlugin;
use CakeContactUs\Controller\ContactUsFormSubmissionsController;
use PHPUnit\Exception;
/**
* CakeContactUs\Controller\ContactUsFormSubmissionsController Test Case
*
* @uses ContactUsFormSubmissionsController
*/
class ContactUsFormSubmissionsControllerTest extends TestCase
{
use IntegrationTestTrait;
use EmailTrait;
class ContactUsFormSubmissionsControllerTest extends TestCase {
/**
* @var ContactUsFormSubmissionsTable|Table
use IntegrationTestTrait;
use EmailTrait;
/**
* @var \App\Model\Table\ContactUsFormSubmissionsTable|\Cake\ORM\Table
*/
protected $ContactUsFormSubmissions;
protected $ContactUsFormSubmissions;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeContactUs.ContactUsFormSubmissions',
];
protected array $fixtures = [
'plugin.CakeContactUs.ContactUsFormSubmissions',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->ContactUsFormSubmissions = $this->getTableLocator()->get('ContactUsFormSubmissions');
protected function setUp(): void {
parent::setUp();
$this->ContactUsFormSubmissions = $this->getTableLocator()->get('ContactUsFormSubmissions');
EventManager::instance()->setEventList(new EventList());
}
EventManager::instance()->setEventList(new EventList());
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ContactUsFormSubmissions);
protected function tearDown(): void {
unset($this->ContactUsFormSubmissions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* Test add method
*
* Tests the add action with a logged in user
*
* @return void
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
* @return void
*/
public function testAddGet(): void
{
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
public function testAddGet(): void {
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$this->get($url);
$this->assertResponseCode(200);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
$this->assertNoMailSent();
}
$this->assertNoMailSent();
}
/**
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @return void
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
*/
public function testAddPostSuccessNoEmail(): void
{
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
public function testAddPostSuccessNoEmail(): void {
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$this->assertNoMailSent();
}
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$this->assertNoMailSent();
}
/**
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @return void
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
* @return void
*/
public function testAddPostSuccessBothEmailsSent(): void
{
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => true, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => true,
'to' => 'test@example.com',
],
],
]);
Configure::write('EmailTransport', [
'default' => [
'className' => DebugTransport::class,
]
]);
public function testAddPostSuccessBothEmailsSent(): void {
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => true, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => true,
'to' => 'test@example.com',
],
],
]);
Configure::write('EmailTransport', [
'default' => [
'className' => DebugTransport::class,
],
]);
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$this->assertMailCount(2); // confirmation + backend emails
}
$this->assertMailCount(2); // confirmation + backend emails
}
/**
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @return void
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
* @return void
*/
public function testAddPostSuccessConfirmationEmailSent(): void
{
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => true, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => false,
'to' => 'test@example.com',
],
],
]);
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
public function testAddPostSuccessConfirmationEmailSent(): void {
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => true, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => false,
'to' => 'test@example.com',
],
],
]);
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$this->assertResponseCode(302);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$this->assertMailCount(1); // confirmation only
}
$this->assertMailCount(1); // confirmation only
}
/**
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @return void
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
* @return void
*/
public function testAddPostSuccessBackendEmailSent(): void
{
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => false, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => true,
'to' => 'test@example.com',
],
],
]);
public function testAddPostSuccessBackendEmailSent(): void {
Configure::write('ContactUs', [
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => false, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => true,
'to' => 'test@example.com',
],
],
]);
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$responseBody = (string)$this->_response->getBody();
$tmpLog = fopen(TMP . 'phpunit.log', 'w');
if ($tmpLog) {
fwrite($tmpLog, $responseBody);
}
$this->assertResponseCode(302);
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'valid_email@test.com',
'message' => 'valid message goes here',
];
$this->post($url, $data);
$responseBody = (string)$this->_response->getBody();
$tmpLog = fopen(TMP . 'phpunit.log', 'w');
if ($tmpLog) {
fwrite($tmpLog, $responseBody);
}
$this->assertResponseCode(302);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore + 1, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_AFTER_CONTACT_US_FORM_SAVED);
$this->assertMailCount(1); // backend email only
}
$this->assertMailCount(1); // backend email only
}
/**
/**
* Test add method
*
* Tests a POST request to the add action with a logged in user
*
* @return void
* @uses ContactUsFormSubmissionsController::add
* @throws Exception
*
* @uses ContactUsFormSubmissionsController::add
* @return void
*/
public function testAddPostLoggedInFailure(): void
{
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
public function testAddPostLoggedInFailure(): void {
$cntBefore = $this->ContactUsFormSubmissions->find()->count();
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$data = [
'name' => 'valid name',
'email' => 'not_valid_email',
'message' => 'this is a valid message ',
];
$this->post($url, $data);
$this->assertResponseCode(200);
// $this->loginUserByRole('admin');
$url = [
'plugin' => 'CakeContactUs',
'controller' => 'ContactUsFormSubmissions',
'action' => 'add',
];
$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);
$this->assertNoMailSent();
}
$cntAfter = $this->ContactUsFormSubmissions->find()->count();
$this->assertEquals($cntBefore, $cntAfter);
$this->assertEventFired(CakeContactUsPlugin::EVENT_BEFORE_CONTACT_US_FORM_SAVED);
$this->assertNoMailSent();
}
}

View File

@@ -9,83 +9,80 @@ use CakeContactUs\Model\Table\ContactUsFormSubmissionsTable;
/**
* CakeContactUs\Model\Table\ContactUsFormSubmissionsTable Test Case
*/
class ContactUsFormSubmissionsTableTest extends TestCase
{
/**
class ContactUsFormSubmissionsTableTest extends TestCase {
/**
* Test subject
*
* @var \CakeContactUs\Model\Table\ContactUsFormSubmissionsTable
*/
protected $ContactUsFormSubmissions;
protected $ContactUsFormSubmissions;
/**
/**
* Fixtures
*
* @var array<string>
*/
protected array $fixtures = [
'plugin.CakeContactUs.ContactUsFormSubmissions',
];
protected array $fixtures = [
'plugin.CakeContactUs.ContactUsFormSubmissions',
];
/**
/**
* setUp method
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$config = $this->getTableLocator()->exists('ContactUsFormSubmissions') ? [] : ['className' => ContactUsFormSubmissionsTable::class];
$this->ContactUsFormSubmissions = $this->getTableLocator()->get('ContactUsFormSubmissions', $config);
}
protected function setUp(): void {
parent::setUp();
$config = $this->getTableLocator()->exists('ContactUsFormSubmissions') ? [] : ['className' => ContactUsFormSubmissionsTable::class];
$this->ContactUsFormSubmissions = $this->getTableLocator()->get('ContactUsFormSubmissions', $config);
}
/**
/**
* tearDown method
*
* @return void
*/
protected function tearDown(): void
{
unset($this->ContactUsFormSubmissions);
protected function tearDown(): void {
unset($this->ContactUsFormSubmissions);
parent::tearDown();
}
parent::tearDown();
}
/**
/**
* TestInitialize method
*
* @return void
* @uses \CakeContactUs\Model\Table\ContactUsFormSubmissionsTable::initialize()
* @return void
*/
public function testInitialize(): void
{
// verify all associations loaded
$expectedAssociations = [];
$associations = $this->ContactUsFormSubmissions->associations();
public function testInitialize(): void {
// verify all associations loaded
$expectedAssociations = [];
$associations = $this->ContactUsFormSubmissions->associations();
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ContactUsFormSubmissions->hasAssociation($expectedAssociation));
}
$this->assertCount(count($expectedAssociations), $associations);
foreach ($expectedAssociations as $expectedAssociation) {
$this->assertTrue($this->ContactUsFormSubmissions->hasAssociation($expectedAssociation));
}
// verify all behaviors loaded
$expectedBehaviors = [];
$behaviors = $this->ContactUsFormSubmissions->behaviors();
// verify all behaviors loaded
$expectedBehaviors = [];
$behaviors = $this->ContactUsFormSubmissions->behaviors();
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ContactUsFormSubmissions->hasBehavior($expectedBehavior));
}
}
$this->assertCount(count($expectedBehaviors), $behaviors);
foreach ($expectedBehaviors as $expectedBehavior) {
$this->assertTrue($this->ContactUsFormSubmissions->hasBehavior($expectedBehavior));
}
}
/**
/**
* Test validationDefault method
*
* @return void
* @uses \CakeContactUs\Model\Table\ContactUsFormSubmissionsTable::validationDefault()
* @return void
*/
public function testValidationDefault(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
public function testValidationDefault(): void {
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@@ -10,20 +10,19 @@ use Cake\Datasource\ConnectionManager;
use Cake\Mailer\Mailer;
use Cake\Mailer\Transport\DebugTransport;
use Cake\Mailer\TransportFactory;
use Cake\TestSuite\Fixture\SchemaLoader;
use CakeContactUs\CakeContactUsPlugin;
use Migrations\TestSuite\Migrator;
use TestApp\Controller\AppController;
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('WINDOWS')) {
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
define('WINDOWS', true);
} else {
define('WINDOWS', false);
}
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
define('WINDOWS', true);
} else {
define('WINDOWS', false);
}
}
define('PLUGIN_ROOT', dirname(__DIR__));
@@ -48,42 +47,42 @@ require CORE_PATH . 'config/bootstrap.php';
require CAKE . 'functions.php';
Configure::write('App', [
'namespace' => '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,
],
],
'namespace' => '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' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => false, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => false,
'to' => 'test@example.com',
],
],
'fields' => [
'captcha' => false,
'email' => true,
],
'email' => [
'mailerClass' => 'CakeContactUs.ContactUsFormSubmissions',
'confirmation' => false, // true or false
'backend' => [ // array with enabled and the to/cc/bcc/ fields as strings or arrays
'enabled' => false,
'to' => 'test@example.com',
],
],
]);
Configure::write('EmailTransport', [
'default' => [
'className' => DebugTransport::class,
]
'default' => [
'className' => DebugTransport::class,
],
]);
TransportFactory::setConfig('default', [
'className' => DebugTransport::class,
'className' => DebugTransport::class,
]);
Configure::write('Email', [
/*
/*
* Email delivery profiles
*
* Delivery profiles allow you to predefine various properties about email
@@ -92,35 +91,35 @@ Configure::write('Email', [
* easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
* for more information.
*/
'default' => [
'transport' => 'default',
'from' => 'test@example.com',
/*
'default' => [
'transport' => 'default',
'from' => 'test@example.com',
/*
* Will by default be set to config value of App.encoding, if that exists otherwise to UTF-8.
*/
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
]);
$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',
],
'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);
@@ -133,15 +132,15 @@ Plugin::getCollection()->add(new CakeContactUsPlugin());
Chronos::setTestNow(Chronos::now());
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite:///:memory:');
putenv('DB_URL=sqlite:///:memory:');
}
ConnectionManager::setConfig('test', [
'className' => Connection::class,
'url' => getenv('DB_URL') ?: null,
'timezone' => 'UTC',
'quoteIdentifiers' => false,
'cacheMetadata' => true,
'className' => Connection::class,
'url' => getenv('DB_URL') ?: null,
'timezone' => 'UTC',
'quoteIdentifiers' => false,
'cacheMetadata' => true,
]);
/**
@@ -156,7 +155,17 @@ ConnectionManager::setConfig('test', [
*/
// Load a schema dump file.
//(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');
if (!defined('SECOND')) {
define('SECOND', 1);
define('MINUTE', 60);
define('HOUR', 3600);
define('DAY', 86400);
define('WEEK', 604800);
define('MONTH', 2592000);
define('YEAR', 31536000);
}
$migrator = new Migrator();
$migrator->run(['plugin' => 'CakeContactUs']);
$migrator->run(['plugin' => 'Captcha']);