1<?php
2
3namespace dokuwiki\plugin\swarmwebhook\test;
4
5/**
6 * General tests for the swarmwebhook plugin
7 *
8 * @group plugin_swarmwebhook
9 * @group plugins
10 */
11class IFTTTfullWebhook extends \DokuWikiTest
12{
13    /** @var array alway enable the needed plugins */
14    protected $pluginsEnabled = ['swarmwebhook', 'struct', 'sqlite'];
15
16    public function test_parseTimeIntoTimestamp()
17    {
18        $inputJSON = '{
19        "ts":"May 25, 2018 at 04:32PM",
20     "shout":"",
21     "VenueName":"Stiftung Für Effektiven Altruismus",
22     "VenueUrl":"https://4sq.com/2kfnC4d",
23     "VenueMapImageUrl":"http://maps.google.com/maps/api/staticmap?center=52.509712,13.324584&zoom=16&size=710x440&maptype=roadmap&sensor=false&markers=color:red%7C52.509712,13.324584"
24     }';
25
26        $IFTTT = new mock\IFTTT();
27
28        $IFTTT->run($inputJSON);
29
30        /** @var \remote_plugin_struct $remote */
31        $remote = plugin_load('remote', 'struct');
32        $rows = $remote->getAggregationData(
33            ['swarm'],
34            ['*']
35        );
36
37        $expectedRows = [
38            'swarm.date' => '2018-05-25',
39            'swarm.json' => $inputJSON,
40            'swarm.locname' => 'Stiftung Für Effektiven Altruismus',
41            'swarm.checkinid' => 'May 25, 2018 at 04:32PM',
42            'swarm.shout' => '',
43            'swarm.time' => '2018-05-25 16:32',
44            'swarm.service' => 'IFTTT',
45        ];
46
47//        $this->assertTrue($actualOK, 'single event, initially creating the schema');
48        $this->assertEquals($rows[0], $expectedRows);
49    }
50}