Passed
Branch master (ad0425)
by Mark
02:23
created

action_plugin_socialcards_test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright (c) 2016 Mark C. Prins <[email protected]>
4
 *
5
 * Permission to use, copy, modify, and distribute this software for any
6
 * purpose with or without fee is hereby granted, provided that the above
7
 * copyright notice and this permission notice appear in all copies.
8
 *
9
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
 */
17
18
/**
19
 * Action tests for the socialcards plugin.
20
 *
21
 * @group plugin_socialcards
22
 * @group plugins
23
 */
24
class action_plugin_socialcards_test extends DokuWikiTest {
25
26
    protected $pluginsEnabled = array('socialcards');
27
28
    public function setUp() {
29
        global $conf;
30
31
        parent::setUp();
32
33
        $conf ['plugin']['socialcards']['twitterName'] = '@twitterName';
34
        $conf ['plugin']['socialcards']['twitterUserName'] = '@twitterUserName';
35
    }
36
37
    public function testHeaders() {
38
        $request = new TestRequest();
39
        $response = $request->get(array('id'=>'wiki:dokuwiki'), '/doku.php');
40
41
        print_r($response);
42
43
        $this->assertTrue(
44
            strpos($response->getContent(), 'DokuWiki') !== false,
45
            'DokuWiki was not a word in the output'
46
        );
47
48
        // check twitter meta headers
49
        $this->assertEquals('DokuWiki',
50
                        $response->queryHTML('meta[name="twitter:title"]')->attr('content'));
51
        $this->assertEquals('@twitterName',
52
                        $response->queryHTML('meta[name="twitter:site"]')->attr('content'));
53
        $this->assertEquals('summary',
54
                        $response->queryHTML('meta[name="twitter:card"]')->attr('content'));
55
        $this->assertEquals('@twitterUserName',
56
                        $response->queryHTML('meta[name="twitter:creator"]')->attr('content'));
57
        $this->assertEquals('http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png',
58
                        $response->queryHTML('meta[name="twitter:image"]')->attr('content'));
59
        $this->assertEquals('',
60
                        $response->queryHTML('meta[name="twitter:image:alt"]')->attr('content'));
61
62
        // check og meta headers
63
        $this->assertEquals('My Test Wiki',
64
                        $response->queryHTML('meta[property="og:site_name"]')->attr('content'));
65
        $this->assertEquals('en_US',
66
                        $response->queryHTML('meta[property="og:locale"]')->attr('content'));
67
        $this->assertEquals('http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png',
68
                        $response->queryHTML('meta[property="og:image"]')->attr('content'));
69
        $this->assertEquals('DokuWiki',
70
                        $response->queryHTML('meta[property="og:title"]')->attr('content'));
71
        $this->assertEquals('article',
72
                        $response->queryHTML('meta[property="og:type"]')->attr('content'));
73
    }
74
}
75