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

more than just last email #12

Open
dwenaus opened this issue Dec 19, 2014 · 12 comments · May be fixed by #102
Open

more than just last email #12

dwenaus opened this issue Dec 19, 2014 · 12 comments · May be fixed by #102

Comments

@dwenaus
Copy link

dwenaus commented Dec 19, 2014

would be great to be able to find more than just the last email. I've got a process that sends two emails and I need to be able to check the second.

@captbaritone
Copy link
Owner

Good idea. I don't really have time to work on this right now, but it should be pretty easy for somebody to implement:

  1. Add helper method: nthLastMessage(n)
  2. Make lastMessage() call this under the hood
  3. Add analogous ...inNthLastEmail... methods to match the existing ...inLastEmail... methods.
  4. Add documentation.

Pull request would be most welcome

@drakakisgeo
Copy link

I wrote something like this, when I find some time I'll make a pull request. In the meantime feel free to use it from here https://gist.github.com/lollypopgr/591649190564fe57a4cd

@captbaritone
Copy link
Owner

Looks good. I'll merge if you PR.

@dwenaus
Copy link
Author

dwenaus commented May 27, 2015

Wow. This is fantastic! Do ya'll need help adding this to the repo?

@captbaritone
Copy link
Owner

@dwenaus If you want to open a PR, I'd merge it.

@captbaritone
Copy link
Owner

@dwenaus and @drakakisgeo is there still any interest in this, or should I close the issue?

@dwenaus
Copy link
Author

dwenaus commented Feb 10, 2016

Yes, still interested :)
On Tue, Feb 9, 2016 at 12:41 PM Jordan Eldredge [email protected]
wrote:

@dwenaus https://github.com/dwenaus and @drakakisgeo
https://github.com/drakakisgeo is there still any interest in this, or
should I close the issue?


Reply to this email directly or view it on GitHub
#12 (comment)
.

@stell
Copy link

stell commented Aug 10, 2021

It's been only five years :) Is merging still possible?

@Jamesking56
Copy link
Collaborator

@stell Waiting for a PR in the repo...

@Jamesking56 Jamesking56 added this to the v3.0.0 milestone Sep 10, 2021
@wazum
Copy link
Contributor

wazum commented Aug 26, 2022

I'm working on a PR, but I don't know how useful the tests are for this.

There's a non-functional method in the test right now (I guess that's the reason it's not active, aka has no test prefix):
\Codeception\Util\MailCatcherTest::lastMessageFrom
that would test something similar.

The problem lies with the Guzzle MockHandler in combination with \Codeception\Module\MailCatcher::emailFromId. I would have to specify exactly the response I expect for the handler anyway, so the test is pretty much worthless.

A test for seeInNthEmail would look something like this:

    public function testSeeInNthEmail()
    {
        $interestingMessage = [
            'id' => 2,
            'created_at' => date('c'),
            'sender' => '[email protected]',
            'recipients' => ['[email protected]'],
            'subject' => '',
        ];
        $handler = new MockHandler([
            new Response(200, [], json_encode([
                [
                    'id' => 1,
                    'created_at' => date('c'),
                    'sender' => '[email protected]',
                    'recipients' => ['[email protected]'],
                    'subject' => '',
                ],
                $interestingMessage
            ])),
            // \Codeception\Module\MailCatcher::emailFromId
            // $this->mailcatcher->get("/messages/{$id}.json");
            new Response(200, [], json_encode($interestingMessage)),
            // \Codeception\Module\MailCatcher::emailFromId
            // $plainMessage = $this->mailcatcher->get("/messages/{$id}.source");
            new Response(200, [], json_encode($interestingMessage))
        ]);
        $client = new Client(['handler' => $handler]);

        $mailcatcher = new MailCatcherTest_TestClass();
        $mailcatcher->setClient($client);

        $message = $mailcatcher->nthMessage(2);
        $this->assertEquals('2', $message->getId());
        $this->assertEquals(['[email protected]'], $message->getRecipients());
    }

The only thing that is tested here is if there are two items in the first response (if the right index in the nthMessage method is chosen).

Should I add such tests @Jamesking56?

@Jamesking56
Copy link
Collaborator

@wazum I think a weak test is better than no test at all, so yes I think still would be worth adding

wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 10, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
@wazum wazum linked a pull request Sep 10, 2022 that will close this issue
wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 11, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 11, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 11, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 11, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
wazum added a commit to wazum/codeception-mailcatcher-module that referenced this issue Sep 11, 2022
Add support for sender and recipient queries.

Resolves: captbaritone#12, captbaritone#98
@wazum
Copy link
Contributor

wazum commented Sep 27, 2022

Has anybody time to review my pull request?
The feature has been requested for years and I finally implemented it. Would be nice to have it in a tagged version.

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

Successfully merging a pull request may close this issue.

7 participants