Skip to content

Commit

Permalink
Merge branch '6.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed May 19, 2017
2 parents af585bc + b7fc361 commit 552f9c9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Expand Up @@ -82,7 +82,7 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin
{
$fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
array(
'isISBN13' => !empty($storageDef->dataInt1) ? (bool)$storageDef->dataInt1 : true,
'isISBN13' => !empty($storageDef->dataInt1) ? (bool)$storageDef->dataInt1 : false,
)
);

Expand Down
@@ -0,0 +1,59 @@
<?php

/**
* File containing the ISBNTest class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\Persistence\Legacy\Tests\Content\FieldValue\Converter;

use eZ\Publish\Core\FieldType\FieldSettings;
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter;
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition;
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition as PersistenceFieldDefinition;
use PHPUnit_Framework_TestCase;

/**
* Test for ISBNConverter in Legacy Storage.
*/
class ISBNTest extends PHPUnit_Framework_TestCase
{
/**
* @var \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter
*/
protected $converter;

protected function setUp()
{
$this->converter = new ISBNConverter();
}

/**
* @dataProvider providerForTestToFieldDefinition
*
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ISBNConverter::toFieldDefinition
*/
public function testToFieldDefinition($dataInt, $excpectedIsbn13Value)
{
$fieldDef = new PersistenceFieldDefinition();
$storageDefinition = new StorageFieldDefinition([
'dataInt1' => $dataInt,
]);

$this->converter->toFieldDefinition($storageDefinition, $fieldDef);

/** @var FieldSettings $fieldSettings */
$fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings;
self::assertSame($excpectedIsbn13Value, $fieldSettings['isISBN13']);
}

public function providerForTestToFieldDefinition()
{
return [
[1, true],
[0, false],
[null, false],
];
}
}

0 comments on commit 552f9c9

Please sign in to comment.