Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
fixed risky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 15, 2017
1 parent 5488f41 commit de66061
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 45 deletions.
2 changes: 2 additions & 0 deletions tests/acceptance/Swift/DependencyContainerAcceptanceTest.php
Expand Up @@ -16,5 +16,7 @@ public function testNoLookupsFail()
$this->fail($e->getMessage());
}
}
// previous loop would fail if there is an issue
$this->addToAssertionCount(1);
}
}
17 changes: 6 additions & 11 deletions tests/bug/Swift/Bug274Test.php
@@ -1,21 +1,15 @@
<?php

// TODO update test

class Swift_Bug274Test extends \PHPUnit\Framework\TestCase
{
/**
* @expectedException \Swift_IoException
* @expectedMessageException The path cannot be empty
*/
public function testEmptyFileNameAsAttachment()
{
$message = new Swift_Message();
// TODO no longer supported by phpunit test must be modified
// $this->setExpectedException('Swift_IoException', 'The path cannot be empty');
try {
$message->attach(Swift_Attachment::fromPath(''));
} catch (Exception $e) {
if (!is_a($e, 'Swift_IoException')) {
$this->fail('Expected Swift_IoException - The path cannot be empty');
}
}
$message->attach(Swift_Attachment::fromPath(''));
}

public function testNonEmptyFileNameAsAttachment()
Expand All @@ -26,5 +20,6 @@ public function testNonEmptyFileNameAsAttachment()
} catch (Exception $e) {
$this->fail('Path should not be empty');
}
$this->addToAssertionCount(1);
}
}
4 changes: 4 additions & 0 deletions tests/unit/Swift/MessageTest.php
Expand Up @@ -9,6 +9,8 @@ public function testCloning()
$message1_clone = clone $message1;

$this->recursiveObjectCloningCheck($message1, $message2, $message1_clone);
// the test above will fail if the two messages are not identical
$this->addToAssertionCount(1);
}

public function testCloningWithSigners()
Expand All @@ -22,6 +24,8 @@ public function testCloningWithSigners()
$message1_clone = clone $message1;

$this->recursiveObjectCloningCheck($message1, $message2, $message1_clone);
// the test above will fail if the two messages are not identical
$this->addToAssertionCount(1);
}

public function testBodySwap()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Swift/Mime/EmbeddedFileTest.php
Expand Up @@ -5,7 +5,8 @@ class Swift_Mime_EmbeddedFileTest extends Swift_Mime_AttachmentTest
{
public function testNestingLevelIsAttachment()
{
//Overridden
// previous loop would fail if there is an issue
$this->addToAssertionCount(1);
}

public function testNestingLevelIsEmbedded()
Expand Down
43 changes: 18 additions & 25 deletions tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php
Expand Up @@ -99,16 +99,14 @@ public function testIdLeftCanBeDotAtom()
$this->assertEquals('<a.b+&%$.c@d>', $header->getFieldBody());
}

/**
* @expectedException \Exception
* @expectedMessageException "a b c" is not valid id-left
*/
public function testInvalidIdLeftThrowsException()
{
try {
$header = $this->getHeader('References');
$header->setId('a b c@d');
$this->fail(
'Exception should be thrown since "a b c" is not valid id-left.'
);
} catch (Exception $e) {
}
$header = $this->getHeader('References');
$header->setId('a b c@d');
}

public function testIdRightCanBeDotAtom()
Expand All @@ -135,32 +133,27 @@ public function testIdRightCanBeLiteral()
$this->assertEquals('<a@[1.2.3.4]>', $header->getFieldBody());
}

/**
* @expectedException \Exception
* @expectedMessageException "b c d" is not valid id-right
*/
public function testInvalidIdRightThrowsException()
{
try {
$header = $this->getHeader('References');
$header->setId('a@b c d');
$this->fail(
'Exception should be thrown since "b c d" is not valid id-right.'
);
} catch (Exception $e) {
}
$header = $this->getHeader('References');
$header->setId('a@b c d');
}

/**
* @expectedException \Exception
* @expectedMessageException "abc" is does not contain @
*/
public function testMissingAtSignThrowsException()
{
/* -- RFC 2822, 3.6.4.
msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
*/

try {
$header = $this->getHeader('References');
$header->setId('abc');
$this->fail(
'Exception should be thrown since "abc" is does not contain @.'
);
} catch (Exception $e) {
}
$header = $this->getHeader('References');
$header->setId('abc');
}

public function testSetBodyModel()
Expand Down
11 changes: 5 additions & 6 deletions tests/unit/Swift/Mime/Headers/PathHeaderTest.php
Expand Up @@ -17,14 +17,13 @@ public function testSingleAddressCanBeSetAndFetched()
$this->assertEquals('chris@swiftmailer.org', $header->getAddress());
}

/**
* @expectedException \Exception
*/
public function testAddressMustComplyWithRfc2822()
{
try {
$header = $this->getHeader('Return-Path');
$header->setAddress('chr is@swiftmailer.org');
$this->fail('Addresses not valid according to RFC 2822 addr-spec grammar must be rejected.');
} catch (Exception $e) {
}
$header = $this->getHeader('Return-Path');
$header->setAddress('chr is@swiftmailer.org');
}

public function testValueIsAngleAddrWithValidAddress()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Swift/Mime/SimpleMessageTest.php
Expand Up @@ -5,7 +5,8 @@ class Swift_Mime_SimpleMessageTest extends Swift_Mime_MimePartTest
{
public function testNestingLevelIsSubpart()
{
//Overridden
// not relevant
$this->addToAssertionCount(1);
}

public function testNestingLevelIsTop()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Swift/Transport/EsmtpTransportTest.php
Expand Up @@ -49,7 +49,8 @@ public function testEncryptionCanBeSetAndFetched()

public function testStartSendsHeloToInitiate()
{
//Overridden for EHLO instead
// previous loop would fail if there is an issue
$this->addToAssertionCount(1);
}

public function testStartSendsEhloToInitiate()
Expand Down

0 comments on commit de66061

Please sign in to comment.