fixtures suck
This commit is contained in:
@@ -14,19 +14,20 @@ use CakeContactUs\Model\Entity\ContactUsFormSubmission;
|
||||
* CakeContactUs\Controller\Component\ContactUsComponent Test Case
|
||||
*/
|
||||
class ContactUsComponentTest extends TestCase {
|
||||
|
||||
protected ContactUsComponent $component;
|
||||
protected Controller $controller;
|
||||
|
||||
/**
|
||||
|
||||
protected ContactUsComponent $component;
|
||||
|
||||
protected Controller $controller;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeContactUs.ContactUsFormSubmissions',
|
||||
];
|
||||
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeContactUs.ContactUsFormSubmissions',
|
||||
];
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
@@ -34,11 +35,11 @@ class ContactUsComponentTest extends TestCase {
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$request = new ServerRequest();
|
||||
$this->controller = new Controller($request);
|
||||
$registry = new ComponentRegistry($this->controller);
|
||||
|
||||
$this->component = new ContactUsComponent($registry);
|
||||
$request = new ServerRequest();
|
||||
$this->controller = new Controller($request);
|
||||
$registry = new ComponentRegistry($this->controller);
|
||||
|
||||
$this->component = new ContactUsComponent($registry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,27 +52,34 @@ class ContactUsComponentTest extends TestCase {
|
||||
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testNewContactUsFormWithoutCaptcha() {
|
||||
$this->assertInstanceOf(ContactUsFormSubmission::class, $this->component->newContactUsForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testNewContactUsFormWithCaptcha() {
|
||||
$this->component->setConfig('requireCaptcha', true);
|
||||
$this->assertInstanceOf(ContactUsFormSubmission::class, $this->component->newContactUsForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user