Skip to content

Commit

Permalink
Merge pull request #341 from ezsystems/fix-EZP-20799-ezpage-unexisten…
Browse files Browse the repository at this point in the history
…t-method

Fix EZP-20799 Page field type calls non existent method on PageService
  • Loading branch information
pspanja committed May 2, 2013
2 parents 74d015e + 8c46331 commit e1ed229
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 3 deletions.
4 changes: 2 additions & 2 deletions eZ/Publish/Core/FieldType/Page/Type.php
Expand Up @@ -68,10 +68,10 @@ public function validateFieldSettings( $fieldSettings )
switch ( $name )
{
case 'defaultLayout':
if ( !in_array( $value, $this->pageService->getAvailableZoneTypes() ) )
if ( !in_array( $value, $this->pageService->getAvailableZoneLayouts() ) )
{
$validationErrors[] = new ValidationError(
"Setting '%setting%' is of unknown type",
"Layout '{$value}' for setting '%setting%' is not available",
null,
array(
'setting' => $name
Expand Down
82 changes: 81 additions & 1 deletion eZ/Publish/Core/FieldType/Tests/PageTest.php
Expand Up @@ -23,7 +23,7 @@ class PageTest extends FieldTypeTest
* Page service mock.
*
* @see getPageServiceMock()
* @var \eZ\Publish\Core\FieldType\Page\PageService
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $pageServiceMock;

Expand All @@ -35,6 +35,9 @@ private function getPageServiceMock()
->getMockBuilder( 'eZ\\Publish\\Core\\FieldType\\Page\\PageService' )
->disableOriginalConstructor()
->getMock();
$this->pageServiceMock->expects( $this->any() )
->method( "getAvailableZoneLayouts" )
->will( $this->returnValue( array( "2ZonesLayout1", "2ZonesLayout2" ) ) );
}
return $this->pageServiceMock;
}
Expand Down Expand Up @@ -269,4 +272,81 @@ public function provideInputForFromHash()
)
);
}

/**
* Provide data sets with field settings which are considered valid by the
* {@link validateFieldSettings()} method.
*
* ATTENTION: This is a default implementation, which must be overwritten
* if a FieldType supports field settings!
*
* Returns an array of data provider sets with a single argument: A valid
* set of field settings.
* For example:
*
* <code>
* return array(
* array(
* array(),
* ),
* array(
* array( 'rows' => 2 )
* ),
* // ...
* );
* </code>
*
* @return array
*/
public function provideValidFieldSettings()
{
return array(
array(
array()
),
array(
array( "defaultLayout" => "2ZonesLayout1" )
),
);
}

/**
* Provide data sets with field settings which are considered invalid by the
* {@link validateFieldSettings()} method. The method must return a
* non-empty array of validation error when receiving such field settings.
*
* ATTENTION: This is a default implementation, which must be overwritten
* if a FieldType supports field settings!
*
* Returns an array of data provider sets with a single argument: A valid
* set of field settings.
* For example:
*
* <code>
* return array(
* array(
* true,
* ),
* array(
* array( 'nonExistentKey' => 2 )
* ),
* // ...
* );
* </code>
*
* @return array
*/
public function provideInValidFieldSettings()
{
return array(
array(
// non-existent setting
array( 'isMultiple' => true )
),
array(
// non-available layout
array( "defaultLayout" => "2ZonesLayout3" )
),
);
}
}

0 comments on commit e1ed229

Please sign in to comment.