Ejemplo n.º 1
0
 public function testBuild()
 {
     $this->if($object = new TestedClass())->and($builder = new \mock\Symfony\Component\Config\Definition\Builder\NodeBuilder())->and($root = new \mock\Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition(uniqid()))->and($node = new \mock\Symfony\Component\Config\Definition\Builder\NodeDefinition(uniqid()))->and($builder->getMockController()->scalarNode = function () use($node) {
         return $node;
     })->and($builder->getMockController()->arrayNode = function () use($root) {
         return $root;
     })->and($root->getMockController()->children = function () use($builder) {
         return $builder;
     })->and($root->getMockController()->end = function () use($builder) {
         return $builder;
     })->and($node->getMockController()->end = function () use($builder) {
         return $builder;
     })->and($node->getMockController()->isRequired = function () use($node) {
         return $node;
     })->then->variable($object->build($root))->isNull()->mock($root)->call('children')->once();
 }
Ejemplo n.º 2
0
 public function testValidate()
 {
     $this->if($object = new \mock\jubianchi\Config\Validator())->and($object->getMockController()->getBuilder = $builder = new \mock\Symfony\Component\Config\Definition\Builder\TreeBuilder())->and($finder = new \mock\jubianchi\Config\TypeFinder())->and($finder->getMockController()->getValidTypes = array('tests\\unit\\jubianchi\\Config\\FooType' => 'foo', 'tests\\unit\\jubianchi\\Config\\BarType' => 'bar'))->then->variable($object->validate(array(), $finder))->isNull()->mock($object)->call('process')->withArguments(array(), $builder)->once()->if($object->getMockController()->getPrototype = $prototype = new \mock\Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition(uniqid()))->and($finder->getMockController()->getValidFields = array('foo', 'bar'))->and($prototype->getMockController()->append = function () use($prototype) {
         return $prototype;
     })->then->variable($object->validate(array(), $finder))->isNull()->mock($prototype)->call('append')->withArguments(new \Symfony\Component\Config\Definition\Builder\VariableNodeDefinition('foo'))->once()->call('append')->withArguments(new \Symfony\Component\Config\Definition\Builder\VariableNodeDefinition('bar'))->once()->if($finder->getMockController()->getValidTypes = array())->then->exception(function () use($object, $finder) {
         $object->validate(array(), $finder);
     })->isInstanceOf('\\RuntimeException')->hasMessage('No valid types found');
 }