Esempio n. 1
0
 public function testCCAccessors()
 {
     $this->iniSet('sendmail_from', '');
     $mail = new \r8\Mail($this->getTestTransport());
     $this->assertEquals(array(), $mail->getCC());
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->hasCCs());
     $this->assertSame($mail, $mail->addCC('*****@*****.**'));
     $this->assertEquals(array('*****@*****.**' => array('email' => '*****@*****.**', 'name' => null)), $mail->getCC());
     $this->assertTrue($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->hasCCs());
     $this->assertSame($mail, $mail->addCC('*****@*****.**', 'Label'));
     $this->assertEquals(array('*****@*****.**' => array('email' => '*****@*****.**', 'name' => 'Label')), $mail->getCC());
     $this->assertTrue($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->hasCCs());
     $this->assertSame($mail, $mail->addCC('*****@*****.**', 'Name'));
     $this->assertEquals(array('*****@*****.**' => array('email' => '*****@*****.**', 'name' => 'Label'), '*****@*****.**' => array('email' => '*****@*****.**', 'name' => 'Name')), $mail->getCC());
     $this->assertTrue($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->hasCCs());
     $this->assertSame($mail, $mail->removeCC('*****@*****.**'));
     $this->assertEquals(array('*****@*****.**' => array('email' => '*****@*****.**', 'name' => 'Name')), $mail->getCC());
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->ccExists('*****@*****.**'));
     $this->assertTrue($mail->hasCCs());
     $this->assertSame($mail, $mail->clearCC());
     $this->assertEquals(array(), $mail->getCC());
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->hasCCs());
     try {
         $this->assertSame($mail, $mail->addCC("  "));
         $this->fail("An expected exception was not thrown");
     } catch (\r8\Exception\Data $err) {
         $this->assertSame("Email Address must not be empty", $err->getMessage());
     }
     $this->assertSame($mail, $mail->clearCC());
     $this->assertEquals(array(), $mail->getCC());
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->ccExists('*****@*****.**'));
     $this->assertFalse($mail->hasCCs());
 }