Skip to content
Permalink
Browse files

Merge pull request #1242 from ezsystems/impl-EZP-24232-indexable-media

Implement EZP-24276: Indexable Media field type
  • Loading branch information...
pspanja committed May 1, 2015
2 parents 510676e + fb4082e commit 659b3e17b7714cbce31638e6f112f7f336ef80cd
@@ -610,8 +610,8 @@ protected function getValidSearchValueOne()
{
return new ImageValue(
array(
'fileName' => 'cafe-terrace-at-night.png',
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.png' ),
'fileName' => 'cafe-terrace-at-night.jpg',
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.jpg' ),
'alternativeText' => 'café terrace at night, also known as the cafe terrace on the place du forum',
'fileSize' => filesize( $path ),
)
@@ -622,8 +622,8 @@ protected function getValidSearchValueTwo()
{
return new ImageValue(
array(
'fileName' => 'thatched-cottages-at-cordeville.jpg',
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.jpg' ),
'fileName' => 'thatched-cottages-at-cordeville.png',
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.png' ),
'alternativeText' => 'chaumes de cordeville à auvers-sur-oise',
'fileSize' => filesize( $path ),
)
@@ -779,6 +779,67 @@ public function testQueryContentModifiedFieldFileSize(
);
}
public function criteriaProviderModifiedFieldMimeType()
{
return $this->provideCriteria( "image/jpeg", "image/png" );
}
/**
* Tests Content Search filtering with Field criterion on the MIME type modified field
*
* @dataProvider criteriaProviderModifiedFieldMimeType
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testFilterContentModifiedFieldMimeType(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
true,
"mime_type"
);
}
/**
* Tests Content Search querying with Field criterion on the MIME type modified field
*
* @dataProvider criteriaProviderModifiedFieldMimeType
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testQueryContentModifiedFieldMimeType(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
false,
"mime_type"
);
}
/**
* Tests Content Search sort with Field sort clause on the alternative text modified field
*
@@ -826,4 +887,28 @@ public function testSortContentModifiedFieldFieldSize(
"file_size"
);
}
/**
* Tests Content Search sort with Field sort clause on the MIME type modified field
*
* @dataProvider sortClauseProvider
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause
* @param boolean $ascending
* @param array $context
*/
public function testSortContentModifiedFieldMimeType(
SortClause $sortClause,
$ascending,
array $context
)
{
$this->assertSortContentModifiedField(
$sortClause,
$ascending,
$context,
"mime_type"
);
}
}
@@ -12,14 +12,16 @@
use eZ\Publish\Core\FieldType\Media\Value as MediaValue;
use eZ\Publish\Core\FieldType\Media\Type as MediaType;
use eZ\Publish\API\Repository\Values\Content\Field;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
/**
* Integration test for use field type
*
* @group integration
* @group field-type
*/
class MediaIntegrationTest extends FileBaseIntegrationTest
class MediaIntegrationTest extends FileSearchBaseIntegrationTest
{
/**
* Stores the loaded image path for copy test.
@@ -424,4 +426,220 @@ public function providerForTestIsNotEmptyValue()
),
);
}
protected function getValidSearchValueOne()
{
return new MediaValue(
array(
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.jpg' ),
'fileName' => 'blue-blue-blue-sindelfingen.jpg',
'fileSize' => filesize( $path ),
)
);
}
protected function getValidSearchValueTwo()
{
return new MediaValue(
array(
'inputUri' => ( $path = __DIR__ . '/_fixtures/image.png' ),
'fileName' => 'icy-night-flower-binary.png',
'fileSize' => filesize( $path ),
)
);
}
protected function getSearchTargetValueOne()
{
$value = $this->getValidSearchValueOne();
return $value->fileName;
}
protected function getSearchTargetValueTwo()
{
$value = $this->getValidSearchValueTwo();
return $value->fileName;
}
/**
* Redefined here in order to execute before tests with modified fields below,
* which depend on it for the returned value.
*/
public function testCreateTestContent()
{
return parent::testCreateTestContent();
}
public function criteriaProviderModifiedFieldMimeType()
{
return $this->provideCriteria( "image/jpeg", "image/png" );
}
/**
* Tests Content Search filtering with Field criterion on the MIME type modified field
*
* @dataProvider criteriaProviderModifiedFieldMimeType
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testFilterContentModifiedFieldMimeType(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
true,
"mime_type"
);
}
/**
* Tests Content Search querying with Field criterion on the MIME type modified field
*
* @dataProvider criteriaProviderModifiedFieldMimeType
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testQueryContentModifiedFieldMimeType(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
false,
"mime_type"
);
}
public function criteriaProviderModifiedFieldFileSize()
{
$valueOne = $this->getValidSearchValueOne();
$valueTwo = $this->getValidSearchValueTwo();
return $this->provideCriteria( $valueOne->fileSize, $valueTwo->fileSize );
}
/**
* Tests Content Search filtering with Field criterion on the file size modified field
*
* @dataProvider criteriaProviderModifiedFieldFileSize
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testFilterContentModifiedFieldFileSize(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
true,
"file_size"
);
}
/**
* Tests Content Search querying with Field criterion on the file size modified field
*
* @dataProvider criteriaProviderModifiedFieldFileSize
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param boolean $includesOne
* @param boolean $includesTwo
* @param array $context
*/
public function testQueryContentModifiedFieldFileSize(
Criterion $criterion,
$includesOne,
$includesTwo,
array $context
)
{
$this->assertFilterContentModifiedField(
$criterion,
$includesOne,
$includesTwo,
$context,
false,
"file_size"
);
}
/**
* Tests Content Search sort with Field sort clause on the MIME type modified field
*
* @dataProvider sortClauseProvider
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause
* @param boolean $ascending
* @param array $context
*/
public function testSortContentModifiedFieldMimeType(
SortClause $sortClause,
$ascending,
array $context
)
{
$this->assertSortContentModifiedField(
$sortClause,
$ascending,
$context,
"mime_type"
);
}
/**
* Tests Content Search sort with Field sort clause on the file size modified field
*
* @dataProvider sortClauseProvider
* @depends testCreateTestContent
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause
* @param boolean $ascending
* @param array $context
*/
public function testSortContentModifiedFieldFieldSize(
SortClause $sortClause,
$ascending,
array $context
)
{
$this->assertSortContentModifiedField(
$sortClause,
$ascending,
$context,
"file_size"
);
}
}
Binary file not shown.
@@ -43,6 +43,11 @@ public function getIndexData( Field $field )
$field->value->data["fileSize"],
new Search\FieldType\IntegerField()
),
new Search\Field(
'mime_type',
$field->value->data["mime"],
new Search\FieldType\StringField()
),
);
}
@@ -57,6 +62,7 @@ public function getIndexDefinition()
"filename" => new Search\FieldType\StringField(),
"alternative_text" => new Search\FieldType\StringField(),
"file_size" => new Search\FieldType\IntegerField(),
'mime_type' => new Search\FieldType\StringField(),
);
}
Oops, something went wrong.

0 comments on commit 659b3e1

Please sign in to comment.
You can’t perform that action at this time.