|
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(): void { |
|
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(): void { |
|
38
|
|
|
$request = new TestRequest(); |
|
39
|
|
|
$params = array( |
|
40
|
|
|
'id' => 'wiki:dokuwiki' |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
$response = $request->get($params, '/doku.php'); |
|
44
|
|
|
|
|
45
|
|
|
print_r($response); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertTrue( |
|
48
|
|
|
strpos($response->getContent(), 'DokuWiki') !== false, |
|
49
|
|
|
'DokuWiki was not a word in the output' |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
// check twitter meta headers |
|
53
|
|
|
$this->assertEquals( |
|
54
|
|
|
'DokuWiki', |
|
55
|
|
|
$response->queryHTML('meta[name="twitter:title"]')->attr('content') |
|
56
|
|
|
); |
|
57
|
|
|
$this->assertEquals( |
|
58
|
|
|
'@twitterName', |
|
59
|
|
|
$response->queryHTML('meta[name="twitter:site"]')->attr('content') |
|
60
|
|
|
); |
|
61
|
|
|
$this->assertEquals( |
|
62
|
|
|
'summary', |
|
63
|
|
|
$response->queryHTML('meta[name="twitter:card"]')->attr('content') |
|
64
|
|
|
); |
|
65
|
|
|
$this->assertEquals( |
|
66
|
|
|
'@twitterUserName', |
|
67
|
|
|
$response->queryHTML('meta[name="twitter:creator"]')->attr('content') |
|
68
|
|
|
); |
|
69
|
|
|
$this->assertEquals( |
|
70
|
|
|
'http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
|
71
|
|
|
$response->queryHTML('meta[name="twitter:image"]')->attr('content') |
|
72
|
|
|
); |
|
73
|
|
|
$this->assertEquals( |
|
74
|
|
|
'', |
|
75
|
|
|
$response->queryHTML('meta[name="twitter:image:alt"]')->attr('content') |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
// check og meta headers |
|
79
|
|
|
$this->assertEquals( |
|
80
|
|
|
'My Test Wiki', |
|
81
|
|
|
$response->queryHTML('meta[property="og:site_name"]')->attr('content') |
|
82
|
|
|
); |
|
83
|
|
|
$this->assertEquals( |
|
84
|
|
|
'en_US', |
|
85
|
|
|
$response->queryHTML('meta[property="og:locale"]')->attr('content') |
|
86
|
|
|
); |
|
87
|
|
|
$this->assertEquals( |
|
88
|
|
|
'http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
|
89
|
|
|
$response->queryHTML('meta[property="og:image"]')->attr('content') |
|
90
|
|
|
); |
|
91
|
|
|
$this->assertEquals( |
|
92
|
|
|
'DokuWiki', |
|
93
|
|
|
$response->queryHTML('meta[property="og:title"]')->attr('content') |
|
94
|
|
|
); |
|
95
|
|
|
$this->assertEquals( |
|
96
|
|
|
'article', |
|
97
|
|
|
$response->queryHTML('meta[property="og:type"]')->attr('content') |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|