Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from ReeceM/master
Browse files Browse the repository at this point in the history
Add mockery objects for non-typed mailable args
  • Loading branch information
Qoraiche authored May 6, 2019
2 parents 8042ce6 + 323fed2 commit 974b3e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ All notable changes to `laravel-mail-editor` will be documented in this file.
## Version 1.1.7

- Moving away templates metadata from DB to a JSON file to avoid production problems.

## Version 1.1.10

- Fixes issues #15, #16
- Adds the ability to have params mocked for a Mailable's constructor where a type isn't available
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"homepage": "https://github.com/Qoraiche/laravel-mail-editor",
"keywords": ["Laravel", "mailEclipse", "mailable-editor", "laravel-mail", "laravel-mailable", "mailable", "markdown"],
"require": {
"illuminate/support": "~5"
"illuminate/support": "~5",
"reecem/mocker": "1.1.*"
},
"require-dev": {
"phpunit/phpunit": "~7.0",
Expand Down
13 changes: 9 additions & 4 deletions src/mailEclipse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use ReflectionClass;
use ReflectionProperty;
use RegexIterator;
use ReeceM\Mocker\ReflectionMockery;

class mailEclipse
{
Expand Down Expand Up @@ -623,6 +624,8 @@ static public function handleMailableViewDataArgs($mailable)
$reflection = new ReflectionClass($mailable);

$params = $reflection->getConstructor()->getParameters();

$mocked = new ReflectionMockery($reflection);

DB::beginTransaction();

Expand Down Expand Up @@ -686,9 +689,11 @@ static public function handleMailableViewDataArgs($mailable)


} else {

$filteredparams[] = $arg;

try {
$filteredparams[] = $mocked->get($arg);
} catch (\Exception $e) {
$filteredparams[] = $arg;
}
}

}
Expand Down Expand Up @@ -853,4 +858,4 @@ static public function renderPreview($simpleview = false, $view, $template = fal
}

}
}
}

0 comments on commit 974b3e4

Please sign in to comment.