diff --git a/src/Email/Email.php b/src/Email/Email.php new file mode 100644 index 0000000..eb34778 --- /dev/null +++ b/src/Email/Email.php @@ -0,0 +1,73 @@ +recipients[] = $email; + } + + public function getRecipients(): array + { + return $this->recipients; + } + + public function addCC(string $email): void + { + $this->cc[] = $email; + } + + public function getCC(): array + { + return $this->cc; + } + + public function addBCC(string $email): void + { + $this->bcc[] = $email; + } + + public function getBCC(): array + { + return $this->bcc; + } + + public function setSubject(string $subject): void + { + $this->subject = $subject; + } + + public function getSubject(): string + { + return $this->subject; + } + + public function setBody(string $body): void + { + $this->body = $body; + } + + public function getBody(): string + { + return $this->body; + } + + public function addAttachment(string $path): void + { + $this->fileAttachments[] = $path; + } + + public function getAttachments(): array + { + return $this->fileAttachments; + } +} diff --git a/src/Email/Emailer.php b/src/Email/Emailer.php new file mode 100644 index 0000000..0f1d3df --- /dev/null +++ b/src/Email/Emailer.php @@ -0,0 +1,10 @@ +sentEmailCount; + } + + public function send(Email $email): bool + { + if (count($email->getRecipients()) > 0) { + $this->sentEmailCount++; + + return true; + } + + return false; + } +} diff --git a/tests/Unit/Email/EmailTest.php b/tests/Unit/Email/EmailTest.php new file mode 100644 index 0000000..5a8ec5c --- /dev/null +++ b/tests/Unit/Email/EmailTest.php @@ -0,0 +1,58 @@ +email = new Email(); + } + + public function test_email_recipients(): void + { + $emailAddress = 'test@email.com'; + $this->email->addRecipient($emailAddress); + $this->assertEquals([$emailAddress], $this->email->getRecipients()); + } + + public function test_email_cc(): void + { + $emailAddress = 'test@email.com'; + $this->email->addCC($emailAddress); + $this->assertEquals([$emailAddress], $this->email->getCC()); + } + + public function test_email_bcc(): void + { + $emailAddress = 'test@email.com'; + $this->email->addBCC($emailAddress); + $this->assertEquals([$emailAddress], $this->email->getBCC()); + } + + public function test_email_subject(): void + { + $subject = 'test subject'; + $this->email->setSubject($subject); + $this->assertEquals($subject, $this->email->getSubject()); + } + + public function test_email_body(): void + { + $body = 'test body'; + $this->email->setBody($body); + $this->assertEquals($body, $this->email->getBody()); + } + + public function test_email_attachments(): void + { + $path = '/path/to/file'; + $this->email->addAttachment($path); + $this->assertEquals([$path], $this->email->getAttachments()); + } +}