1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the ISBNTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Tests\Content\FieldValue\Converter; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\Core\FieldType\FieldSettings; |
12
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter; |
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition; |
14
|
|
|
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition as PersistenceFieldDefinition; |
15
|
|
|
use PHPUnit_Framework_TestCase; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Test for ISBNConverter in Legacy Storage. |
19
|
|
|
*/ |
20
|
|
|
class ISBNTest extends PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter |
24
|
|
|
*/ |
25
|
|
|
protected $converter; |
26
|
|
|
|
27
|
|
|
protected function setUp() |
28
|
|
|
{ |
29
|
|
|
$this->converter = new ISBNConverter(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @dataProvider providerForTestToFieldDefinition |
34
|
|
|
* |
35
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter::toFieldDefinition |
36
|
|
|
*/ |
37
|
|
|
public function testToFieldDefinition($dataInt, $excpectedIsbn13Value) |
38
|
|
|
{ |
39
|
|
|
$fieldDef = new PersistenceFieldDefinition(); |
40
|
|
|
$storageDefinition = new StorageFieldDefinition([ |
41
|
|
|
'dataInt1' => $dataInt, |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
$this->converter->toFieldDefinition($storageDefinition, $fieldDef); |
45
|
|
|
|
46
|
|
|
/** @var FieldSettings $fieldSettings */ |
47
|
|
|
$fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings; |
48
|
|
|
self::assertSame($excpectedIsbn13Value, $fieldSettings['isISBN13']); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
View Code Duplication |
public function providerForTestToFieldDefinition() |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
[1, true], |
55
|
|
|
[0, false], |
56
|
|
|
[null, false], |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|