Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #541 from mhujer/php7-fixes
Browse files Browse the repository at this point in the history
Fixed errors in tests on PHP7
  • Loading branch information
froschdesign committed Mar 31, 2015
2 parents 276db36 + 73480b2 commit 0cef832
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
16 changes: 0 additions & 16 deletions library/Zend/Serializer/Adapter/PythonPickle.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class Zend_Serializer_Adapter_PythonPickle extends Zend_Serializer_Adapter_Adapt
const OP_BINBYTES = 'B'; // push bytes; counted binary string argument
const OP_SHORT_BINBYTES = 'C'; // " " ; " " " " < 256 bytes

/**
* @var bool Whether or not this is a PHP 6 binary
*/
protected static $_isPhp6 = null;

/**
* @var bool Whether or not the system is little-endian
*/
Expand Down Expand Up @@ -155,9 +150,6 @@ public function __construct($opts=array())
if (self::$_isLittleEndian === null) {
self::$_isLittleEndian = (pack('l', 1) === "\x01\x00\x00\x00");
}
if (self::$_isPhp6 === null) {
self::$_isPhp6 = !version_compare(PHP_VERSION, '6.0.0', '<');
}

$this->_marker = new stdClass();
}
Expand Down Expand Up @@ -1103,10 +1095,6 @@ protected function _loadUnicode()
$pattern = '/\\\\u([a-fA-F0-9]{4})/u'; // \uXXXX
$data = preg_replace_callback($pattern, array($this, '_convertMatchingUnicodeSequence2Utf8'), $data);

if (self::$_isPhp6) {
$data = unicode_decode($data, 'UTF-8');
}

$this->_stack[] = $data;
}

Expand Down Expand Up @@ -1172,10 +1160,6 @@ protected function _loadBinUnicode()
list(, $n) = unpack('l', $n);
$data = $this->_read($n);

if (self::$_isPhp6) {
$data = unicode_decode($data, 'UTF-8');
}

$this->_stack[] = $data;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Zend/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5522,7 +5522,7 @@ public function testUsePhpNFormat()
Zend_Date::setOptions(array('format_type' => 'php'));

date_default_timezone_set('GMT');
$date = new Zend_Date(mktime(20,10,0,09,20,2009));
$date = new Zend_Date(mktime(20,10,0,9,20,2009));
$this->assertSame(gmdate('w',$date->getTimestamp()), $date->toString( 'w'));
$this->assertSame(gmdate('d',$date->getTimestamp()), $date->toString( 'd'));
$this->assertSame(gmdate('D',$date->getTimestamp()), $date->toString('D', 'en'));
Expand Down Expand Up @@ -5561,7 +5561,7 @@ public function testUsePhpNFormat()
$this->assertSame(gmdate('U',$date->getTimestamp()), $date->toString( 'U'));

date_default_timezone_set('Indian/Maldives');
$date = new Zend_Date(mktime(20,10,0,09,20,2009));
$date = new Zend_Date(mktime(20,10,0,9,20,2009));
$this->assertSame(date('w',$date->getTimestamp()), $date->toString( 'w'));
$this->assertSame(date('d',$date->getTimestamp()), $date->toString( 'd'));
$this->assertSame(date('D',$date->getTimestamp()), $date->toString('D', 'en'));
Expand Down
7 changes: 7 additions & 0 deletions tests/Zend/Log/Writer/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
class Zend_Log_Writer_AbstractTest extends PHPUnit_Framework_TestCase
{
/**
* @var Zend_Log_Writer_Abstract
*/
protected $_writer;

public static function main()
Expand All @@ -55,6 +58,10 @@ protected function setUp()
*/
public function testSetFormatter()
{
if (version_compare(phpversion(), '7', '>=')) {
$this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
}

require_once 'Zend/Log/Formatter/Simple.php';
$this->_writer->setFormatter(new Zend_Log_Formatter_Simple());
$this->setExpectedException('PHPUnit_Framework_Error');
Expand Down
4 changes: 4 additions & 0 deletions tests/Zend/Log/Writer/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public function testFactory()
*/
public function testThrowStrictSetFormatter()
{
if (version_compare(phpversion(), '7', '>=')) {
$this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
}

try {
$this->writer->setFormatter(new StdClass());
} catch (Exception $e) {
Expand Down
3 changes: 3 additions & 0 deletions tests/Zend/Serializer/Adapter/PhpCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public function testUnserializeObject()

public function testUnserialzeInvalid()
{
if (version_compare(phpversion(), '7', '>=')) {
$this->markTestSkipped('Evaling of invalid input is PHP Parse error in PHP7+');
}
$value = 'not a serialized string';
$this->setExpectedException('Zend_Serializer_Exception');
$this->_adapter->unserialize($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public function testGetTokenFromCache()

public function testSetTokenToCache1stParamException()
{
if (version_compare(phpversion(), '7', '>=')) {
$this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
}

try {
Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::setTokenToCache(
'NotExisting',
Expand All @@ -176,6 +180,10 @@ public function testSetTokenToCache1stParamException()

public function testSetTokenToCache2ndParamException()
{
if (version_compare(phpversion(), '7', '>=')) {
$this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
}

try {
Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::setTokenToCache(
'securityToken',
Expand Down

0 comments on commit 0cef832

Please sign in to comment.