|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
4
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\Matcher\Tests; |
|
7
|
|
|
|
|
8
|
|
|
use eZ\Publish\Core\MVC\Symfony\Matcher\IsEmbedImage; |
|
9
|
|
|
use eZ\Publish\Core\MVC\Symfony\View\ContentView; |
|
10
|
|
|
use PHPUnit_Framework_TestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @covers \eZ\Publish\Core\MVC\Symfony\Matcher\IsEmbedImage |
|
14
|
|
|
*/ |
|
15
|
|
|
class IsEmbedImageTest extends PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @expectedException \InvalidArgumentException |
|
19
|
|
|
* @expectedExceptionMessage The IsEmbedImage matcher expects a boolean value |
|
20
|
|
|
*/ |
|
21
|
|
|
public function testSetMatchingConfigException() |
|
22
|
|
|
{ |
|
23
|
|
|
$matcher = new IsEmbedImage(); |
|
24
|
|
|
$matcher->setMatchingConfig('some value'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @dataProvider viewParametersProvider |
|
29
|
|
|
* @param array $objectParameters |
|
30
|
|
|
* @param bool $expectedResult |
|
31
|
|
|
*/ |
|
32
|
|
|
public function testMatch($objectParameters, $expectedResult) |
|
33
|
|
|
{ |
|
34
|
|
|
$matcher = new IsEmbedImage(); |
|
35
|
|
|
$matcher->setMatchingConfig(true); |
|
36
|
|
|
$view = new ContentView(null, $objectParameters); |
|
37
|
|
|
|
|
38
|
|
|
self::assertEquals($expectedResult, $matcher->match($view)); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function viewParametersProvider() |
|
42
|
|
|
{ |
|
43
|
|
|
return [ |
|
44
|
|
|
'no_objectParameters_parameter' => [[], false], |
|
45
|
|
|
'no_isImage_key' => [['objectParameters' => []], false], |
|
46
|
|
|
'is_embed_image' => [['objectParameters' => ['isImage' => true]], true], |
|
47
|
|
|
]; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|