Skip to content

Commit

Permalink
add an extra database seed in order to test SlackUser factorying
Browse files Browse the repository at this point in the history
add test case for log clear command
  • Loading branch information
elfaus committed Aug 13, 2016
1 parent d73163c commit bfe7226
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
67 changes: 67 additions & 0 deletions tests/SlackLogsClearTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* User: Warlof Tutsimo <loic.leuilliot@gmail.com>
* Date: 09/08/2016
* Time: 16:25
*/

namespace Seat\Slackbot\Tests;

use Orchestra\Testbench\TestCase;
use Seat\Services\Settings\Seat;
use Seat\Slackbot\Commands\SlackChannelsUpdate;
use Seat\Slackbot\Commands\SlackLogsClear;
use Seat\Slackbot\Helpers\SlackApi;
use Seat\Slackbot\Models\SlackChannel;
use Seat\Slackbot\Models\SlackLog;

class SlackLogsClearTest extends TestCase
{
/**
* @var SlackApi
*/
private $slackApi;

public function getEnvironmentSetUp($app)
{
$app['config']->set('database.default', 'mysql');
$app['config']->set('database.connections.mysql', [
'driver' => 'mysql',
'host' => getenv('database_host'),
'database' => getenv('database_name'),
'username' => getenv('database_user'),
'password' => getenv('database_pass'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
]);
}

public function testChannelUpdate()
{
$logAmount = SlackLog::all()->count();
$this->assertGreaterThan(0, $logAmount);

$command = new SlackLogsClear();
$command->handle();

$logAmount = SlackLog::all()->count();

// compare both array
$this->assertEquals(0, $logAmount);
}

/**
* @expectedException Seat\Slackbot\Exceptions\SlackSettingException
*/
public function testTokenException()
{
// pre test
Seat::set('slack_token', '');

// test
$job = new SlackChannelsUpdate();
$job->handle();
}
}
1 change: 1 addition & 0 deletions tests/SlackUsersUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function testUserUpdate()
Seat::set('slack_token', getenv('slack_token'));

$artifacts = [new SlackUser(['user_id' => 1, 'slack_id' => 'U1Z9LT9NM']),
new SlackUser(['user_id' => 2, 'slack_id' => 'U1Z9QVCJW']),
new SlackUser(['user_id' => 3, 'slack_id' => 'U1Z9LT9NK'])];

// test
Expand Down
3 changes: 1 addition & 2 deletions tests/artifacts/public_channel.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"is_member": true,
"members": [
"U1Z8TCZAT",
"U1Z9HSP1T",
"U1Z9QVCJW"
"U1Z9HSP1T"
],
"topic": {
"value": "Non-work banter and water cooler conversation",
Expand Down
14 changes: 13 additions & 1 deletion tests/scripts/seeding.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ VALUES ('1', 'admin', NULL, 'loic67@hotmail.fr', '$2y$10$fjvF.gn2zr.gEaLUSvxS/uy
INSERT INTO `users` (`id`, `name`, `eve_id`, `email`, `password`, `token`, `active`, `last_login`, `last_login_source`, `remember_token`, `created_at`, `updated_at`)
VALUES ('3', 'test', NULL, 'elfaus@hotmail.fr', '$2y$10$fjvF.gn2zr.gEaLUSvxS/uyYuuG.dD0uNX7EokRg9ZJI.W4sK2rqu', NULL, '1', '2016-08-08 11:12:23', '192.168.1.34', 'R7JLEM6h0Rr5SthIcjUHBWzWfD0BtmTSedFXalbJ9j3C0PKFgkaDjV0SmB1N', '2016-08-07 20:27:19', '2016-08-08 11:12:23');

INSERT INTO `users` (`id`, `name`, `eve_id`, `email`, `password`, `token`, `active`, `last_login`, `last_login_source`, `remember_token`, `created_at`, `updated_at`)
VALUES ('2', 'test', NULL, 'tmnf1gp@free.fr', '$2y$10$fjvF.gn2zr.gEaLUSvxS/uyYuuG.dD0uNX7EokRg9ZJI.W4sK2rqu', NULL, '1', '2016-08-08 11:12:23', '192.168.1.34', 'R7JLEM6h0Rr5SthIcjUHBWzWfD0BtmTSedFXalbJ9j3C0PKFgkaDjV0SmB1N', '2016-08-07 20:27:19', '2016-08-08 11:12:23');

INSERT INTO `eve_alliance_lists` (`allianceID`, `name`, `shortName`, `executorCorpID`, `memberCount`, `startDate`, `created_at`, `updated_at`)
VALUES ('99000006', 'Everto Rex Regis', '666', '1983708877', '3', '2010-11-04 13:11:00', '2016-06-20 01:00:49', '2016-06-20 01:00:49');

Expand Down Expand Up @@ -34,4 +37,13 @@ INSERT INTO `slack_channel_public` (`channel_id`, `enable`, `created_at`, `updat
VALUES ('C1Z920QKC', '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00');

INSERT INTO `slack_channel_users` (`user_id`, `channel_id`, `enable`, `created_at`, `updated_at`)
VALUES ('1', 'C1Z920QKC', '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00');
VALUES ('1', 'C1Z920QKC', '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00');

INSERT INTO `slack_logs` (`id`, `event`, `message`)
VALUES ('100', 'kick', 'Some user has been kicked from following channels : ');

INSERT INTO `slack_logs` (`id`, `event`, `message`)
VALUES ('101', 'kick', 'Some user has been kicked from following channels : ');

INSERT INTO `slack_logs` (`id`, `event`, `message`)
VALUES ('102', 'invite', 'Some user has been invited to following channels : ');

0 comments on commit bfe7226

Please sign in to comment.