forked from ezsystems/ezpublish-kernel
/
EmbedLinkingTest.php
84 lines (69 loc) · 2.03 KB
/
EmbedLinkingTest.php
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
<?php
/**
* File containing the EmbedLinking converter test
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
*/
namespace eZ\Publish\Core\FieldType\Tests\XmlText\Converter;
use eZ\Publish\Core\FieldType\XmlText\Converter\EmbedLinking;
use PHPUnit_Framework_TestCase;
use DOMDocument;
/**
* Tests the EmbedLinking converter
*/
class EmbedLinkingTest extends PHPUnit_Framework_TestCase
{
/**
* Provider for conversion test.
*
* @return array
*/
public function providerForTestConvert()
{
$map = array();
foreach ( glob( __DIR__ . "/_fixtures/embed_linking/input/*.xml" ) as $inputFilePath )
{
$basename = basename( $inputFilePath, ".xml" );
$outputFilePath = __DIR__ . "/_fixtures/embed_linking/output/{$basename}.xml";
$map[] = array( $inputFilePath, $outputFilePath );
}
return $map;
}
/**
* @param string $xml
* @param boolean $isPath
*
* @return \DOMDocument
*/
protected function createDocument( $xml, $isPath = true )
{
$document = new DOMDocument();
$document->preserveWhiteSpace = false;
$document->formatOutput = false;
if ( $isPath === true )
{
$xml = file_get_contents( $xml );
}
$document->loadXml( $xml );
return $document;
}
/**
* @param string $inputFilePath
* @param string $outputFilePath
*
* @dataProvider providerForTestConvert
*/
public function testConvert( $inputFilePath, $outputFilePath )
{
$inputDocument = $this->createDocument( $inputFilePath );
$converter = new EmbedLinking();
$converter->convert( $inputDocument );
$outputDocument = $this->createDocument( $outputFilePath );
$this->assertEquals(
$outputDocument,
$inputDocument
);
}
}