2019-02-13 22:47:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Tests\Service;
|
|
|
|
|
|
|
|
use App\Service\Picker;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Tightenco\Collect\Support\Collection;
|
|
|
|
|
|
|
|
class PickerTest extends TestCase
|
|
|
|
{
|
|
|
|
/** @test */
|
|
|
|
public function hosts_for_multiple_events_are_grouped_and_unique()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
[
|
|
|
|
'hosts' => [
|
|
|
|
['host_name' => 'Lee Stone'],
|
|
|
|
['host_name' => 'Dave Liddament'],
|
|
|
|
['host_name' => 'Kat Zien'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'hosts' => [
|
|
|
|
['host_name' => 'Oliver Davies'],
|
|
|
|
['host_name' => 'Lee Stone'],
|
|
|
|
['host_name' => 'Lucia Velasco'],
|
|
|
|
['host_name' => 'Dave Liddament'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$picker = new Picker();
|
|
|
|
$picker->setHosts(collect($data));
|
|
|
|
|
|
|
|
$hosts = $picker->getHosts();
|
|
|
|
$this->assertInstanceOf(Collection::class, $hosts);
|
|
|
|
$this->assertCount(5, $hosts);
|
|
|
|
}
|
2019-02-13 23:28:49 +00:00
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function comments_for_multiple_events_are_flattened_and_combined()
|
|
|
|
{
|
2019-02-14 00:04:07 +00:00
|
|
|
$comments = [
|
2019-02-13 23:53:54 +00:00
|
|
|
[
|
|
|
|
['comment' => 'Great talk!'],
|
|
|
|
['comment' => 'Could be better.'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
['comment' => 'Needs more cat pictures.'],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$picker = new Picker();
|
2019-02-14 00:04:07 +00:00
|
|
|
$picker->setComments(collect($comments));
|
2019-02-13 23:53:54 +00:00
|
|
|
|
2019-02-14 00:04:07 +00:00
|
|
|
$result = $picker->getComments();
|
|
|
|
$this->assertInstanceOf(Collection::class, $result);
|
|
|
|
$this->assertCount(3, $result);
|
2019-02-13 23:28:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function comments_from_event_hosts_cannot_be_picked()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function a_winner_can_be_selected()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
2019-02-13 22:47:34 +00:00
|
|
|
}
|