Skip to content

Commit

Permalink
Calling setLocation on a RepeaterBuilder should delegate to the Paren…
Browse files Browse the repository at this point in the history
…tContext

Close issue #1
  • Loading branch information
stevep committed May 16, 2016
1 parent 1c4e8fb commit f6994a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/RepeaterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public function endRepeater()
{
return $this->getParentContext();
}

public function setLocation($param, $operator, $value)
{
return $this->getParentContext()->setLocation($param, $operator, $value);
}
}
16 changes: 16 additions & 0 deletions tests/RepeaterBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,20 @@ public function testEndRepeater()
->endRepeater()
->addText('parent_title');
}

public function testSetLocation()
{
$fieldsBuilder = $this->getMockBuilder('StoutLogic\AcfBuilder\FieldsBuilder')
->setConstructorArgs(['parent'])
->getMock();

$repeaterBuilder = new RepeaterBuilder('slides');
$repeaterBuilder->setParentContext($fieldsBuilder);

$fieldsBuilder->expects($this->once())->method('setLocation');

$repeaterBuilder->addText('title')
->addWysiwyg('content')
->setLocation('post_type', '==', 'page');
}
}

0 comments on commit f6994a3

Please sign in to comment.