This repository has been archived on 2022-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
opencase/tests/src/Unit/OCCaseTest.php

34 lines
1.1 KiB
PHP

<?php declare(strict_types = 1);
namespace Drupal\Tests\opencase\Unit;
use Drupal\Tests\UnitTestCase;
class OCCaseTest extends UnitTestCase{
use EntityTrait;
private $case;
public function setUp(): void {
$this->etm = $this->getEntityTypeManager();
$this->getContainer([
'entity_type.manager' => $this->etm
]);
$this->case = $this->getMockBuilder('\\Drupal\\opencase_cases\\Entity\\OCCase')->disableOriginalConstructor()
->onlyMethods(['id'])
->getMock();
}
public function testGetCaseProvisionIds(): void{
$storage = $this->getStorage($this->etm, 'oc_case_provision');
$query = $this->getQuery($storage);
$this->case->expects($this->once())->method('id')->willReturn(5);
$query->expects($this->once())->method('condition')->withConsecutive(
['oc_case.target_id', 5]);
$query->expects($this->once())->method('execute')->willReturn([1,2,3,4]);
$ids = $this->case->getCaseProvisionIds($this->etm);
$this->assertTrue($ids == [1,2,3,4]);
}
}