Skip to content

Commit b25fcc0

Browse files
committed
Add test for coverage
1 parent 3def306 commit b25fcc0

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"require-dev": {
2929
"codeigniter4/codeigniter4": "dev-develop",
30-
"tatter/imposter": "^1.0",
3130
"tatter/tools": "^1.15"
3231
},
3332
"autoload": {

src/Entities/Email.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tatter\Outbox\Entities;
44

55
use CodeIgniter\Entity\Entity;
6+
use RuntimeException;
67

78
class Email extends Entity
89
{
@@ -58,11 +59,13 @@ public function getRecipients(): array
5859
* Helper function to return attachments or recipients.
5960
*
6061
* @param string $target Object/table/model to request
62+
*
63+
* @throws RuntimeException
6164
*/
6265
protected function getRelatedItems(string $target): array
6366
{
6467
if (empty($this->id)) {
65-
throw new \RuntimeException('Object must be created before getting relations.');
68+
throw new RuntimeException('Object must be created before getting relations.');
6669
}
6770

6871
$property = $target . 's';

tests/entities/EmailTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,14 @@ public function testGetRecipients()
5757
$this->assertInstanceOf(Recipient::class, $result[0]);
5858
$this->assertSame('[email protected]', $result[0]->email);
5959
}
60+
61+
public function testGetRelatedUncreatedThrows()
62+
{
63+
$email = new Email();
64+
65+
$this->expectException('RuntimeException');
66+
$this->expectExceptionMessage('Object must be created before getting relations.');
67+
68+
$email->getRecipients();
69+
}
6070
}

0 commit comments

Comments
 (0)