-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertFullUrlTest.php
More file actions
116 lines (103 loc) · 2.58 KB
/
ConvertFullUrlTest.php
File metadata and controls
116 lines (103 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* SnsButtonHelper::twitter()のテスト
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
/**
* require
*/
require_once CakePlugin::path('Tinydb') . 'Lib/TinydbFunctions.php';
App::uses('NetCommonsHelperTestCase', 'NetCommons.TestSuite');
/**
* SnsButtonHelper::twitter()のテスト
*
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @package NetCommons\NetCommons\Test\Case\View\Helper\SnsButtonHelper
*/
class TinydbOgpConvertFullUrlTest extends NetCommonsHelperTestCase {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array();
/**
* Plugin name
*
* @var string
*/
public $plugin = 'tinydb';
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
//テストデータ生成
$viewVars = array();
$requestData = array();
$params = array(
'plugin' => 'tinydb',
'controller' => 'tinydb_items',
'action' => 'view',
'key' => 'item_1'
);
//Helperロード
$this->loadHelper('Tinydb.TinydbOgp', $viewVars, $requestData, $params);
$stub = $this->getMockBuilder('NetCommonsHtml')
->setMethods(['url'])
->getMock();
$map = [
['/tinydb/tinydb_items/view/item_1'],
//[null, [], FULL_BASE_URL . '/tinydb/tinydb_items/view/item_1'],
['/tinydb/tinydb_items/view/../foo/bar.jpg', true, FULL_BASE_URL . '/tinydb/tinydb_items/view/../foo/bar.jpg']
];
$stub->method('url')
->will($this->returnValueMap($map));
$this->TinydbOgp->NetCommonsHtml = $stub;
}
/**
* Tset TinydbOgp::__convertFullUrl()
*
* @param string $imageUrl image url
* @param string $fullUrl フルURLの期待値
* @throws ReflectionException
* @return void
* @dataProvider data4ConvertFullUrl
*/
public function testConvertFullUrl($imageUrl, $fullUrl) {
$method = new ReflectionMethod($this->TinydbOgp, '__convertFullUrl');
$method->setAccessible(true);
$result = $method->invoke($this->TinydbOgp, $imageUrl);
//debug($result);
$this->assertEquals($fullUrl, $result);
}
/**
* testConvertFullUrl test case
*
* @return array
*/
public function data4ConvertFullUrl() {
$data = [
[
'imageUrl' => 'http://example.com/foo.jpg',
'fullUrl' => 'http://example.com/foo.jpg'
],
[
'imageUrl' => '/foo/bar.jpg',
'fullUrl' => FULL_BASE_URL . '/foo/bar.jpg'
],
[
'imageUrl' => '../foo/bar.jpg',
'fullUrl' => FULL_BASE_URL . '/tinydb/tinydb_items/view/../foo/bar.jpg'
],
];
return $data;
}
}