public function testValidationMultiDimensionalNotValid()
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->setChildren([new WhiteBlock([new Paragraph()]), new WhiteBlock([new WhiteBlock(), new WhiteBlock([new WhiteBlock([])])]), new WhiteBlock([new NormalText()]), new WhiteBlock([])]);
     $validator = new Validator([new Validator\Rule\CantBeEmpty(), new Validator\Rule\CheckAllowedChildren()]);
     $this->assertTrue($validator->validate($emailTemplate)->hasErrors());
     $this->assertEquals("0[whiteBlock]0[paragraph] Element property 'children[]' can't be empty\n" . "1[whiteBlock] Element 'whiteBlock' can't have [whiteBlock, whiteBlock] as child. Only [paragraph, header, readOnly] allowed.\n" . "1[whiteBlock]0[whiteBlock] Element property 'children[]' can't be empty\n" . "1[whiteBlock]1[whiteBlock] Element 'whiteBlock' can't have [whiteBlock] as child. Only [paragraph, header, readOnly] allowed.\n" . "1[whiteBlock]1[whiteBlock]0[whiteBlock] Element property 'children[]' can't be empty\n" . "2[whiteBlock] Element 'whiteBlock' can't have [normalText] as child. Only [paragraph, header, readOnly] allowed.\n" . "2[whiteBlock]0[normalText] Element property 'content' can't be empty\n" . "3[whiteBlock] Element property 'children[]' can't be empty", $validator->validate($emailTemplate)->dump());
 }
 public function testValidationNotValid()
 {
     $child1 = m::mock('TPN\\EmailTemplatesComponent\\Element\\AbstractElement');
     $child1->shouldReceive('isLeaf')->once()->andReturn(true);
     $child1->shouldReceive('getName')->once()->andReturn('child1');
     $child2 = m::mock('TPN\\EmailTemplatesComponent\\Element\\AbstractElement');
     $child2->shouldReceive('isLeaf')->once()->andReturn(true);
     $child2->shouldReceive('getName')->once()->andReturn('child2');
     $child3 = m::mock('TPN\\EmailTemplatesComponent\\Element\\AbstractElement');
     $child3->shouldReceive('isLeaf')->once()->andReturn(true);
     $child3->shouldReceive('getName')->once()->andReturn('child3');
     $children = [$child1, $child2, $child3];
     $emailTemplate = m::mock('TPN\\EmailTemplatesComponent\\Model\\EmailTemplate');
     $emailTemplate->shouldReceive('getChildren')->once()->andReturn($children);
     $ruleMock = m::mock('TPN\\EmailTemplatesComponent\\Validator\\Rule\\RuleInterface');
     $ruleMock->shouldReceive('validate')->andThrow(new Validator\ValidationError('some fancy error'));
     $validator = new Validator([$ruleMock]);
     $errorTrace = $validator->validate($emailTemplate);
     $this->assertInstanceOf('TPN\\EmailTemplatesComponent\\Validator\\ErrorTrace', $errorTrace);
     $this->assertTrue($errorTrace->hasErrors());
     $this->assertEquals("0[child1] some fancy error\n" . "1[child2] some fancy error\n" . '2[child3] some fancy error', $errorTrace->dump());
 }