Пример #1
0
 public function testGetDescription()
 {
     $handler = new EmailHandler($this->container);
     $this->assertEquals('**Test**', $handler->getDescription(array('stripped-html' => '<b>Test</b>')));
     $this->assertEquals('foobar', $handler->getDescription(array('stripped-html' => '', 'stripped-text' => 'foobar')));
     $this->assertEquals('', $handler->getDescription(array('stripped-html' => '', 'stripped-text' => '')));
 }
 public function testHandlePayload()
 {
     $w = new EmailHandler($this->container);
     $p = new Project($this->container);
     $pp = new ProjectUserRole($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('username' => '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->receiveEmail(array()));
     // Unknown user
     $this->assertFalse($w->receiveEmail(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
     // Project not found
     $this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
     // User is not member
     $this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));
     // The task must be created
     $this->assertTrue($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-html' => '<strong>boo</strong>')));
     $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']);
 }
Пример #3
0
 /**
  * Handle Mailgun webhooks
  *
  * @access public
  */
 public function receiver()
 {
     $this->checkWebhookToken();
     $handler = new EmailHandler($this->container);
     echo $handler->receiveEmail($_POST) ? 'PARSED' : 'IGNORED';
 }