Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Commit

Permalink
Update to the latest version of KB
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed May 8, 2016
1 parent 5f10c69 commit 81a0909
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
10 changes: 6 additions & 4 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public function initialize()
{
$this->emailClient->setTransport('sendgrid', '\Kanboard\Plugin\Sendgrid\EmailHandler');
$this->template->hook->attach('template:config:integrations', 'sendgrid:integration');
$this->route->addRoute('/sendgrid/handler/:token', 'webhook', 'receiver', 'sendgrid');
}

$this->on('app.bootstrap', function ($container) {
Translator::load($container['config']->getCurrentLanguage(), __DIR__.'/Locale');
});
public function onStartup()
{
Translator::load($this->language->getCurrentLanguage(), __DIR__.'/Locale');
}

public function getPluginDescription()
Expand All @@ -35,7 +37,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.2';
return '1.0.3';
}

public function getPluginHomepage()
Expand Down
4 changes: 2 additions & 2 deletions Template/integration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h3><img src="<?= $this->url->dir() ?>plugins/Sendgrid/sendgrid-icon.png"/>&nbsp;Sendgrid</h3>
<div class="listing">
<input type="text" class="auto-select" readonly="readonly" value="<?= $this->url->href('webhook', 'receiver', array('plugin' => 'sendgrid', 'token' => $values['webhook_token']), false, '', true) ?>"/><br/>
<p class="form-help"><a href="https://github.com/kanboard/plugin-sendgrid" target="_blank"><?= t('Help on Sendgrid integration') ?></a></p>
</div>
<p class="form-help"><a href="https://kanboard.net/plugin/sendgrid" target="_blank"><?= t('Help on Sendgrid integration') ?></a></p>
</div>
31 changes: 9 additions & 22 deletions Test/EmailHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,17 @@ class SendgridTest extends Base
{
public function testSendEmail()
{
$this->container['httpClient']
->expects($this->once())
->method('postForm')
->with(
'https://api.sendgrid.com/api/mail.send.json',
$this->anything(),
$this->anything()
);

$pm = new EmailHandler($this->container);
$pm->sendEmail('test@localhost', 'Me', 'Test', 'Content', 'Bob');

$this->assertEquals('https://api.sendgrid.com/api/mail.send.json', $this->container['httpClient']->getUrl());

$data = $this->container['httpClient']->getData();

$this->assertArrayHasKey('api_user', $data);
$this->assertArrayHasKey('api_key', $data);
$this->assertArrayHasKey('from', $data);
$this->assertArrayHasKey('fromname', $data);
$this->assertArrayHasKey('to', $data);
$this->assertArrayHasKey('toname', $data);
$this->assertArrayHasKey('subject', $data);
$this->assertArrayHasKey('html', $data);

$this->assertEquals('test@localhost', $data['to']);
$this->assertEquals('Me', $data['toname']);
$this->assertEquals('[email protected]', $data['from']);
$this->assertEquals('Bob', $data['fromname']);
$this->assertEquals('Test', $data['subject']);
$this->assertEquals('Content', $data['html']);
$this->assertEquals('', $data['api_key']);
$this->assertEquals('', $data['api_user']);
}

public function testHandlePayload()
Expand Down
1 change: 1 addition & 0 deletions Test/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function testPlugin()
{
$plugin = new Plugin($this->container);
$this->assertSame(null, $plugin->initialize());
$this->assertSame(null, $plugin->onStartup());
$this->assertNotEmpty($plugin->getPluginName());
$this->assertNotEmpty($plugin->getPluginDescription());
$this->assertNotEmpty($plugin->getPluginAuthor());
Expand Down

0 comments on commit 81a0909

Please sign in to comment.