*/ protected array $fixtures = [ 'plugin.CakeContactUs.ContactUsFormSubmissions', ]; /** * setUp method * * @return void */ 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->component); parent::tearDown(); } /** * @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); } }