|
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
|
|
|
function setUp(){ |
|
|
|
|
|
|
29
|
|
|
global $conf; |
|
30
|
|
|
|
|
31
|
|
|
parent::setUp(); |
|
32
|
|
|
|
|
33
|
|
|
$conf ['plugin']['socialcards']['twitterName'] = '@twitterName'; |
|
34
|
|
|
$conf ['plugin']['socialcards']['twitterUserName'] = '@twitterUserName'; |
|
35
|
|
|
// $conf ['plugin']['socialcards']['fallbackImage'] = 'wiki:dokuwiki-128.png'; |
|
|
|
|
|
|
36
|
|
|
// $conf ['plugin']['socialcards']['languageTerritory'] = 'en_US'; |
|
|
|
|
|
|
37
|
|
|
// $conf ['plugin']['socialcards']['fbAppId'] = ''; |
|
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testHeaders() { |
|
41
|
|
|
$request = new TestRequest(); |
|
42
|
|
|
$response = $request->get(array('id'=>'wiki:dokuwiki'), '/doku.php'); |
|
43
|
|
|
|
|
44
|
|
|
print_r($response); |
|
45
|
|
|
|
|
46
|
|
|
$this->assertTrue( |
|
47
|
|
|
strpos($response->getContent(), 'DokuWiki') !== false, |
|
48
|
|
|
'DokuWiki was not a word in the output' |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
// check twitter meta headers |
|
52
|
|
|
$this->assertEquals('DokuWiki', |
|
53
|
|
|
$response->queryHTML('meta[name="twitter:title"]')->attr('content')); |
|
54
|
|
|
$this->assertEquals('@twitterName', |
|
55
|
|
|
$response->queryHTML('meta[name="twitter:site"]')->attr('content')); |
|
56
|
|
|
$this->assertEquals('summary', |
|
57
|
|
|
$response->queryHTML('meta[name="twitter:card"]')->attr('content')); |
|
58
|
|
|
$this->assertEquals('@twitterUserName', |
|
59
|
|
|
$response->queryHTML('meta[name="twitter:creator"]')->attr('content')); |
|
60
|
|
|
$this->assertEquals('http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
|
61
|
|
|
$response->queryHTML('meta[name="twitter:image"]')->attr('content')); |
|
62
|
|
|
$this->assertEquals('', |
|
63
|
|
|
$response->queryHTML('meta[name="twitter:image:alt"]')->attr('content')); |
|
64
|
|
|
|
|
65
|
|
|
// check og meta headers |
|
66
|
|
|
$this->assertEquals('My Test Wiki', |
|
67
|
|
|
$response->queryHTML('meta[property="og:site_name"]')->attr('content')); |
|
68
|
|
|
$this->assertEquals('en_US', |
|
69
|
|
|
$response->queryHTML('meta[property="og:locale"]')->attr('content')); |
|
70
|
|
|
$this->assertEquals('http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
|
71
|
|
|
$response->queryHTML('meta[property="og:image"]')->attr('content')); |
|
72
|
|
|
$this->assertEquals('DokuWiki', |
|
73
|
|
|
$response->queryHTML('meta[property="og:title"]')->attr('content')); |
|
74
|
|
|
$this->assertEquals('article', |
|
75
|
|
|
$response->queryHTML('meta[property="og:type"]')->attr('content')); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.