From ac86c3100a1030026024c33c1cf02ec79f08ff51 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 19 Apr 2015 16:01:41 -0400 Subject: Add Mailgun integration (incoming emails) --- tests/units/MailgunWebhookTest.php | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/units/MailgunWebhookTest.php (limited to 'tests') diff --git a/tests/units/MailgunWebhookTest.php b/tests/units/MailgunWebhookTest.php new file mode 100644 index 00000000..c2745180 --- /dev/null +++ b/tests/units/MailgunWebhookTest.php @@ -0,0 +1,51 @@ +container); + $p = new Project($this->container); + $pp = new ProjectPermission($this->container); + $u = new User($this->container); + $tc = new TaskCreation($this->container); + $tf = new TaskFinder($this->container); + + $this->assertEquals(2, $u->create(array('name' => 'me', 'email' => 'me@localhost'))); + + $this->assertEquals(1, $p->create(array('name' => 'test1'))); + $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1'))); + + // Empty payload + $this->assertFalse($w->parsePayload(array())); + + // Unknown user + $this->assertFalse($w->parsePayload(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo'))); + + // Project not found + $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo'))); + + // User is not member + $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo'))); + $this->assertTrue($pp->addMember(2, 2)); + + // The task must be created + $this->assertTrue($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo'))); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(2, $task['project_id']); + $this->assertEquals('Email task', $task['title']); + $this->assertEquals('boo', $task['description']); + $this->assertEquals(2, $task['creator_id']); + } +} -- cgit v1.2.3