Skip to content

Commit

Permalink
[TASK] Move inline comments to method and update.
Browse files Browse the repository at this point in the history
  • Loading branch information
rozbehsharahitxb committed Jan 21, 2019
1 parent d5b46c7 commit c456005
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@
class LogicalAndTest extends BaseTest
{
/**
* Test parsing.
* Logical parsing of AND statement.
*
* Notice regarding multiple criteria of same type:
*
* The XML decoder of EZ is not creating numeric arrays, instead using the tag as the array key. See
* variable $logicalAndParsedFromXml. This causes the ContentTypeIdentifierCriterion-Tag to appear as one-element
* (type numeric array) and two criteria configuration inside. The logical or parser will take care
* of this and return a flatt LogicalAnd criterion with 3 criteria inside.
*
* ```
* <AND>
* <ContentTypeIdentifierCriterion>author</ContentTypeIdentifierCriterion>
* <ContentTypeIdentifierCriterion>book</ContentTypeIdentifierCriterion>
* <Field>
* <name>title</name>
* <operator>EQ</operator>
* <value>Contributing to projects</value>
* </Field>
* </AND>
* ```
*/
public function testParseLogicalAnd()
{
// This is what xml parser is right now creating out of
// <AND>
// <ContentTypeIdentifierCriterion>author</ContentTypeIdentifierCriterion>
// <ContentTypeIdentifierCriterion>book</ContentTypeIdentifierCriterion>
// <Field>
// <name>title</name>
// <operator>EQ</operator>
// <value>Contributing to projects</value>
// </Field>
// </AND>
$logicalAndParsedFromXml = [
'AND' => [
'ContentTypeIdentifierCriterion' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,35 @@
class LogicalOrTest extends BaseTest
{
/**
* Test parsing.
* Test parsing of OR statement.
*
* Notice regarding multiple criteria of same type:
*
* The XML decoder of EZ is not creating numeric arrays, instead using the tag as the array key. See
* variable $logicalOrParsedFromXml. This causes the Field Tag to appear as one-element
* (type numeric array) and two criteria configuration inside. The logical or parser will take care
* of this and return a flatt LogicalOr criterion with 4 criteria inside.
*
* ```
* <OR>
* <ContentTypeIdentifierCriterion>author</ContentTypeIdentifierCriterion>
* <ContentTypeIdentifierCriterion>book</ContentTypeIdentifierCriterion>
* <Field>
* <name>title</name>
* <operator>EQ</operator>
* <value>Contributing to projects</value>
* </Field>
* <Field>
* <name>title</name>
* <operator>EQ</operator>
* <value>Contributing to projects</value>
* </Field>
* </OR>
* ```
*/
public function testParseLogicalOr()
{
// This is what xml parser is right now creating out of
// <OR>
// <ContentTypeIdentifierCriterion>author</ContentTypeIdentifierCriterion>
// <ContentTypeIdentifierCriterion>book</ContentTypeIdentifierCriterion>
// <Field>
// <name>title</name>
// <operator>EQ</operator>
// <value>Contributing to projects</value>
// </Field>
// <Field>
// <name>title</name>
// <operator>EQ</operator>
// <value>Contributing to projects</value>
// </Field>
// </OR>
$logicalAndParsedFromXml = [
$logicalOrParsedFromXml = [
'OR' => [
'ContentTypeIdentifierCriterion' => [
0 => 'author',
Expand All @@ -61,7 +70,7 @@ public function testParseLogicalOr()
$parserMock = $this->createMock(\eZ\Publish\Core\REST\Common\Input\Parser::class);
$parserMock->method('parse')->willReturn($criterionMock);

$result = $this->internalGetParser()->parse($logicalAndParsedFromXml, new ParsingDispatcher([
$result = $this->internalGetParser()->parse($logicalOrParsedFromXml, new ParsingDispatcher([
'application/vnd.ez.api.internal.criterion.ContentTypeIdentifier' => $parserMock,
'application/vnd.ez.api.internal.criterion.Field' => $parserMock,
]));
Expand Down

0 comments on commit c456005

Please sign in to comment.