Compare commits
22 Commits
multiplefu
...
ffb56ab09f
Author | SHA1 | Date | |
---|---|---|---|
ffb56ab09f | |||
2f07a2b9aa | |||
20f2312245 | |||
6857bb8d4c | |||
f48dae3371 | |||
183537db39 | |||
fb9737ca04 | |||
737104d7bd | |||
66fa591566 | |||
c318c451dc | |||
d81e1b3711 | |||
eb9335b250 | |||
809dbfc837 | |||
156434fecc | |||
57795b6393 | |||
457b4ad694 | |||
780f144b52 | |||
33aec90a78 | |||
f9654bcd78 | |||
4852de71c7 | |||
c29a480401 | |||
56bc7b83dd |
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\opencase_cases\Entity;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityBase;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Entity\RevisionableContentEntityBase;
|
||||
@ -116,6 +117,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
else return [];
|
||||
}
|
||||
|
||||
public function getTargetEntity(): ContentEntityBase {
|
||||
if (!$this->oc_target->isEmpty()) {
|
||||
return $this->oc_target->entity;
|
||||
} elseif ($this->hasField('client') && !$this->client->isEmpty()) {
|
||||
return $this->client->entity;
|
||||
} else {
|
||||
throw new \Exception('No target found on case');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -230,7 +230,8 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
->setLabel(t('Visible'))
|
||||
->setDescription(t('A boolean indicating whether the Case Fee is published.'))
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE);
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setDefaultValue(TRUE);
|
||||
|
||||
$fields['created'] = BaseFieldDefinition::create('created')
|
||||
->setLabel(t('Created'))
|
||||
|
@ -56,10 +56,10 @@ class OCCaseRevisionRevertForm extends ConfirmFormBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager')->getStorage('oc_case'),
|
||||
$container->get('date.formatter')
|
||||
);
|
||||
return new static($container
|
||||
->get('entity_type.manager')
|
||||
->getStorage('oc_case'), $container
|
||||
->get('date.formatter'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,6 +211,9 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
|
||||
public function getCountOfCaseProvisions(array $conditionsToApplyToCaseProvisionQuery = []): int {
|
||||
$query = \Drupal::entityQuery('oc_case_provision');
|
||||
$query->condition('oc_provider', $this->id());
|
||||
foreach($conditionsToApplyToCaseProvisionQuery as $condition) {
|
||||
$query->condition($condition[0], $condition[1], $condition[2] ?? '=');
|
||||
}
|
||||
return count($query->execute());
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class OCActivityRevisionRevertForm extends ConfirmFormBase {
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager')->getStorage('oc_activity'),
|
||||
$container->get('entity_type.manager')->getStorage('oc_activity'),
|
||||
$container->get('date.formatter')
|
||||
);
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ class OCActorRevisionRevertForm extends ConfirmFormBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager')->getStorage('oc_actor'),
|
||||
$container->get('date.formatter')
|
||||
);
|
||||
return new static($container
|
||||
->get('entity_type.manager')
|
||||
->getStorage('oc_actor'), $container
|
||||
->get('date.formatter'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ class OCOrganisationRevisionRevertForm extends ConfirmFormBase {
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
$instance = parent::create($container);
|
||||
$instance->oCOrganisationStorage = $container->get('entity_type.manager')->getStorage('oc_organisation');
|
||||
$instance->OCOrganisationStorage = $container->get('entity_type.manager')->getStorage('oc_organisation');
|
||||
$instance->dateFormatter = $container->get('date.formatter');
|
||||
return $instance;
|
||||
}
|
||||
|
8
opencase.services.yml
Normal file
8
opencase.services.yml
Normal file
@ -0,0 +1,8 @@
|
||||
services:
|
||||
opencase.breadcrumb:
|
||||
# The namespace + classname from your BreadcrumbBuilderInterface class
|
||||
class: Drupal\opencase\Breadcrumb\BreadcrumbBuilder
|
||||
|
||||
# Priority determines the order in which Breadcrumb services run.
|
||||
tags:
|
||||
- { name: breadcrumb_builder, priority: 100 }
|
105
src/Breadcrumb/BreadcrumbBuilder.php
Normal file
105
src/Breadcrumb/BreadcrumbBuilder.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Drupal\opencase\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Link ;
|
||||
use Drupal\Core\Breadcrumb\Breadcrumb;
|
||||
use Drupal\opencase_cases\Entity\OCCase;
|
||||
use Drupal\Core\Entity\ContentEntityBase;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\opencase_entities\Entity\OCOrganisation;
|
||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||
|
||||
class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
|
||||
private string $title;
|
||||
private function addTitle($route_match) {
|
||||
$title = $this->title ?? $this->getPageTitle($route_match);
|
||||
$this->breadcrumb->addLink(Link::createFromRoute($title, '<none>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies(RouteMatchInterface $route_match) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
private function getPageTitle($route_match) {
|
||||
$request = \Drupal::request();
|
||||
return \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
|
||||
}
|
||||
|
||||
private function addLinksForCaseTarget(ContentEntityBase $entity) {
|
||||
if ($entity instanceof OCOrganisation) {
|
||||
$this->addLinksForOrganisation($entity);
|
||||
}
|
||||
}
|
||||
|
||||
private function addLinksForOrganisation(ContentEntityBase $entity) {
|
||||
$fields = ['field_umbrella_client'];
|
||||
$this->addLinks($entity, $fields);
|
||||
}
|
||||
|
||||
private function addLinksForCase(OCCase $case) {
|
||||
$fields = ['client', 'field_project'];
|
||||
$this->addLinksForCaseTarget($case->getTargetEntity());
|
||||
$this->addLinks($case, $fields);
|
||||
}
|
||||
|
||||
private function addLinks(ContentEntityBase $entity, array $fields) {
|
||||
foreach ($fields as $field) {
|
||||
if ($entity->hasField($field) && !$entity->get($field)->isEmpty()) {
|
||||
$this->breadcrumb->addLink($entity->$field->entity->toLink());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$this->breadcrumb = new Breadcrumb();
|
||||
$this->breadcrumb->addLink(Link::createFromRoute('Home', '<front>'));
|
||||
$params = $route_match->getParameters();
|
||||
|
||||
if ($params->has('oc_activity')) {
|
||||
$activity = $params->get('oc_activity');
|
||||
if (!$activity->get('oc_case')->isEmpty()){
|
||||
$this->addLinksForCase($activity->get('oc_case')->entity);
|
||||
}
|
||||
$this->addLinks($activity, ['client', 'oc_case']);
|
||||
$this->title = $activity->getName() ?? $activity->type->entity->label();
|
||||
}
|
||||
|
||||
elseif ($params->has('oc_organisation')) {
|
||||
$this->addLinksForOrganisation($params->get('oc_organisation'));
|
||||
}
|
||||
|
||||
elseif ($params->has('oc_case')) {
|
||||
$this->addLinksForCase($params->get('oc_case'));
|
||||
}
|
||||
|
||||
elseif ($params->has('oc_case_fee')) {
|
||||
$case_provision = $params->get('oc_case_fee');
|
||||
$this->addLinksForCase($case_provision->get('oc_case')->entity);
|
||||
$this->addLinks($case_provision, ['oc_case']);
|
||||
$this->title = "Fee";
|
||||
}
|
||||
|
||||
elseif ($params->has('oc_case_provision')) {
|
||||
$case_provision = $params->get('oc_case_provision');
|
||||
$this->addLinksForCase($case_provision->get('oc_case')->entity);
|
||||
$this->addLinks($case_provision, ['oc_case']);
|
||||
$this->title = $case_provision->type->entity->label();
|
||||
}
|
||||
|
||||
$this->addTitle($route_match);
|
||||
|
||||
// Don't forget to add cache control by a route.
|
||||
// Otherwise all pages will have the same breadcrumb.
|
||||
$this->breadcrumb->addCacheContexts(['route']);
|
||||
return $this->breadcrumb;
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,14 @@
|
||||
|
||||
namespace Drupal\opencase;
|
||||
|
||||
|
||||
class Pluraliser {
|
||||
const NO_CHANGE = ['Staff'];
|
||||
public static function pluralise($text) {
|
||||
return $text . "s";
|
||||
if (in_array($text, self::NO_CHANGE)) {
|
||||
return $text;
|
||||
} else {
|
||||
return $text . "s";
|
||||
}
|
||||
}
|
||||
}
|
@ -2,25 +2,21 @@
|
||||
|
||||
namespace Drupal\opencase;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\opencase\Utils;
|
||||
|
||||
final class TimeBasedFieldUpdater {
|
||||
|
||||
private EntityTypeManagerInterface $entityTypeManager;
|
||||
private string $date_field;
|
||||
private Utils $utils;
|
||||
private string $entity_type;
|
||||
private string $date_format;
|
||||
private string $bundle;
|
||||
|
||||
final public function __construct(
|
||||
EntityTypeManagerInterface $entityTypeManager,
|
||||
Utils $utils,
|
||||
string $entity_type, string $bundle, string $date_field, string $date_format = 'Y-m-d'
|
||||
)
|
||||
{
|
||||
$this->entityTypeManager = $entityTypeManager;
|
||||
$this->utils = $utils;
|
||||
$this->date_field = $date_field;
|
||||
$this->date_format = $date_format;
|
||||
$this->entity_type = $entity_type;
|
||||
@ -39,7 +35,7 @@ final class TimeBasedFieldUpdater {
|
||||
$this->updateEntity($id, $new_values);
|
||||
}
|
||||
}
|
||||
private function updateEntity(int $entity_id, array $new_values): void {
|
||||
private function updateEntity(string $entity_id, array $new_values): void {
|
||||
$entity = $this->entityTypeManager->getStorage($this->entity_type)->load($entity_id);
|
||||
foreach($new_values as $new_field=>$new_value) {
|
||||
$entity->$new_field = $new_value;
|
||||
|
38
tests/src/Unit/EntityTrait.php
Normal file
38
tests/src/Unit/EntityTrait.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Drupal\Tests\opencase\Unit;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
|
||||
trait EntityTrait {
|
||||
public function getEntityTypeManager() {
|
||||
return $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeManager')->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
public function getStorage(MockObject $entityTypeManager, string $entityTypeToExpect = ''): MockObject {
|
||||
$storage = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityStorageInterface')->disableOriginalConstructor()->getMock();
|
||||
$entityTypeManager->method('getStorage')->willReturn($storage);
|
||||
if ($entityTypeToExpect) {
|
||||
$entityTypeManager->expects($this->any())->method('getStorage')->with($entityTypeToExpect)->willReturn($storage);
|
||||
}
|
||||
return $storage;
|
||||
}
|
||||
|
||||
public function getQuery(MockObject $storage): MockObject {
|
||||
$query = $this->getMockBuilder('\\Drupal\\Core\\Entity\\Query\\QueryInterface')->getMock();
|
||||
$storage->method('getQuery')->willReturn($query);
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getEntity(): MockObject {
|
||||
return $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
public function getContainer(array $services): ContainerBuilder {
|
||||
$container = new ContainerBuilder();
|
||||
foreach ($services as $key => $mock) {
|
||||
$container->set($key, $mock);
|
||||
}
|
||||
\Drupal::setContainer($container);
|
||||
return $container;
|
||||
}
|
||||
}
|
61
tests/src/Unit/OCActorTest.php
Normal file
61
tests/src/Unit/OCActorTest.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Drupal\Tests\opencase\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
class OCActorTest extends UnitTestCase{
|
||||
|
||||
use EntityTrait;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->etm = $this->getEntityTypeManager();
|
||||
$this->getContainer([
|
||||
'entity_type.manager' => $this->etm
|
||||
]);
|
||||
}
|
||||
|
||||
public function testGetCountOfCaseProvisionsWithNoExtraConditions(): void{
|
||||
$storage = $this->getStorage($this->etm, 'oc_case_provision');
|
||||
$query = $this->getQuery($storage);
|
||||
$actor = $this->getMockBuilder('\\Drupal\\opencase_entities\\Entity\\OCActor')->disableOriginalConstructor()
|
||||
->onlyMethods(['id'])
|
||||
->getMock();
|
||||
$actor->expects($this->once())->method('id')->willReturn(5);
|
||||
$query->expects($this->once())->method('condition')->with('oc_provider', 5);
|
||||
$query->expects($this->once())->method('execute')->willReturn([1,2,3,4]);
|
||||
$count = $actor->getCountOfCaseProvisions();
|
||||
$this->assertTrue($count == 4);
|
||||
}
|
||||
|
||||
|
||||
public function testGetCountOfCaseProvisionsWithExtraConditions(): void{
|
||||
$storage = $this->getStorage($this->etm, 'oc_case_provision');
|
||||
$query = $this->getQuery($storage);
|
||||
$actor = $this->getMockBuilder('\\Drupal\\opencase_entities\\Entity\\OCActor')->disableOriginalConstructor()
|
||||
->onlyMethods(['id'])
|
||||
->getMock();
|
||||
$actor->expects($this->once())->method('id')->willReturn(5);
|
||||
$query->expects($this->exactly(2))->method('condition')->withConsecutive(
|
||||
['oc_provider', 5],
|
||||
['some_date_field', '2022-01-01', '<']);
|
||||
$query->expects($this->once())->method('execute')->willReturn([1,2,3,4]);
|
||||
$count = $actor->getCountOfCaseProvisions([['some_date_field', '2022-01-01', '<']]);
|
||||
$this->assertTrue($count == 4);
|
||||
}
|
||||
|
||||
public function testGetCountOfCaseProvisionsWithExtraConditionsWithAssumedEqualityOperator(): void{
|
||||
$storage = $this->getStorage($this->etm, 'oc_case_provision');
|
||||
$query = $this->getQuery($storage);
|
||||
$actor = $this->getMockBuilder('\\Drupal\\opencase_entities\\Entity\\OCActor')->disableOriginalConstructor()
|
||||
->onlyMethods(['id'])
|
||||
->getMock();
|
||||
$actor->expects($this->once())->method('id')->willReturn(5);
|
||||
$query->expects($this->exactly(2))->method('condition')->withConsecutive(
|
||||
['oc_provider', 5],
|
||||
['some_date_field', '2022-01-01', '=']);
|
||||
$query->expects($this->once())->method('execute')->willReturn([1,2,3,4]);
|
||||
$count = $actor->getCountOfCaseProvisions([['some_date_field', '2022-01-01']]);
|
||||
$this->assertTrue($count == 4);
|
||||
}
|
||||
}
|
60
tests/src/Unit/RevisionRevertFormTest.php
Normal file
60
tests/src/Unit/RevisionRevertFormTest.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Drupal\Tests\opencase\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Tests\opencase\Unit\EntityTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Drupal\opencase_cases\Form\OCCaseRevisionRevertForm;
|
||||
use Drupal\opencase_entities\Form\OCActorRevisionRevertForm;
|
||||
use Drupal\opencase_entities\Form\OCActivityRevisionRevertForm;
|
||||
use Drupal\opencase_entities\Form\OCOrganisationRevisionRevertForm;
|
||||
|
||||
class RevisionRevertFormTest extends UnitTestCase{
|
||||
|
||||
use EntityTrait;
|
||||
|
||||
public function setUp(): void {
|
||||
$entityTypeManager = $this->getEntityTypeManager();
|
||||
$storage = $this->getStorage($entityTypeManager);
|
||||
$dateFormatter = $this->getMockBuilder('\\Drupal\\Core\\Datetime\\DateFormatterInterface')->disableOriginalConstructor()->getMock();
|
||||
$revision = $this->getMockBuilder('\\Drupal\\opencase_entities\\Entity\OCActivity')->disableOriginalConstructor()->getMock();
|
||||
$request = new Request([], [], [], [], [], [], [], json_encode([
|
||||
'foo' => 'bar'
|
||||
]));
|
||||
$requestStack = new RequestStack();
|
||||
$requestStack->push($request);
|
||||
$dateFormatter->method('format');
|
||||
$storage->method('loadRevision')->willReturn($revision);
|
||||
$this->container = $this->getContainer([
|
||||
'entity_type.manager'=> $entityTypeManager,
|
||||
'date.formatter' => $dateFormatter,
|
||||
'string_translation'=> self::getStringTranslationStub(),
|
||||
'request_stack'=> $requestStack
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function testBuildFormForRevertingActivity():void {
|
||||
$this->reverter = OCActivityRevisionRevertForm::create($this->container);
|
||||
$form = [];
|
||||
$this->assertTrue(is_array($this->reverter->buildForm($form, new FormState())));
|
||||
}
|
||||
public function testBuildFormForRevertingActor():void {
|
||||
$this->reverter = OCActorRevisionRevertForm::create($this->container);
|
||||
$form = [];
|
||||
$this->assertTrue(is_array($this->reverter->buildForm($form, new FormState())));
|
||||
}
|
||||
public function testBuildFormForRevertingCase():void {
|
||||
$this->reverter = OCCaseRevisionRevertForm::create($this->container);
|
||||
$form = [];
|
||||
$this->assertTrue(is_array($this->reverter->buildForm($form, new FormState())));
|
||||
}
|
||||
public function testBuildFormForRevertingOrganisation():void {
|
||||
$this->reverter = OCOrganisationRevisionRevertForm::create($this->container);
|
||||
$form = [];
|
||||
$this->assertTrue(is_array($this->reverter->buildForm($form, new FormState())));
|
||||
}
|
||||
}
|
@ -7,16 +7,13 @@ use Drupal\opencase\TimeBasedFieldUpdater;
|
||||
|
||||
class TimeBasedFieldUpdaterTest extends UnitTestCase{
|
||||
|
||||
use EntityTrait;
|
||||
|
||||
function setUp():void {
|
||||
/** @var \Drupal\opencase\Utils&\PHPUnit\Framework\MockObject\MockObject $utils */
|
||||
$this->utils = $this->getMockBuilder('\\Drupal\\opencase\\Utils')->disableOriginalConstructor()->getMock();
|
||||
/** @var \Drupal\core\Entity\EntityTypeManagerInterface&\PHPUnit\Framework\MockObject\MockObject $entityTypeManager */
|
||||
$this->entityTypeManager = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeManager')->disableOriginalConstructor()->getMock();
|
||||
$this->storage = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityStorageInterface')->getMock();
|
||||
$this->query = $this->getMockBuilder('\\Drupal\\Core\\Entity\\Query\\QueryInterface')->getMock();
|
||||
$this->entityTypeManager->method('getStorage')->willReturn($this->storage);
|
||||
$this->storage->method('getQuery')->willReturn($this->query);
|
||||
$this->updater = new TimeBasedFieldUpdater($this->entityTypeManager, $this->utils, 'dummy_entity_type', 'dummy_bundle', 'dummy_date_field');
|
||||
$this->etm = $this->getEntityTypeManager();
|
||||
$this->storage = $this->getStorage($this->etm);
|
||||
$this->query = $this->getQuery($this->storage);
|
||||
$this->updater = new TimeBasedFieldUpdater($this->etm, 'dummy_entity_type', 'dummy_bundle', 'dummy_date_field');
|
||||
|
||||
}
|
||||
function testFieldIsUpdatedOnEntityReturnedByQuery():void {
|
||||
@ -28,21 +25,21 @@ class TimeBasedFieldUpdaterTest extends UnitTestCase{
|
||||
}
|
||||
function testFieldIsUpdatedOnAllEntitiesReturnedByQuery():void {
|
||||
$this->query->method('execute')->willReturn([1, 2]);
|
||||
$this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock();
|
||||
$this->entity2 = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock();
|
||||
$this->storage->method('load')->willReturnMap([[1, $this->entity], [2, $this-> entity2]]);
|
||||
$entity = $this->getEntity();
|
||||
$entity2 = $this->getEntity();
|
||||
$this->storage->method('load')->willReturnMap([[1, $entity], [2, $entity2]]);
|
||||
$this->updater->update([], '3 months', ['dummy_field' => 4]);
|
||||
$this->assertEquals($this->entity->dummy_field, 4);
|
||||
$this->assertEquals($this->entity2->dummy_field, 4);
|
||||
$this->assertEquals($entity->dummy_field, 4);
|
||||
$this->assertEquals($entity2->dummy_field, 4);
|
||||
}
|
||||
|
||||
function testMultipleFieldsAreUpdated(): void {
|
||||
$this->query->method('execute')->willReturn([1]);
|
||||
$this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityBase')->disableOriginalConstructor()->getMock();
|
||||
$this->storage->expects($this->once())->method('load')->with(1)->willReturn($this->entity);
|
||||
$entity = $this->getEntity();
|
||||
$this->storage->expects($this->once())->method('load')->with(1)->willReturn($entity);
|
||||
$this->updater->update([], '3 months', ['dummy_field' => 4, 'dummy_field_2' => 5]);
|
||||
$this->assertEquals($this->entity->dummy_field, 4);
|
||||
$this->assertEquals($this->entity->dummy_field_2, 5);
|
||||
$this->assertEquals($entity->dummy_field, 4);
|
||||
$this->assertEquals($entity->dummy_field_2, 5);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user