Skip to content

Commit e1ac5c7

Browse files
authored
Merge pull request #22 from tattersoftware/test
Test
2 parents 6c60b0e + b25fcc0 commit e1ac5c7

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Tatter\Outbox
22
Email toolkit for CodeIgniter 4
33

4-
[![](https://github.com/tattersoftware/codeigniter4-outbox/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-outbox/actions?query=workflow%3A%22PHPUnit)
5-
[![](https://github.com/tattersoftware/codeigniter4-outbox/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-outbox/actions?query=workflow%3A%22PHPStan)
4+
[![](https://github.com/tattersoftware/codeigniter4-outbox/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-outbox/actions/workflows/test.yml)
5+
[![](https://github.com/tattersoftware/codeigniter4-outbox/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-outbox/actions/workflows/analyze.yml)
6+
[![](https://github.com/tattersoftware/codeigniter4-outbox/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-outbox/actions/workflows/inspect.yml)
67
[![Coverage Status](https://coveralls.io/repos/github/tattersoftware/codeigniter4-outbox/badge.svg?branch=develop)](https://coveralls.io/github/tattersoftware/codeigniter4-outbox?branch=develop)
78

89
## Quick Start
@@ -21,17 +22,32 @@ model(TemplateModel::class)->findByName('Default')
2122
->send();
2223
```
2324

24-
## Description
25+
## Features
2526

26-
**Outbox** supplies a handful of useful tools to supplement the framework's native `Email`
27-
class.
27+
**Outbox** supplies useful tools to supplement the framework's native `Email` class:
28+
logging, style inlining, and templating.
29+
30+
## Installation
31+
32+
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities
33+
and always be up-to-date:
34+
```bash
35+
composer require tatter/outbox
36+
```
37+
38+
Or, install manually by downloading the source files and adding the directory to
39+
**app/Config/Autoload.php**.
2840

2941
## Configuration (optional)
3042

3143
The library's default behavior can be altered by extending its config file. Copy
3244
**examples/Outbox.php** to **app/Config/** and follow the instructions
3345
in the comments. If no config file is found in **app/Config** then the library will use its own.
3446

47+
If you plan to use the Template Routes (see below) you should also want to configure
48+
[Tatter\Layouts](https://github.com/tattersoftware/codeigniter4-layouts) to ensure the
49+
views are displayed properly for your app.
50+
3551
## Usage
3652

3753
### Logging

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)