Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default entity profile #2

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions remote_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// phpcs:enable

use Civi\RemoteCase\Api4\Permissions;
use Civi\RemoteCase\RemoteCaseDefaultEntityProfile;
use Civi\RemoteTools\EntityProfile\ReadOnlyRemoteEntityProfile;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use CRM_RemoteCase_ExtensionUtil as E;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Implements hook_civicrm_config().
Expand All @@ -24,9 +22,8 @@ function remote_case_civicrm_config(\CRM_Core_Config $config): void {
* Implements hook_civicrm_container().
*/
function remote_case_civicrm_container(ContainerBuilder $container): void {
if (class_exists(ReadOnlyRemoteEntityProfile::class)) {
$container->autowire(RemoteCaseDefaultEntityProfile::class)
->addTag(RemoteCaseDefaultEntityProfile::SERVICE_TAG);
if (function_exists('_remote_case_test_civicrm_container')) {
_remote_case_test_civicrm_container($container);
}
}

Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/Civi/Api4/RemoteCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* @covers \Civi\Api4\RemoteCase
* @covers \Civi\RemoteCase\RemoteCaseDefaultEntityProfile
* @covers \Civi\RemoteCase\RemoteCaseTestEntityProfile
*
* @group headless
*/
Expand All @@ -36,7 +36,7 @@ public function testDelete(): void {
$contact = ContactFixture::addIndividual();
$case = CaseFixture::addFixture($contact['id']);
$result = RemoteCase::delete()
->setProfile('default')
->setProfile('test')
->addWhere('id', '=', $case['id'])
->execute();

Expand All @@ -45,15 +45,15 @@ public function testDelete(): void {

public function testGet(): void {
$result = RemoteCase::get()
->setProfile('default')
->setProfile('test')
->execute();

static::assertCount(0, $result);

$contact = ContactFixture::addIndividual();
$case = CaseFixture::addFixture($contact['id']);
$result = RemoteCase::get()
->setProfile('default')
->setProfile('test')
->addSelect('*', 'CAN_delete', 'CAN_update')
->execute();

Expand All @@ -63,7 +63,7 @@ public function testGet(): void {
static::assertFalse($result->single()['CAN_update']);

$result = RemoteCase::get()
->setProfile('default')
->setProfile('test')
->addWhere('id', '!=', $case['id'])
->execute();

Expand All @@ -79,13 +79,13 @@ public function testGetActions(): void {
public function testGetCreateForm(): void {
$this->expectException(UnauthorizedException::class);
RemoteCase::getCreateForm()
->setProfile('default')
->setProfile('test')
->execute();
}

public function testGetFields(): void {
$result = RemoteCase::getFields()
->setProfile('default')
->setProfile('test')
->addSelect('*', 'CAN_delete', 'CAN_update')
->execute();

Expand All @@ -100,7 +100,7 @@ public function testGetUpdateForm(): void {
$case = CaseFixture::addFixture($contact['id']);
$this->expectException(UnauthorizedException::class);
RemoteCase::getUpdateForm()
->setProfile('default')
->setProfile('test')
->setId($case['id'])
->execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

use Civi\RemoteTools\EntityProfile\ReadOnlyRemoteEntityProfile;

final class RemoteCaseDefaultEntityProfile extends ReadOnlyRemoteEntityProfile {
final class RemoteCaseTestEntityProfile extends ReadOnlyRemoteEntityProfile {

public const NAME = 'default';
public const NAME = 'test';

public const ENTITY_NAME = 'Case';

Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
declare(strict_types = 1);

use Civi\RemoteCase\RemoteCaseTestEntityProfile;
use Composer\Autoload\ClassLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -52,6 +53,8 @@
* Modify DI container for tests.
*/
function _remote_case_test_civicrm_container(ContainerBuilder $container): void {
$container->autowire(RemoteCaseTestEntityProfile::class)
->addTag(RemoteCaseTestEntityProfile::SERVICE_TAG);
}

function addExtensionToClassLoader(string $extension): void {
Expand Down
Loading