Пример #1
0
 public function testSectionAccessors()
 {
     $email = new \SendGrid\Email();
     $sections = ["sub_1" => ["val_1.1", "val_1.2", "val_1.3"], "sub_2" => ["val_2.1", "val_2.2"], "sub_3" => ["val_3.1", "val_3.2", "val_3.3", "val_3.4"], "sub_4" => ["val_4.1", "val_4.2", "val_4.3"]];
     $email->setSections($sections);
     $this->assertEquals('{"section":{"sub_1":["val_1.1","val_1.2","val_1.3"],"sub_2":["val_2.1","val_2.2"],"sub_3":["val_3.1","val_3.2","val_3.3","val_3.4"],"sub_4":["val_4.1","val_4.2","val_4.3"]}}', $email->getSmtpapi()->jsonString());
 }
 public function testSectionAccessors()
 {
     $email = new SendGrid\Email();
     $sections = array("sub_1" => array("val_1.1", "val_1.2", "val_1.3"), "sub_2" => array("val_2.1", "val_2.2"), "sub_3" => array("val_3.1", "val_3.2", "val_3.3", "val_3.4"), "sub_4" => array("val_4.1", "val_4.2", "val_4.3"));
     $email->setSections($sections);
     $header = $email->getSmtpapiHeaders();
     $this->assertEquals($sections, $header['section']);
     $this->assertEquals("{\"section\":{\"sub_1\":[\"val_1.1\",\"val_1.2\",\"val_1.3\"],\"sub_2\":[\"val_2.1\",\"val_2.2\"],\"sub_3\":[\"val_3.1\",\"val_3.2\",\"val_3.3\",\"val_3.4\"],\"sub_4\":[\"val_4.1\",\"val_4.2\",\"val_4.3\"]}}", $email->getSmtpapiHeadersJson());
     // ensure that addSubstitution appends to the list of substitutions
     $section_vals = array("val_5.1", "val_5.2", "val_5.3", "val_5.4");
     $email->addSection("sub_5", $section_vals);
     $sections["sub_5"] = $section_vals;
     $header = $email->getSmtpapiHeaders();
     $this->assertEquals(5, count($header['section']));
     $this->assertEquals($sections, $header['section']);
 }
Пример #3
0
 public function it_sets_mailer_data(\SendGrid $sendGrid)
 {
     $this->setData(['from_name' => 'Master Jedi Yoda', 'from_email' => '*****@*****.**', 'subject' => 'Example subject', 'template' => 'example template', 'recipients' => ['*****@*****.**' => new Recipient('Jane Doe', '*****@*****.**')], 'global_vars' => ['global_one' => 'Example', 'global_two' => 'Another example'], 'local_vars' => ['*****@*****.**' => [new Variable('local', 'Yet another example')]], 'headers' => [], 'reply_to' => null, 'attachments' => []]);
     $email = new \SendGrid\Email();
     $email->setFrom('*****@*****.**');
     $email->setFromName('Master Jedi Yoda');
     $email->addSmtpapiTo('*****@*****.**', 'Jane Doe');
     $email->setSubject('Example subject');
     $email->setHtml(' ');
     $email->setTemplateId('example template');
     $email->setSections(['global_one_SECTION' => 'Example', 'global_two_SECTION' => 'Another example']);
     $email->setSubstitutions(['local' => ['Yet another example'], 'global_one' => ['global_one_SECTION'], 'global_two' => ['global_two_SECTION']]);
     $sendGrid->send($email)->shouldBeCalled();
     $this->send('Example subject', 'example template')->shouldReturn(true);
 }
Пример #4
0
 public function testSectionAccessors()
 {
     $email = new SendGrid\Email();
     $sections = array("sub_1" => array("val_1.1", "val_1.2", "val_1.3"), "sub_2" => array("val_2.1", "val_2.2"), "sub_3" => array("val_3.1", "val_3.2", "val_3.3", "val_3.4"), "sub_4" => array("val_4.1", "val_4.2", "val_4.3"));
     $email->setSections($sections);
     $this->assertEquals("{\"section\":{\"sub_1\":[\"val_1.1\",\"val_1.2\",\"val_1.3\"],\"sub_2\":[\"val_2.1\",\"val_2.2\"],\"sub_3\":[\"val_3.1\",\"val_3.2\",\"val_3.3\",\"val_3.4\"],\"sub_4\":[\"val_4.1\",\"val_4.2\",\"val_4.3\"]}}", $email->smtpapi->jsonString());
 }