Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MockEmail class #2788

Merged
merged 4 commits into from
Apr 6, 2020
Merged

add MockEmail class #2788

merged 4 commits into from
Apr 6, 2020

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Apr 2, 2020

Based on @MGatner comment at #2785 (comment)

Checklist:

  • Securely signed commits
  • Unit testing, with >80% coverage

@samsonasik
Copy link
Member Author

I've added unit test for $autoClear parameter in send() method.

@lonnieezell
Copy link
Member

This looks good. We do need a way to incorporate testing failures, though, too. Not sure what the preferred way here would be, whether it's another method that specifies the result, or another parameter I'm not too concerned.

@MGatner thoughts?

@MGatner
Copy link
Member

MGatner commented Apr 3, 2020

Yes I think this is a great start. I was thinking of something like this:

	/**
	 * Record of mock emails sent.
	 * @var array
	 */
	public $archive = [];
...
	public function send($autoClear = true)
	{
...
		$this->archive[] = get_object_vars($this);

		return true;
	}

That way a test could check $mockEmail->archive to see the actual emails that were "sent". I don't think that code will work because of the scope but you get the idea.

@samsonasik
Copy link
Member Author

@MGatner I've added $archive property for save properties on send() method called.

@samsonasik
Copy link
Member Author

I realized that clear() methods clear the properties, so, I placed the archive saving after autoClear check.

@MGatner
Copy link
Member

MGatner commented Apr 6, 2020

Thanks @samsonasik this is precisely what I'd hoped for! Glad to see it wasn't too complicated either.

@MGatner MGatner merged commit 2a2cd57 into codeigniter4:develop Apr 6, 2020
@samsonasik samsonasik deleted the mock-email branch April 6, 2020 14:34
@MGatner
Copy link
Member

MGatner commented Jun 18, 2020

I realized that clear() methods clear the properties, so, I placed the archive saving after autoClear check.

@samsonasik I'm working on some tweaks to Email testing... Isn't the precisely what we don't want? Setting $this->archive = get_object_vars($this); after clear() means the values will always be blank. Should be before like you originally had it, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants