Skip to content
Snippets Groups Projects
Commit 77286beb authored by catch's avatar catch
Browse files

Issue #3085673 by mikelutz: [Symfony 4] EntityResourceValidationTraitTest...

Issue #3085673 by mikelutz: [Symfony 4] EntityResourceValidationTraitTest should not get a mock for an internal trait
parent 1e6ffcb5
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -4,6 +4,7 @@
use Drupal\Core\Entity\EntityConstraintViolationList;
use Drupal\node\Entity\Node;
use Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait;
use Drupal\Tests\UnitTestCase;
use Drupal\user\Entity\User;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
......@@ -19,7 +20,7 @@ class EntityResourceValidationTraitTest extends UnitTestCase {
* @covers ::validate
*/
public function testValidate() {
$trait = $this->getMockForTrait('Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait');
$trait = new EntityResourceValidationTraitTestClass();
$method = new \ReflectionMethod($trait, 'validate');
$method->setAccessible(TRUE);
......@@ -59,7 +60,7 @@ public function testFailedValidate() {
$entity->validate()->willReturn($violations);
$trait = $this->getMockForTrait('Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait');
$trait = new EntityResourceValidationTraitTestClass();
$method = new \ReflectionMethod($trait, 'validate');
$method->setAccessible(TRUE);
......@@ -70,3 +71,15 @@ public function testFailedValidate() {
}
}
/**
* A test class to use to test EntityResourceValidationTrait.
*
* Using ->getMockForTrait is problematic, as this trait is marked internal.
* Because the mock doesn't use the \Drupal namespace, the Symfony 4+ class
* loader will throw a deprecation error.
*/
class EntityResourceValidationTraitTestClass {
use EntityResourceValidationTrait;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment