Skip to content

Commit

Permalink
feat(ACFComposer): add basic registerFieldGroup method
Browse files Browse the repository at this point in the history
  • Loading branch information
domtra committed Nov 8, 2016
1 parent 66d7596 commit 53e147e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/ACFComposer/ACFComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
namespace ACFComposer;

class ACFComposer {

public static function registerFieldGroup($config) {
$fieldGroup = ResolveConfig::forFieldGroup($config);
return acf_add_local_field_group($fieldGroup);
}
}
22 changes: 20 additions & 2 deletions tests/test-acfComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,27 @@

use ACFComposer\TestCase;
use ACFComposer\ACFComposer;
use Brain\Monkey\Functions;

class ACFComposerTest extends TestCase {
function testSimple() {
$this->assertTrue(true);
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
function testRegisterFieldGroup() {
$config = 'this is a config';
$fieldGroup = 'this is a field group';
$returnValue = 'this is a return value';
Mockery::mock('alias:ACFComposer\ResolveConfig')
->shouldReceive('forFieldGroup')
->with($config)
->once()
->andReturn($fieldGroup);
Functions::expect('acf_add_local_field_group')
->with($fieldGroup)
->once()
->andReturn($returnValue);
$output = ACFComposer::registerFieldGroup($config);
$this->assertEquals($returnValue, $output);
}
}

0 comments on commit 53e147e

Please sign in to comment.