Skip to content

#20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr… #20923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,62 @@ public function prototype($type)
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
}

/**
* @return VariableNodeDefinition
*/
public function variablePrototype()
{
return $this->prototype('variable');
}

/**
* @return ScalarNodeDefinition
*/
public function scalarPrototype()
{
return $this->prototype('scalar');
}

/**
* @return BooleanNodeDefinition
*/
public function booleanPrototype()
{
return $this->prototype('boolean');
}

/**
* @return IntegerNodeDefinition
*/
public function integerPrototype()
{
return $this->prototype('integer');
}

/**
* @return FloatNodeDefinition
*/
public function floatPrototype()
{
return $this->prototype('float');
}

/**
* @return ArrayNodeDefinition
*/
public function arrayPrototype()
{
return $this->prototype('array');
}

/**
* @return EnumNodeDefinition
*/
public function enumPrototype()
{
return $this->prototype('enum');
}

/**
* Adds the default value if the node is not set in the configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,48 @@ public function testNormalizeKeys()
$this->assertFalse($this->getField($node, 'normalizeKeys'));
}

public function testPrototypeVariable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a single test?

{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('variable'), $node->variablePrototype());
}

public function testPrototypeScalar()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('scalar'), $node->scalarPrototype());
}

public function testPrototypeBoolean()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('boolean'), $node->booleanPrototype());
}

public function testPrototypeInteger()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('integer'), $node->integerPrototype());
}

public function testPrototypeFloat()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('float'), $node->floatPrototype());
}

public function testPrototypeArray()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('array'), $node->arrayPrototype());
}

public function testPrototypeEnum()
{
$node = new ArrayNodeDefinition('root');
$this->assertEquals($node->prototype('enum'), $node->enumPrototype());
}

public function getEnableableNodeFixtures()
{
return array(
Expand Down