Skip to content

Commit

Permalink
Fixed FormError issue
Browse files Browse the repository at this point in the history
  • Loading branch information
prosalov committed Sep 25, 2017
1 parent 4346a5a commit add20b8
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tests/Handler/FormErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public function testDefaultTranslationDomain()
$this->equalTo('validators')
);

$this->invokeMethod($handler, 'getErrorMessage', [new FormError('error!'),]);
$formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
$formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
$formError->expects($this->once())->method('getMessagePluralization')->willReturn(null);
$formError->expects($this->once())->method('getMessageParameters')->willReturn([]);

$this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
}

public function testDefaultTranslationDomainWithPluralTranslation()
Expand All @@ -132,7 +137,12 @@ public function testDefaultTranslationDomainWithPluralTranslation()
$this->equalTo('validators')
);

$this->invokeMethod($handler, 'getErrorMessage', [new FormError('error!', null, array(), 0),]);
$formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
$formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
$formError->expects($this->exactly(2))->method('getMessagePluralization')->willReturn(0);
$formError->expects($this->once())->method('getMessageParameters')->willReturn([]);

$this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
}

public function testCustomTranslationDomain()
Expand All @@ -150,7 +160,12 @@ public function testCustomTranslationDomain()
$this->equalTo('custom_domain')
);

$this->invokeMethod($handler, 'getErrorMessage', [new FormError('error!'),]);
$formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
$formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
$formError->expects($this->once())->method('getMessagePluralization')->willReturn(null);
$formError->expects($this->once())->method('getMessageParameters')->willReturn([]);

$this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
}

public function testCustomTranslationDomainWithPluralTranslation()
Expand All @@ -169,7 +184,13 @@ public function testCustomTranslationDomainWithPluralTranslation()
$this->equalTo('custom_domain')
);

$this->invokeMethod($handler, 'getErrorMessage', [new FormError('error!', null, array(), 0),]);
$formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
$formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
$formError->expects($this->exactly(2))->method('getMessagePluralization')->willReturn(0);
$formError->expects($this->once())->method('getMessageParameters')->willReturn([]);

$this->invokeMethod($handler, 'getErrorMessage', [$formError,]);

}

/**
Expand Down

0 comments on commit add20b8

Please sign in to comment.