mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°7726 - Fatal error if a newsroom is sent without any message
Add test for valid ActionNewsroom
This commit is contained in:
@@ -65,7 +65,7 @@ class ActionNewsroomTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testActionNewsroomRecordsEventIfAMandatoryFieldIsEmpty(bool $bIsAsynchronous)
|
||||
{
|
||||
$iActionNewsroomId = $this->GivenActionNewsroom($bIsAsynchronous, '$this->service_name$');
|
||||
$iActionNewsroomId = $this->GivenActionNewsroomInDB($bIsAsynchronous, '$this->service_name$');
|
||||
|
||||
$this->CreateUserRequest(1,
|
||||
[
|
||||
@@ -87,11 +87,48 @@ class ActionNewsroomTest extends ItopDataTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ActionNewsroomProvider
|
||||
* @throws CoreException
|
||||
* @throws MissingQueryArgument
|
||||
* @throws CoreUnexpectedValue
|
||||
* @throws ArchivedObjectException
|
||||
* @throws MySQLException
|
||||
* @throws MySQLHasGoneAwayException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testActionNewsroomRecordsEvent(bool $bIsAsynchronous)
|
||||
{
|
||||
$iActionNewsroomId = $this->GivenActionNewsroomInDB($bIsAsynchronous, 'Body of the notification');
|
||||
|
||||
$iServiceId = $this->GivenService('Test service');
|
||||
|
||||
$this->CreateUserRequest(1,
|
||||
[
|
||||
'title' => '[TEST] ActionNewsroom',
|
||||
'org_id' => $this->getTestOrgId(),
|
||||
'caller_id' => $this->iRecipientId,
|
||||
'description' => 'PHPUnit Test',
|
||||
'service_id' => 0
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->AssertUniqueObjectInDB(
|
||||
'EventNotificationNewsroom',
|
||||
[
|
||||
'action_id' => $iActionNewsroomId,
|
||||
'message' => 'Body of the notification'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function GivenActionNewsroom(bool $bIsAsynchronous, string $sMessage): int
|
||||
private function GivenActionNewsroomInDB(bool $bIsAsynchronous, string $sMessage): int
|
||||
{
|
||||
$this->GivenObjectInDB('UserLocal', [
|
||||
'login' => 'demo_test_'.uniqid(__CLASS__, true),
|
||||
@@ -114,4 +151,16 @@ class ActionNewsroomTest extends ItopDataTestCase
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function GivenService(string $sName): int
|
||||
{
|
||||
return $this->GivenObjectInDB('Service', [
|
||||
'name' => $sName,
|
||||
'org_id' => $this->getTestOrgId()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user