/** * @depends testSMTPEmailCustomHeaders */ public function testMultipleRecipients() { // phpunit is a bit broken so we manually call the dependent tests; $this->testSMTPEmailCustomHeaders(); $to = '*****@*****.**'; $to2 = '*****@*****.**'; $e = new SMTPEmail(); $e->To = $to . ', ' . $to2; $e->Subject = "Hi there"; $e->Body = "I just really wanted to email you and say hi."; // get the mailer bound to the Email class $e->setupMailer(); $mailer = SMTPEmail::mailer()->mailer; // check recipients $tos = $mailer->getToAddresses(); $exists = $exists2 = false; foreach ($tos as $item) { if (in_array($to, $item)) { $exists = true; } if (in_array($to2, $item)) { $exists2 = true; } } $this->assertEquals(true, $exists && $exists2); // check send $this->assertEquals(true, $e->send()); }
/** * @depends testSMTPEmail */ public function testStringAttachmentEmail() { // phpunit is a bit broken so we manually call the dependent tests; $this->testSMTPEmail(); // create file $fileContents = 'test content'; $fileName = 'test.txt'; $type = 'text/plain'; // create email $e = new SMTPEmail(); $e->To = '*****@*****.**'; $e->Subject = "Hi there"; $e->Body = "I just really wanted to email you and say hi."; $e->attachFileFromString($fileContents, $fileName, $type); // get the mailer bound to the Email class $e->setupMailer(); $mailer = SMTPEmail::mailer()->mailer; // check attached files $files = $mailer->getAttachments(); $this->assertEquals(true, $files[0][0] == $fileContents); $this->assertEquals(true, $files[0][1] == $fileName); $this->assertEquals(true, $files[0][4] == $type); // check send $this->assertEquals(true, $e->send()); }