Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
- Fixed an error setting a from recipent
  • Loading branch information
beebmx committed Oct 8, 2024
1 parent 5d55dfe commit 9c82a3f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ phpunit.xml.dist export-ignore

# Others
.editorconfig export-ignore
.prettierrc export-ignore
CHANGELOG-* export-ignore
CHANGELOG export-ignore
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Kirby Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.",
"license": "MIT",
"type": "kirby-plugin",
"version": "1.0.0",
"version": "1.0.1",
"keywords": [
"kirby",
"kirby-4",
Expand Down Expand Up @@ -52,7 +52,7 @@
"kirby-plugin-path": "tests/Fixtures/site/plugins"
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "vendor/bin/pest"
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
10 changes: 5 additions & 5 deletions src/Console/MakeThemeMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public function __invoke(CLI $cli): void
$fake = $cli->arg('fake') === true;
$name = $cli->argOrPrompt('theme', 'Enter a courier theme name:');
$file = $this->path($kirby).'/themes/'.$name.'.css';
//
// if (! $fake) {
$cli->make($file, __DIR__.'/stubs/theme.stub');
// }
//

if (! $fake) {
$cli->make($file, __DIR__.'/stubs/theme.stub');
}

$cli->success('Courier theme was created.');
}

Expand Down
21 changes: 14 additions & 7 deletions src/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ abstract class Mailable implements Sendable

public function __construct()
{
$this->setAddress(
App::instance()->option('beebmx.kirby-courier.from.address', 'hello@example.com'),
App::instance()->option('beebmx.kirby-courier.from.name', 'Example'),
'from'
);

$this->subject = App::instance()->option('beebmx.kirby-courier.message.subject', 'Message from courier');
$this->logo = $this->getLogo();

Expand Down Expand Up @@ -125,6 +119,14 @@ public function from(string $address, ?string $name = null): static
return $this->setAddress($address, $name, 'from');
}

/**
* Determine if the given recipient is set on the mailable.
*/
public function hasFrom(array|string $address, ?string $name = null): bool
{
return $this->hasRecipient($address, $name, 'from');
}

/**
* Set the recipients of the message.
*/
Expand Down Expand Up @@ -419,6 +421,12 @@ protected function buildFrom(): array
return $this->buildFromPreset(['from', 'fromName']);
}

$this->setAddress(
App::instance()->option('beebmx.kirby-courier.from.address', 'hello@example.com'),
App::instance()->option('beebmx.kirby-courier.from.name', 'Example'),
'from'
);

return [
'from' => $this->from[0]['address'],
'fromName' => $this->from[0]['name'],
Expand All @@ -432,7 +440,6 @@ protected function buildRecipients(): array
'cc' => [],
'bcc' => [],
'replyTo' => [],

];

foreach ($recipients as $type => $value) {
Expand Down
26 changes: 26 additions & 0 deletions tests/Feature/MailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@
->toBeInstanceOf(Email::class);
});

it('set a email with default from recipent', function () {
$message = (new Message);

expect($message->send(true))
->from()
->toEqual('hello@example.com');
});

it('can set from recipent', function () {
$message = (new Message)
->from('john@doe.co');

expect($message)
->hasFrom('john@doe.co')
->toBeTrue();
});

it('send a email with from recipent', function () {
$message = (new Message)
->from('john@doe.co');

expect($message->send(true))
->from()
->toEqual('john@doe.co');
});

it('can set single recipent', function () {
$message = (new Message)
->to('john@doe.co');
Expand Down

0 comments on commit 9c82a3f

Please sign in to comment.