|
37 | 37 | use CommonITILActor;
|
38 | 38 | use Contract;
|
39 | 39 | use DbTestCase;
|
| 40 | +use Entity; |
40 | 41 | use ITILFollowup;
|
41 | 42 | use ITILSolution;
|
42 | 43 | use NotificationTarget;
|
@@ -1459,4 +1460,134 @@ public function testGetEntitySelectorTree(): void
|
1459 | 1460 | $fn_find_entities_in_selector(\Entity::getEntitySelectorTree(), $entities, null, $found);
|
1460 | 1461 | $this->assertCount(count($entities), $found);
|
1461 | 1462 | }
|
| 1463 | + |
| 1464 | + public function testGetHelpdeskSceneIdIsInheritedByDefault(): void |
| 1465 | + { |
| 1466 | + $this->login(); |
| 1467 | + $root_entity = $this->getTestRootEntity(); |
| 1468 | + |
| 1469 | + // Act: create a child entity without values for the scene fields |
| 1470 | + $entity = $this->createItem(Entity::class, [ |
| 1471 | + 'name' => "Test entity", |
| 1472 | + 'entities_id' => $root_entity->getID(), |
| 1473 | + ]); |
| 1474 | + |
| 1475 | + // Assert: scenes should be inherited |
| 1476 | + $this->assertEquals( |
| 1477 | + Entity::CONFIG_PARENT, |
| 1478 | + $entity->fields['custom_helpdesk_home_scene_left'], |
| 1479 | + ); |
| 1480 | + $this->assertEquals( |
| 1481 | + Entity::CONFIG_PARENT, |
| 1482 | + $entity->fields['custom_helpdesk_home_scene_right'], |
| 1483 | + ); |
| 1484 | + } |
| 1485 | + |
| 1486 | + public function testGetHelpdeskSceneIdInheritedDefaultValue(): void |
| 1487 | + { |
| 1488 | + $this->login(); |
| 1489 | + $root_entity = $this->getTestRootEntity(); |
| 1490 | + |
| 1491 | + // Arrange: create a child entity that inherit its parent values |
| 1492 | + $entity = $this->createItem(Entity::class, [ |
| 1493 | + 'name' => "Test entity", |
| 1494 | + 'entities_id' => $root_entity->getID(), |
| 1495 | + 'custom_helpdesk_home_scene_left' => Entity::CONFIG_PARENT, |
| 1496 | + 'custom_helpdesk_home_scene_right' => Entity::CONFIG_PARENT, |
| 1497 | + ]); |
| 1498 | + |
| 1499 | + // Act: get the scenes id |
| 1500 | + $left_scene_id = $entity->getHelpdeskSceneId( |
| 1501 | + 'custom_helpdesk_home_scene_left' |
| 1502 | + ); |
| 1503 | + $right_scene_id = $entity->getHelpdeskSceneId( |
| 1504 | + 'custom_helpdesk_home_scene_right' |
| 1505 | + ); |
| 1506 | + |
| 1507 | + // Assert: the default illustration must be found |
| 1508 | + $this->assertEquals($left_scene_id, Entity::DEFAULT_LEFT_SCENE); |
| 1509 | + $this->assertEquals($right_scene_id, Entity::DEFAULT_RIGHT_SCENE); |
| 1510 | + } |
| 1511 | + |
| 1512 | + public function testGetHelpdeskSceneIdInheritedCustomValue(): void |
| 1513 | + { |
| 1514 | + $this->login(); |
| 1515 | + $root_entity = $this->getTestRootEntity(); |
| 1516 | + |
| 1517 | + // Arrange: create a child entity that inherit its parent values |
| 1518 | + $entity = $this->createItem(Entity::class, [ |
| 1519 | + 'name' => "Test entity", |
| 1520 | + 'entities_id' => $root_entity->getID(), |
| 1521 | + 'custom_helpdesk_home_scene_left' => Entity::CONFIG_PARENT, |
| 1522 | + 'custom_helpdesk_home_scene_right' => Entity::CONFIG_PARENT, |
| 1523 | + ]); |
| 1524 | + |
| 1525 | + // Act: set custom values for the parent and get the scenes ids |
| 1526 | + $this->updateItem(Entity::class, $root_entity->getID(), [ |
| 1527 | + 'custom_helpdesk_home_scene_left' => 'test-left.png', |
| 1528 | + 'custom_helpdesk_home_scene_right' => 'test-right.png', |
| 1529 | + ]); |
| 1530 | + $left_scene_id = $entity->getHelpdeskSceneId( |
| 1531 | + 'custom_helpdesk_home_scene_left' |
| 1532 | + ); |
| 1533 | + $right_scene_id = $entity->getHelpdeskSceneId( |
| 1534 | + 'custom_helpdesk_home_scene_right' |
| 1535 | + ); |
| 1536 | + |
| 1537 | + // Assert: the specific file names should be found. |
| 1538 | + $this->assertEquals($left_scene_id, 'custom:test-left.png'); |
| 1539 | + $this->assertEquals($right_scene_id, 'custom:test-right.png'); |
| 1540 | + } |
| 1541 | + |
| 1542 | + public function testGetHelpdeskSceneIdDefaultValue(): void |
| 1543 | + { |
| 1544 | + $this->login(); |
| 1545 | + $root_entity = $this->getTestRootEntity(); |
| 1546 | + |
| 1547 | + // Arrange: create a child entity with default illustrations |
| 1548 | + $entity = $this->createItem(Entity::class, [ |
| 1549 | + 'name' => "Test entity", |
| 1550 | + 'entities_id' => $root_entity->getID(), |
| 1551 | + 'custom_helpdesk_home_scene_left' => '', |
| 1552 | + 'custom_helpdesk_home_scene_right' => '', |
| 1553 | + ]); |
| 1554 | + |
| 1555 | + // Act: get the scenes id |
| 1556 | + $left_scene_id = $entity->getHelpdeskSceneId( |
| 1557 | + 'custom_helpdesk_home_scene_left' |
| 1558 | + ); |
| 1559 | + $right_scene_id = $entity->getHelpdeskSceneId( |
| 1560 | + 'custom_helpdesk_home_scene_right' |
| 1561 | + ); |
| 1562 | + |
| 1563 | + // Assert: the default illustration must be found |
| 1564 | + $this->assertEquals($left_scene_id, Entity::DEFAULT_LEFT_SCENE); |
| 1565 | + $this->assertEquals($right_scene_id, Entity::DEFAULT_RIGHT_SCENE); |
| 1566 | + } |
| 1567 | + |
| 1568 | + public function testGetHelpdeskSceneIdCustomValue(): void |
| 1569 | + { |
| 1570 | + $this->login(); |
| 1571 | + $root_entity = $this->getTestRootEntity(); |
| 1572 | + |
| 1573 | + // Arrange: create a child entity with custom illustrations |
| 1574 | + $entity = $this->createItem(Entity::class, [ |
| 1575 | + 'name' => "Test entity", |
| 1576 | + 'entities_id' => $root_entity->getID(), |
| 1577 | + 'custom_helpdesk_home_scene_left' => 'test-left.png', |
| 1578 | + 'custom_helpdesk_home_scene_right' => 'test-right.png', |
| 1579 | + ]); |
| 1580 | + |
| 1581 | + // Act: Get the scenes ids |
| 1582 | + $left_scene_id = $entity->getHelpdeskSceneId( |
| 1583 | + 'custom_helpdesk_home_scene_left' |
| 1584 | + ); |
| 1585 | + $right_scene_id = $entity->getHelpdeskSceneId( |
| 1586 | + 'custom_helpdesk_home_scene_right' |
| 1587 | + ); |
| 1588 | + |
| 1589 | + // Assert: the specific file names should be found. |
| 1590 | + $this->assertEquals($left_scene_id, 'custom:test-left.png'); |
| 1591 | + $this->assertEquals($right_scene_id, 'custom:test-right.png'); |
| 1592 | + } |
1462 | 1593 | }
|
0 commit comments