1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) Andreas Heigl<[email protected]> |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
13
|
|
|
* all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21
|
|
|
* THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
* @author Andreas Heigl<[email protected]> |
24
|
|
|
* @copyright Andreas Heigl |
25
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT-License |
26
|
|
|
* @since 20.02.2017 |
27
|
|
|
* @link http://github.com/heiglandreas/org.heigl.Mailproxy |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
namespace Org_Heigl\MailproxyTest\View\Helper; |
31
|
|
|
|
32
|
|
|
use Mockery as M; |
33
|
|
|
use Org_Heigl\Mailproxy\View\Helper\Mailto; |
34
|
|
|
use PHPUnit\Framework\TestCase; |
35
|
|
|
use Zend\View\Helper\EscapeHtml; |
36
|
|
|
use Zend\View\Helper\EscapeHtmlAttr; |
37
|
|
|
use Zend\View\Helper\HeadStyle; |
38
|
|
|
use Zend\View\Renderer\RendererInterface; |
39
|
|
|
|
40
|
|
|
class MailtoTest extends TestCase |
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* @param $address |
44
|
|
|
* @param $expected |
45
|
|
|
* @dataProvider invocationWorksAsExpectedProvider |
46
|
|
|
* @covers \Org_Heigl\Mailproxy\View\Helper\Mailto |
47
|
|
|
*/ |
48
|
|
|
public function testThatInvocationWorksAsExpected($address, $expected, $name = null, $params = []) |
49
|
|
|
{ |
50
|
|
|
$style = M::mock(HeadStyle::class); |
51
|
|
|
$style->shouldReceive('appendStyle')->with('.orgHeiglMailProxy{ |
52
|
|
|
direction: rtl; |
53
|
|
|
unicode-bidi: bidi-override; |
54
|
|
|
|
55
|
|
|
}'); |
56
|
|
|
|
57
|
|
|
$view = M::mock(RendererInterface::class); |
58
|
|
|
$view->shouldReceive('url')->andReturn('mailproxy/' . strrev($address)); |
59
|
|
|
$view->shouldReceive('headStyle')->andReturn($style); |
60
|
|
|
$view->shouldReceive('plugin')->with('escapehtml')->andReturn(new EscapeHtml()); |
61
|
|
|
$view->shouldReceive('plugin')->with('escapehtmlattr')->andReturn(new EscapeHtmlAttr()); |
62
|
|
|
|
63
|
|
|
$helper = new Mailto(); |
64
|
|
|
$helper->setView($view); |
65
|
|
|
|
66
|
|
|
$this->assertEquals($expected, $helper($address, $name, $params)); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function invocationWorksAsExpectedProvider() |
70
|
|
|
{ |
71
|
|
|
return [ |
72
|
|
|
[ |
73
|
|
|
'[email protected]', |
74
|
|
|
'<a href="mailproxy/moc.elpmaxe@ofni" class="orgHeiglMailProxy">moc.elpmaxe@ofni</a>', |
75
|
|
|
], |
76
|
|
|
[ |
77
|
|
|
'[email protected]', |
78
|
|
|
'<a href="mailproxy/moc.elpmaxe@ofni">title</a>', |
79
|
|
|
'title', |
80
|
|
|
], |
81
|
|
|
[ |
82
|
|
|
'[email protected]', |
83
|
|
|
'<a href="mailproxy/moc.elpmaxe@ofni" class="class" title="this is a title">title</a>', |
84
|
|
|
'title', |
85
|
|
|
[ |
86
|
|
|
'class' => 'class', |
87
|
|
|
'title' => 'this is a title' |
88
|
|
|
] |
89
|
|
|
], |
90
|
|
|
[ |
91
|
|
|
'[email protected]', |
92
|
|
|
'<a href="mailproxy/moc.elpmaxe@ofni" class="class orgHeiglMailProxy" title="this is a title">moc.elpmaxe@ofni</a>', |
93
|
|
|
null, |
94
|
|
|
[ |
95
|
|
|
'class' => 'class', |
96
|
|
|
'title' => 'this is a title' |
97
|
|
|
] |
98
|
|
|
], |
99
|
|
|
]; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|