added tests for COrganisationRevisionRevertForm
This commit is contained in:
parent
9862e65ea9
commit
56bc7b83dd
40
tests/src/Unit/OCOrganisationRevisionRevertFormTest.php
Normal file
40
tests/src/Unit/OCOrganisationRevisionRevertFormTest.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace Drupal\Tests\opencase\Unit;
|
||||||
|
|
||||||
|
use Drupal\Tests\UnitTestCase;
|
||||||
|
use Drupal\Core\Form\FormState;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||||
|
use Drupal\opencase_entities\Form\OCOrganisationRevisionRevertForm;
|
||||||
|
|
||||||
|
class OCOrganisationRevisionRevertFormTest extends UnitTestCase{
|
||||||
|
public function setUp(): void {
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$entityTypeManager = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeManager')->disableOriginalConstructor()->getMock();
|
||||||
|
$dateFormatter = $this->getMockBuilder('\\Drupal\\Core\\Datetime\\DateFormatterInterface')->disableOriginalConstructor()->getMock();
|
||||||
|
$storage = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityStorageInterface')->disableOriginalConstructor()->getMock();
|
||||||
|
$revision = $this->getMockBuilder('\\Drupal\\opencase_entities\\Entity\OCOrganisation')->disableOriginalConstructor()->getMock();
|
||||||
|
$request = new Request([], [], [], [], [], [], [], json_encode([
|
||||||
|
'foo' => 'bar'
|
||||||
|
]));
|
||||||
|
$requestStack = new RequestStack();
|
||||||
|
$requestStack->push($request);
|
||||||
|
$dateFormatter->method('format');
|
||||||
|
$container->set('entity_type.manager', $entityTypeManager);
|
||||||
|
$container->set('date.formatter', $dateFormatter);
|
||||||
|
$entityTypeManager->method('getStorage')->willReturn($storage);
|
||||||
|
$storage->method('loadRevision')->willReturn($revision);
|
||||||
|
$container->set('string_translation', self::getStringTranslationStub());
|
||||||
|
$container->set('request_stack', $requestStack);
|
||||||
|
\Drupal::setContainer($container);
|
||||||
|
$this->reverter = OCOrganisationRevisionRevertForm::create($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBuildForm():void {
|
||||||
|
$form = [];
|
||||||
|
$this->assertTrue(is_array($this->reverter->buildForm($form, new FormState())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user