From 1c91e01e31749bbb7521db157e97fbaf1d01e05a Mon Sep 17 00:00:00 2001 From: ReeceM Date: Mon, 29 Apr 2019 14:03:16 +0200 Subject: [PATCH 1/8] feat: add mocker package for the mails --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26f0300..bf3f2e2 100644 --- a/composer.json +++ b/composer.json @@ -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.0.*" }, "require-dev": { "phpunit/phpunit": "~7.0", From 80f0e6c7b69d291df0aed88fc3455f6030580752 Mon Sep 17 00:00:00 2001 From: ReeceM Date: Mon, 29 Apr 2019 14:04:51 +0200 Subject: [PATCH 2/8] fix: fixes #15, #16 by mocking constructor args --- src/mailEclipse.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mailEclipse.php b/src/mailEclipse.php index e4ec8bc..246b395 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -15,6 +15,7 @@ use ReflectionClass; use ReflectionProperty; use RegexIterator; +use ReeceM\Mocker\ReflectionMockery; class mailEclipse { @@ -623,6 +624,11 @@ static public function handleMailableViewDataArgs($mailable) $reflection = new ReflectionClass($mailable); $params = $reflection->getConstructor()->getParameters(); + + /** + * Pass the $reflection instance + */ + $mock = new ReflectionMockery($reflection); DB::beginTransaction(); @@ -686,9 +692,10 @@ static public function handleMailableViewDataArgs($mailable) } else { - - $filteredparams[] = $arg; - + /** + * For all the things not found, mock it. + */ + $filteredparams[] = $mock->get($arg); } } From 6dfc51fb82ec0f1f14d6f2e79808c78de28ae1b3 Mon Sep 17 00:00:00 2001 From: ReeceM Date: Mon, 29 Apr 2019 14:17:28 +0200 Subject: [PATCH 3/8] update changelog to next version based on repo tags --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 4b6b176..70cb679 100644 --- a/changelog.md +++ b/changelog.md @@ -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 From 1a6c8aa12646f4514c755d284817b5a34e7f6e1b Mon Sep 17 00:00:00 2001 From: Yassine Qr Date: Tue, 30 Apr 2019 00:52:04 +0100 Subject: [PATCH 4/8] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26f0300..bf3f2e2 100644 --- a/composer.json +++ b/composer.json @@ -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.0.*" }, "require-dev": { "phpunit/phpunit": "~7.0", From ab3d866fd1d7c4ba5a68e5f37197afba873553b7 Mon Sep 17 00:00:00 2001 From: Yassine Qr Date: Tue, 30 Apr 2019 00:53:12 +0100 Subject: [PATCH 5/8] Update mailEclipse.php --- src/mailEclipse.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mailEclipse.php b/src/mailEclipse.php index e4ec8bc..ca02529 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -15,6 +15,7 @@ use ReflectionClass; use ReflectionProperty; use RegexIterator; +use ReeceM\Mocker\ReflectionMockery; class mailEclipse { @@ -853,4 +854,4 @@ static public function renderPreview($simpleview = false, $view, $template = fal } } -} \ No newline at end of file +} From c47271d8db02a642955cce65e540305d4fda0503 Mon Sep 17 00:00:00 2001 From: Yassine Qr Date: Tue, 30 Apr 2019 00:54:16 +0100 Subject: [PATCH 6/8] Update mailEclipse.php --- src/mailEclipse.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mailEclipse.php b/src/mailEclipse.php index ca02529..71565c8 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -624,6 +624,8 @@ static public function handleMailableViewDataArgs($mailable) $reflection = new ReflectionClass($mailable); $params = $reflection->getConstructor()->getParameters(); + + $mock = new ReflectionMockery($reflection); DB::beginTransaction(); From 18ec479ecf2951c119f47b22118fefce7774d419 Mon Sep 17 00:00:00 2001 From: Yassine Qr Date: Sun, 5 May 2019 23:54:53 +0000 Subject: [PATCH 7/8] Update mocker version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf3f2e2..b7205e3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "keywords": ["Laravel", "mailEclipse", "mailable-editor", "laravel-mail", "laravel-mailable", "mailable", "markdown"], "require": { "illuminate/support": "~5", - "reecem/mocker": "1.0.*" + "reecem/mocker": "1.1.*" }, "require-dev": { "phpunit/phpunit": "~7.0", From 323fed214be07593cb7ed1f99498e4ddbcaf7153 Mon Sep 17 00:00:00 2001 From: ReeceM Date: Mon, 6 May 2019 18:39:41 +0200 Subject: [PATCH 8/8] feat: wip: add mockery support with try catch --- src/mailEclipse.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mailEclipse.php b/src/mailEclipse.php index dbe3c6f..226acb6 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -625,7 +625,7 @@ static public function handleMailableViewDataArgs($mailable) $params = $reflection->getConstructor()->getParameters(); - $mock = new ReflectionMockery($reflection); + $mocked = new ReflectionMockery($reflection); DB::beginTransaction(); @@ -689,10 +689,11 @@ static public function handleMailableViewDataArgs($mailable) } else { - /** - * For all the things not found, mock it. - */ - $filteredparams[] = $mock->get($arg); + try { + $filteredparams[] = $mocked->get($arg); + } catch (\Exception $e) { + $filteredparams[] = $arg; + } } }