Skip to content

Commit

Permalink
Fix tests failing on PHP7
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Schmidt authored and c960657 committed May 10, 2016
1 parent 68f50da commit 0185781
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -23,6 +23,5 @@ matrix:
- php: 7.0
- php: hhvm
allow_failures:
- php: 7.0
- php: hhvm
fast_finish: true
Expand Up @@ -48,7 +48,7 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC
$strlen = strlen($string);
// % and / are CPU intensive, so, maybe find a better way
$ignored = $strlen % $this->_width;
$ignoredChars = substr($string, -$ignored);
$ignoredChars = $ignored ? substr($string, -$ignored) : '';
$currentMap = $this->_width;

return ($strlen - $ignored) / $this->_width;
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/CharacterStream/NgCharacterStream.php
Expand Up @@ -215,7 +215,7 @@ public function read($length)
*
* @param int $length
*
* @return integer[]
* @return int[]
*/
public function readBytes($length)
{
Expand Down
Expand Up @@ -11,6 +11,11 @@ public function setUp()
$this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
}

public function tearDown()
{
Swift_Preferences::getInstance()->setQPDotEscape(false);
}

public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
Expand Down Expand Up @@ -144,8 +149,6 @@ public function testDotStuffingEncodingAndDecodingSamplesFromDiConfiguredInstanc
// Enable DotEscaping
Swift_Preferences::getInstance()->setQPDotEscape(true);
$this->testEncodingAndDecodingSamplesFromDiConfiguredInstance();
// Disable DotStuffing to continue
Swift_Preferences::getInstance()->setQPDotEscape(false);
}

private function _createEncoderFromContainer()
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/Swift/Events/SimpleEventDispatcherTest.php
Expand Up @@ -87,7 +87,7 @@ public function testListenersAreOnlyCalledIfImplementingCorrectInterface()
$evt = $this->_dispatcher->createSendEvent($transport, $message);

$targetListener = $this->getMock('Swift_Events_SendListener');
$otherListener = $this->getMock('Swift_Events_TransportChangeListener');
$otherListener = $this->getMock('DummyListener');

$this->_dispatcher->bindEventListener($targetListener);
$this->_dispatcher->bindEventListener($otherListener);
Expand Down Expand Up @@ -133,3 +133,10 @@ private function _createDispatcher(array $map)
return new Swift_Events_SimpleEventDispatcher($map);
}
}

class DummyListener implements Swift_Events_EventListener
{
public function sendPerformed(Swift_Events_SendEvent $evt)
{
}
}

0 comments on commit 0185781

Please sign in to comment.