Passed
Push — develop ( 417183...699825 )
by Michael
07:58
created

extractData_plugin_swarmzapierstructwebhook_test   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 48
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_extractDataFromPayload() 0 9 1
A dataProvider() 0 23 1
1
<?php
2
3
/**
4
 * General tests for the swarmzapierstructwebhook plugin
5
 *
6
 * @group plugin_swarmzapierstructwebhook
7
 * @group plugins
8
 */
9
class extractData_plugin_swarmzapierstructwebhook_test extends DokuWikiTest
1 ignored issue
show
Bug introduced by
The type DokuWikiTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
{
11
    /** @var array alway enable the needed plugins */
12
    protected $pluginsEnabled = ['swarmzapierstructwebhook'];
13
14
    public function dataProvider()
15
    {
16
        return [
17
            [
18
                '{"createdAt": "1525849118", "like": "False", "isMayor": "True", "editableUntil": "1525935518000", "posts": {"count": "0", "textCount": "0"}, "comments": {"count": "0"}, "photos": {"count": "0", "items": ""}, "likes": {"count": "0", "groups": ""}, "venue": {"stats": {"tipCount": "2", "checkinsCount": "1552", "usersCount": "24"}, "name": "CosmoCode", "venueRatingBlacklisted": "True", "url": "http://www.cosmocode.de", "contact": {"twitter": "cosmocode"}, "location": {"city": "Berlin", "labeledLatLngs": "label: display\nlat: 52.5341728565\nlng: 13.4235969339", "cc": "DE", "country": "Germany", "postalCode": "10405", "state": "Berlin", "formattedAddress": "Prenzlauer Allee 36 (Marienburger Strasse),10405 Berlin", "crossStreet": "Marienburger Strasse", "address": "Prenzlauer Allee 36", "lat": "52.5341728565", "lng": "13.4235969339"}, "beenHere": {"lastCheckinExpiredAt": "0"}, "verified": "False", "id": "4b4ca6c8f964a520f8b826e3", "categories": "icon: {u\'prefix\': u\'https://ss3.4sqi.net/img/categories_v2/building/default_\', u\'suffix\': u\'.png\'}\nid: 4bf58dd8d48988d124941735\nname: Office\npluralName: Offices\nprimary: True\nshortName: Office"}, "type": "checkin", "id": "5af29c1e6fd626002c38730b", "timeZoneOffset": "120", "source": {"url": "https://www.swarmapp.com", "name": "Swarm for Android"}}',
19
                [
20
                    'date' => '2018-05-09',
21
                    'time' => '2018-05-09T08:58:38+02:00',
22
                    'checkinid' => '5af29c1e6fd626002c38730b',
23
                    'locname' => 'CosmoCode',
24
                ],
25
                'normal event without shout',
26
            ],
27
            [
28
                '{"entities": "", "createdAt": "1526051437", "like": "False", "isMayor": "False", "editableUntil": "1526137837000", "sticker": {"bonusStatus": "Use once per week. Recharges Sunday at midnight.", "group": {"index": "85", "name": "collectible"}, "name": "Baggs", "unlockText": "They\'re out of milk, your cart\'s wheel is busted, and that lady has way more than 10 items! Here\'s hoping Baggs doesn\'t dump your eggs on the ground.", "image": {"prefix": "https://irs1.4sqi.net/img/sticker/", "name": "/groceries_2a2425.png", "sizes": "60,94,150,300"}, "pickerPosition": {"index": "13", "page": "3"}, "points": "2", "teaseText": "Check in at food & drink shops to unlock this sticker.", "bonusText": "Use at Food & Drink Shops for a bonus.", "id": "55563bd52beaa0fbc4d1dc3f", "stickerType": "unlockable"}, "posts": {"count": "0", "textCount": "0"}, "comments": {"count": "0"}, "photos": {"count": "0", "items": ""}, "shout": "Reiswaffeln \ud83c\udf5a", "likes": {"count": "0", "groups": ""}, "venue": {"stats": {"tipCount": "0", "checkinsCount": "368", "usersCount": "140"}, "name": "EDEKA Rhinstra\u00dfe", "url": "http://www.kaisers.de", "allowMenuUrlEdit": "True", "contact": {"facebookName": "Kaiser\'s Berlin", "facebookUsername": "KaisersBerlin", "facebook": "352765558110244", "formattedPhone": "0208 37770", "phone": "020837770"}, "location": {"city": "Berlin", "labeledLatLngs": "label: display\nlat: 52.5135124211\nlng: 13.5182151518", "cc": "DE", "country": "Germany", "postalCode": "10315", "state": "Berlin", "formattedAddress": "Rhinstr. 17,10315 Berlin", "address": "Rhinstr. 17", "lat": "52.5135124211", "lng": "13.5182151518"}, "beenHere": {"lastCheckinExpiredAt": "0"}, "verified": "True", "id": "4d79bd5b7418a14366cfc05b", "categories": "icon: {u\'prefix\': u\'https://ss3.4sqi.net/img/categories_v2/shops/food_grocery_\', u\'suffix\': u\'.png\'}\nid: 52f2ab2ebcbc57f1066b8b46\nname: Supermarket\npluralName: Supermarkets\nprimary: True\nshortName: Supermarket"}, "type": "checkin", "id": "5af5b26d898bdc002c7a17db", "timeZoneOffset": "120", "source": {"url": "https://www.swarmapp.com", "name": "Swarm for Android"}}',
29
                [
30
                    'date' => '2018-05-11',
31
                    'time' => '2018-05-11T17:10:37+02:00',
32
                    'checkinid' => '5af5b26d898bdc002c7a17db',
33
                    'locname' => 'EDEKA Rhinstraße',
34
                    'shout' => 'Reiswaffeln 🍚',
35
                ],
36
                'normal event with shout and sticker',
37
            ]
38
        ];
39
    }
40
41
    /**
42
     * @dataProvider dataProvider
43
     *
44
     * @param $inputJSON
45
     * @param $expectedExtractedData
46
     * @param $msg
47
     */
48
    public function test_extractDataFromPayload($inputJSON, $expectedExtractedData, $msg)
49
    {
50
        /** @var helper_plugin_swarmzapierstructwebhook $helper */
51
        $helper = plugin_load('helper', 'swarmzapierstructwebhook');
1 ignored issue
show
Bug introduced by
The function plugin_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $helper = /** @scrutinizer ignore-call */ plugin_load('helper', 'swarmzapierstructwebhook');
Loading history...
52
        $inputArray = json_decode($inputJSON, true);
53
54
        $actualExtractedData = $helper->extractDataFromPayload($inputArray);
55
56
        $this->assertEquals($expectedExtractedData, $actualExtractedData, $msg);
57
    }
58
}