Skip to content

Commit

Permalink
Upgrade phpunit (#8)
Browse files Browse the repository at this point in the history
* upgrade phpunit, switching to getMockBuilder calls as needed
* fixes some non-well formed numeric value errors on my machine
* All tests converted to XML suites, all passing on local machine
* Some fixes for the errors in php 5.6 run
* Removing hhvm from runs - Tests don’t pass, take forever, and we don’t use hhvm, so not going to
address them.
  • Loading branch information
aripringle authored Jan 12, 2018
1 parent e76b1fe commit b1152f5
Show file tree
Hide file tree
Showing 129 changed files with 2,978 additions and 986 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ tests/Zend/OpenId/_files/*
tests/Zend/Translate/Adapter/_files/zend_cache---internal-metadatas---testid
tests/Zend/Translate/Adapter/_files/zend_cache---testid
tests/TestConfiguration.php
tests/Zend/Session/_files/*
tests/Zend/Cache/zend_cache_tmp_dir_*
vendor/*
composer.lock
bin/dbunit
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ php:
- 7
- 7.1
- 7.2
- hhvm

env: TMPDIR=/tmp

Expand Down Expand Up @@ -37,4 +36,3 @@ script:
matrix:
allow_failures:
- php: 7.2
- php: hhvm
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/phpunit": "5.*",
"phpunit/dbunit": "1.3.*"
},
"archive": {
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Validate/File/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ protected function _fromByteString($size)
$value = substr($value, 0, -1);
}

$value = trim($value);

switch (strtoupper($type)) {
case 'Y':
$value *= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024);
Expand Down
1 change: 1 addition & 0 deletions tests/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@
// Suppress DateTime warnings
date_default_timezone_set(@date_default_timezone_get());

define('PHPUnit_MAIN_METHOD', 'dontuse');
12 changes: 8 additions & 4 deletions tests/Zend/Application/Resource/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setUp()

public function testSetSaveHandler()
{
$saveHandler = $this->getMock('Zend_Session_SaveHandler_Interface');
$saveHandler = $this->getMockBuilder('Zend_Session_SaveHandler_Interface')->getMock();

$this->resource->setSaveHandler($saveHandler);
$this->assertSame($saveHandler, $this->resource->getSaveHandler());
Expand All @@ -54,7 +54,9 @@ public function testSetSaveHandler()
public function testSetSaveHandlerString()
{
$saveHandlerClassName = 'Zend_Application_Resource_SessionTestHandlerMock1';
$saveHandler = $this->getMock('Zend_Session_SaveHandler_Interface', array(), array(), $saveHandlerClassName);
$saveHandler = $this->getMockBuilder('Zend_Session_SaveHandler_Interface')
->setMockClassName($saveHandlerClassName)
->getMock();

$this->resource->setSaveHandler($saveHandlerClassName);

Expand All @@ -64,7 +66,9 @@ public function testSetSaveHandlerString()
public function testSetSaveHandlerArray()
{
$saveHandlerClassName = 'Zend_Application_Resource_SessionTestHandlerMock2';
$saveHandler = $this->getMock('Zend_Session_SaveHandler_Interface', array(), array(), $saveHandlerClassName);
$saveHandler = $this->getMockBuilder('Zend_Session_SaveHandler_Interface')
->setMockClassName($saveHandlerClassName)
->getMock();

$this->resource->setSaveHandler(array('class' => $saveHandlerClassName));

Expand Down Expand Up @@ -93,7 +97,7 @@ public function testInitSetsSaveHandler()
{
Zend_Session::$_unitTestEnabled = true;

$saveHandler = $this->getMock('Zend_Session_SaveHandler_Interface');
$saveHandler = $this->getMockBuilder('Zend_Session_SaveHandler_Interface')->getMock();

$this->resource->setSaveHandler($saveHandler);

Expand Down
12 changes: 12 additions & 0 deletions tests/Zend/Auth/Adapter/DbTable/BasicSqliteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ class Zend_Auth_Adapter_DbTable_BasicSqliteTest extends PHPUnit_Framework_TestCa
*/
public function setUp()
{
if (!defined('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED') ||
constant('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED') === false) {
$this->markTestSkipped('Tests are not enabled in TestConfiguration.php');
return;
} else if (!extension_loaded('pdo')) {
$this->markTestSkipped("Extension 'PDO' is not loaded");
return;
} else if (!in_array('sqlite', PDO::getAvailableDrivers())) {
$this->markTestSkipped("PDO driver 'sqlite' is not available");
return;
}

$this->_setupDbAdapter();
$this->_setupAuthAdapter();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/Auth/Adapter/Http/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function testBadDigestRequest()
protected function _doAuth($clientHeader, $scheme)
{
// Set up stub request and response objects
$request = $this->getMock('Zend_Controller_Request_Http');
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$response = new Zend_Controller_Response_Http;
$response->setHttpResponseCode(200);
$response->headersSentThrowsException = false;
Expand Down
18 changes: 9 additions & 9 deletions tests/Zend/Auth/Adapter/Http/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ public function testAuthenticateArgs()
// Good, it threw an exception
}

$request = $this->getMock('Zend_Controller_Request_Http');
$response = $this->getMock('Zend_Controller_Response_Http');
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$response = $this->getMockBuilder('Zend_Controller_Response_Http')->getMock();

// If this throws an exception, it fails
$a->setRequest($request)
Expand All @@ -224,8 +224,8 @@ public function testAuthenticateArgs()

public function testNoResolvers()
{
$request = $this->getMock('Zend_Controller_Request_Http');
$response = $this->getMock('Zend_Controller_Response_Http');
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$response = $this->getMockBuilder('Zend_Controller_Response_Http')->getMock();

// Stub request for Basic auth
$request->expects($this->any())
Expand All @@ -245,7 +245,7 @@ public function testNoResolvers()
}

// Stub request for Digest auth, must be reseted (recreated)
$request = $this->getMock('Zend_Controller_Request_Http');
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$request->expects($this->any())
->method('getHeader')
->will($this->returnValue('Digest <followed by a space caracter'));
Expand All @@ -265,8 +265,8 @@ public function testNoResolvers()

public function testWrongResolverUsed()
{
$response = $this->getMock('Zend_Controller_Response_Http');
$request = $this->getMock('Zend_Controller_Request_Http');
$response = $this->getMockBuilder('Zend_Controller_Response_Http')->getMock();
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$request->expects($this->any())
->method('getHeader')
->will($this->returnValue('Basic <followed by a space caracter')); // A basic Header will be provided by that request
Expand All @@ -282,8 +282,8 @@ public function testWrongResolverUsed()

public function testUnsupportedScheme()
{
$response = $this->getMock('Zend_Controller_Response_Http');
$request = $this->getMock('Zend_Controller_Request_Http');
$response = $this->getMockBuilder('Zend_Controller_Response_Http')->getMock();
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$request->expects($this->any())
->method('getHeader')
->will($this->returnValue('NotSupportedScheme <followed by a space caracter'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/Auth/Adapter/Http/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function testBadDigestRequest()
public function _doAuth($clientHeader, $scheme)
{
// Set up stub request and response objects
$request = $this->getMock('Zend_Controller_Request_Http');
$request = $this->getMockBuilder('Zend_Controller_Request_Http')->getMock();
$response = new Zend_Controller_Response_Http;
$response->setHttpResponseCode(200);
$response->headersSentThrowsException = false;
Expand Down
6 changes: 6 additions & 0 deletions tests/Zend/Auth/Adapter/Ldap/OnlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class Zend_Auth_Adapter_Ldap_OnlineTest extends PHPUnit_Framework_TestCase

public function setUp()
{
if (!(defined('TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED')
&& constant('TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED'))) {
$this->markTestSkipped('Zend_Auth_Adapter_Ldap online tests not enabled in TestConfiguration.php');
return;
}

$this->_options = array(
'host' => TESTS_ZEND_LDAP_HOST,
'username' => TESTS_ZEND_LDAP_USERNAME,
Expand Down
11 changes: 9 additions & 2 deletions tests/Zend/Cache/ApcBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public function __construct($name = null, array $data = array(), $dataName = '')

public function setUp($notag = true)
{
if (!defined('TESTS_ZEND_CACHE_APC_ENABLED') ||
constant('TESTS_ZEND_CACHE_APC_ENABLED') === false) {
$this->markTestSkipped('Tests are not enabled in TestConfiguration.php');
return;
} else if (!extension_loaded('apc')) {
$this->markTestSkipped("Extension 'APC' is not loaded");
return;
}

$this->_instance = new Zend_Cache_Backend_Apc(array());
parent::setUp($notag);
}
Expand Down Expand Up @@ -128,5 +137,3 @@ public function testGetMetadatas($notag = true)
}

}


33 changes: 29 additions & 4 deletions tests/Zend/Cache/LibmemcachedBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
class Zend_Cache_LibmemcachedBackendTest extends Zend_Cache_CommonExtendedBackendTest {

protected $_instance;
protected $skipped;

public function __construct($name = null, array $data = array(), $dataName = '')
{
Expand All @@ -50,7 +51,31 @@ public function __construct($name = null, array $data = array(), $dataName = '')

public function setUp($notag = true)
{
$this->skipped = false;

if (!defined('TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED') ||
constant('TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED') === false) {
$this->skipped = true;
$this->markTestSkipped('Tests are not enabled in TestConfiguration.php');
return;
} else if (!extension_loaded('memcached')) {
$this->skipped = true;
$this->markTestSkipped("Extension 'Memcached' is not loaded");
return;
} else {
if (!defined('TESTS_ZEND_CACHE_LIBMEMCACHED_HOST')) {
define('TESTS_ZEND_CACHE_LIBMEMCACHED_HOST', '127.0.0.1');
}
if (!defined('TESTS_ZEND_CACHE_LIBMEMCACHED_PORT')) {
define('TESTS_ZEND_CACHE_LIBMEMCACHED_PORT', 11211);
}
if (!defined('TESTS_ZEND_CACHE_LIBMEMCACHED_WEIGHT')) {
define('TESTS_ZEND_CACHE_LIBMEMCACHED_WEIGHT', 1);
}
}

if(!class_exists('Memcached')) {
$this->skipped = true;
$this->markTestSkipped('Memcached is not installed, skipping test');
return;
}
Expand All @@ -75,8 +100,10 @@ public function tearDown()
{
parent::tearDown();
$this->_instance = null;
// We have to wait after a memcached flush
sleep(1);
if ($this->skipped === false) {
// We have to wait after a memcached flush
sleep(1);
}
}

public function testConstructorCorrectCall()
Expand Down Expand Up @@ -173,5 +200,3 @@ public function testGetFillingPercentageOnEmptyBackend()
}

}


31 changes: 27 additions & 4 deletions tests/Zend/Cache/MemcachedBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
class Zend_Cache_MemcachedBackendTest extends Zend_Cache_CommonExtendedBackendTest {

protected $_instance;
protected $skipped;

public function __construct($name = null, array $data = array(), $dataName = '')
{
Expand All @@ -50,7 +51,29 @@ public function __construct($name = null, array $data = array(), $dataName = '')

public function setUp($notag = true)
{
if (!defined('TESTS_ZEND_CACHE_MEMCACHED_ENABLED') ||
constant('TESTS_ZEND_CACHE_MEMCACHED_ENABLED') === false) {
$this->skipped = true;
$this->markTestSkipped('Tests are not enabled in TestConfiguration.php');
return;
} else if (!extension_loaded('memcache')) {
$this->skipped = true;
$this->markTestSkipped("Extension 'memcache' is not loaded");
return;
} else {
if (!defined('TESTS_ZEND_CACHE_MEMCACHED_HOST')) {
define('TESTS_ZEND_CACHE_MEMCACHED_HOST', '127.0.0.1');
}
if (!defined('TESTS_ZEND_CACHE_MEMCACHED_PORT')) {
define('TESTS_ZEND_CACHE_MEMCACHED_PORT', 11211);
}
if (!defined('TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT')) {
define('TESTS_ZEND_CACHE_MEMCACHED_PERSISTENT', true);
}
}

if(!class_exists('Memcached')) {
$this->skipped = true;
$this->markTestSkipped('Memcached is not installed, skipping test');
return;
}
Expand All @@ -76,8 +99,10 @@ public function tearDown()
{
parent::tearDown();
unset($this->_instance);
// We have to wait after a memcache flush
sleep(1);
if ($this->skipped === false) {
// We have to wait after a memcache flush
sleep(1);
}
}

public function testConstructorCorrectCall()
Expand Down Expand Up @@ -174,5 +199,3 @@ public function testGetFillingPercentageOnEmptyBackend()
}

}


11 changes: 9 additions & 2 deletions tests/Zend/Cache/SqliteBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public function __construct($name = null, array $data = array(), $dataName = '')

public function setUp($notag = false)
{
if (!defined('TESTS_ZEND_CACHE_SQLITE_ENABLED') ||
constant('TESTS_ZEND_CACHE_SQLITE_ENABLED') === false) {
$this->markTestSkipped('Tests are not enabled in TestConfiguration.php');
return;
} else if (!extension_loaded('sqlite')) {
$this->markTestSkipped("Extension 'sqlite' is not loaded");
return;
}

@mkdir($this->getTmpDir());
$this->_cache_dir = $this->getTmpDir() . DIRECTORY_SEPARATOR;
$this->_instance = new Zend_Cache_Backend_Sqlite(array(
Expand Down Expand Up @@ -128,5 +137,3 @@ public function testRemoveCorrectCallWithVacuumOnMemoryDb()
}

}


Loading

0 comments on commit b1152f5

Please sign in to comment.