コード例 #1
0
 public function testSmtpapiHeaderAccessors()
 {
     $email = new SendGrid\Email();
     $this->assertEquals("{}", $email->getSmtpapiHeadersJson());
     $headers = array("header_1" => array("item_1" => "value_1", "item_2" => "value_2", "item_3" => "value_3"), "header_2" => "value_4", "header_3" => "value_4", "header_4" => array("item_4" => array("sub_item_1" => "sub_value_1", "sub_item_2" => "sub_value_2")));
     $email->setSmtpapiHeaders($headers);
     $this->assertEquals($headers, $email->getSmtpapiHeaders());
     $email->addSmtpapiHeader("simple_header", "simple_value");
     $headers["simple_header"] = "simple_value";
     $this->assertEquals($headers, $email->getSmtpapiHeaders());
     $this->assertEquals("{\"header_1\":{\"item_1\":\"value_1\",\"item_2\":\"value_2\",\"item_3\":\"value_3\"},\"header_2\":\"value_4\",\"header_3\":\"value_4\",\"header_4\":{\"item_4\":{\"sub_item_1\":\"sub_value_1\",\"sub_item_2\":\"sub_value_2\"}},\"simple_header\":\"simple_value\"}", $email->getSmtpapiHeadersJson());
     //remove a header
     $email->removeSmtpapiHeader("simple_header");
     unset($headers["simple_header"]);
     $this->assertEquals($headers, $email->getSmtpapiHeaders());
 }