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

Travis: fix failing tests #172

Merged
merged 5 commits into from
Sep 22, 2017
Merged

Conversation

Slamdunk
Copy link
Collaborator

So, here we are. Comments on code.

return (
'R' === $this->getHeaders()->get('recent')
|| ('' === $this->getHeaders()->get('recent') && '' !== $this->getHeaders()->get('unseen'))
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -48,7 +48,7 @@ private function parseHeader($key, $value)
case 'draft':
// no break
case 'unseen':
return (bool)trim($value);
return $value;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flags can't be force to boolean because they can have multiple values, like recent:

https://secure.php.net/manual/en/function.imap-headerinfo.php

// $this->decodedContent,
// $this->getCharset()
// );
// }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After commenting this code no test fails, and testEncoding7Bit passes: @ddeboer do you have any test case that justify this piece of code?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a fix for #3, so also testSubjectEncoding().

Copy link
Collaborator Author

@Slamdunk Slamdunk Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what changed since november 2013, but the rule is that if removing code doesn't break tests, it's either:

  1. the tests are not enough
  2. the code is unnecessary

But don't be afraid: we need a lot of test cases with different charset to test against, and I will gather and test them, in future PR, of couse before the any next release.

Just not now: before deeping into the charset topic, we need minor improvement like coding standards and re-enable code-coverage; one step at time

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: I hate commented code too and for sure will be removed soon.
One step at time, reminder added: #174

// imap_utf8 doesn't seem to work properly, so use Transcoder instead
$decoded .= Transcoder::create()->transcode($part->text, $charset);
// $decoded .= Transcoder::create()->transcode($part->text, $charset);
$decoded .= $part->text;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Message\Part also headers are affected: when the raw value is used, no test fails and testEncoding7Bit passes. @ddeboer do you have any test case that justify this piece of code?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, so let’s disable it for now.

@@ -101,6 +102,7 @@ public function testDelete()

$message = $this->mailbox->getMessage(3);
$message->delete();
$this->mailbox->expunge();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial bugfix. Manual says:

Marks messages listed in msg_number for deletion. Messages marked for deletion will stay in the mailbox until either imap_expunge() is called or imap_close() is called with the optional parameter CL_EXPUNGE.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only fix this here, this may not be transparent to users. Should we also add a doc comment to Message::delete()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, since delete doesn't delete the message, I suggest:

  1. Rename delete method to markAsDelete
  2. Add to the doc that mailbox::expunge must be called for a complete delete

Reminder: #175

@Slamdunk Slamdunk removed the BC break label Sep 22, 2017
@Slamdunk Slamdunk added this to the 1.0 milestone Sep 22, 2017
. "--$boundary\r\n"
. "Content-Transfer-Encoding: quoted-printable\r\n"
. "Content-Type: text/html; charset=\"windows-1252\"\r\n"
. "\r\n"
. "<html><body>Espa=F1a</body></html>\r\n\r\n"
. "<html><body>Espa=C3=B1a</body></html>\r\n\r\n"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this? The original text was received in a bug report.

Copy link
Collaborator Author

@Slamdunk Slamdunk Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change I was least comfortable with.

Even though F1 is the right UTF-8 code for n with tilde, I was unable to reproduce in a real email the character written like this. Instead every mail agent uses =C3=B1.

I think we need to refactor test assets as a whole:

  1. Write emails within PHP in pure UTF-8
  2. Use an external tool/library/ext to convert them into different charsets
  3. Send them to Dovecot (already done)
  4. Test this library reads the result in UTF-8 (already done)

String concatenation seems too weak to handle the encoding topic properly (in the tests).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. We can use ddeboer/transcoder (or some other lib) for step 2.

Copy link
Collaborator Author

@Slamdunk Slamdunk Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: #176

It have to be said that 21f3817 behavied completely differently from now; something somewhere got broken and testing against Gmail didn't help.

This was referenced Sep 22, 2017
@ddeboer ddeboer merged commit fd1356a into ddeboer:develop Sep 22, 2017
@Slamdunk Slamdunk mentioned this pull request Sep 22, 2017
@Slamdunk Slamdunk deleted the travis_first_fixes branch September 22, 2017 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants