assertEquals( 'imip', $plugin->getPluginInfo()['name'] ); } function testDeliverReply() { $message = new Message(); $message->sender = 'mailto:sender@example.org'; $message->senderName = 'Sender'; $message->recipient = 'mailto:recipient@example.org'; $message->recipientName = 'Recipient'; $message->method = 'REPLY'; $ics = <<message = Reader::read($ics); $result = $this->schedule($message); $expected = [ [ 'to' => 'Recipient ', 'subject' => 'Re: Birthday party', 'body' => $ics, 'headers' => [ 'Reply-To: Sender ', 'From: system@example.org', 'Content-Type: text/calendar; charset=UTF-8; method=REPLY', 'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION, ], ] ]; $this->assertEquals($expected, $result); } function testDeliverReplyNoMailto() { $message = new Message(); $message->sender = 'mailto:sender@example.org'; $message->senderName = 'Sender'; $message->recipient = 'http://example.org/recipient'; $message->recipientName = 'Recipient'; $message->method = 'REPLY'; $ics = <<message = Reader::read($ics); $result = $this->schedule($message); $expected = []; $this->assertEquals($expected, $result); } function testDeliverRequest() { $message = new Message(); $message->sender = 'mailto:sender@example.org'; $message->senderName = 'Sender'; $message->recipient = 'mailto:recipient@example.org'; $message->recipientName = 'Recipient'; $message->method = 'REQUEST'; $ics = <<message = Reader::read($ics); $result = $this->schedule($message); $expected = [ [ 'to' => 'Recipient ', 'subject' => 'Birthday party', 'body' => $ics, 'headers' => [ 'Reply-To: Sender ', 'From: system@example.org', 'Content-Type: text/calendar; charset=UTF-8; method=REQUEST', 'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION, ], ] ]; $this->assertEquals($expected, $result); } function testDeliverCancel() { $message = new Message(); $message->sender = 'mailto:sender@example.org'; $message->senderName = 'Sender'; $message->recipient = 'mailto:recipient@example.org'; $message->recipientName = 'Recipient'; $message->method = 'CANCEL'; $ics = <<message = Reader::read($ics); $result = $this->schedule($message); $expected = [ [ 'to' => 'Recipient ', 'subject' => 'Cancelled: Birthday party', 'body' => $ics, 'headers' => [ 'Reply-To: Sender ', 'From: system@example.org', 'Content-Type: text/calendar; charset=UTF-8; method=CANCEL', 'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION, ], ] ]; $this->assertEquals($expected, $result); $this->assertEquals('1.1', substr($message->scheduleStatus, 0, 3)); } function schedule(Message $message) { $plugin = new IMip\MockPlugin('system@example.org'); $server = new Server(); $server->addPlugin($plugin); $server->emit('schedule', [$message]); return $plugin->getSentEmails(); } function testDeliverInsignificantRequest() { $message = new Message(); $message->sender = 'mailto:sender@example.org'; $message->senderName = 'Sender'; $message->recipient = 'mailto:recipient@example.org'; $message->recipientName = 'Recipient'; $message->method = 'REQUEST'; $message->significantChange = false; $ics = <<message = Reader::read($ics); $result = $this->schedule($message); $expected = []; $this->assertEquals($expected, $result); $this->assertEquals('1.0', $message->getScheduleStatus()[0]); } }