Commit a6439b6a authored by Seamus Lee's avatar Seamus Lee

Update test files to use PHPUnit6 notiation for classes

Update for phpunit5 compatability

Add in old catch to see if we get tests to pass

Fix Report Form Test case

Fix last remaining test issues
parent 76143f46
This diff is collapsed.
This diff is collapsed.
......@@ -42,6 +42,7 @@
"symfony/event-dispatcher": "^2.8.44 || ~3.0",
"symfony/filesystem": "^2.8.44 || ~3.0",
"symfony/process": "^2.8.44 || ~3.0",
"symfony/yaml": "^2.8.44 || ~3.0",
"psr/log": "~1.1",
"symfony/finder": "^2.8.44 || ~3.0",
"tecnickcom/tcpdf" : "6.2.*",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a786aecfcc51b68f1ebafb0f43f99d08",
"content-hash": "b37fa5010f8217fd31e83fe60e2ba0a9",
"packages": [
{
"name": "civicrm/civicrm-cxn-rpc",
......@@ -1975,6 +1975,56 @@
"homepage": "https://symfony.com",
"time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/yaml",
"version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "fbf876678e29dc634430dcf0096e216eb0004467"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/fbf876678e29dc634430dcf0096e216eb0004467",
"reference": "fbf876678e29dc634430dcf0096e216eb0004467",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-07-26T09:03:18+00:00"
},
{
"name": "tecnickcom/tcpdf",
"version": "6.2.26",
......
......@@ -381,7 +381,7 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase {
/**
* Generate a mock HTTP client with the expectation that it is never called.
*
* @return CRM_Utils_HttpClient|PHPUnit_Framework_MockObject_MockObject
* @return CRM_Utils_HttpClient|PHPUnit\Framework\MockObject\MockObject
*/
protected function expectNoHttpRequest() {
$mockFunction = $this->mockMethod;
......@@ -396,7 +396,7 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase {
*
* @param $response
*
* @return CRM_Utils_HttpClient|PHPUnit_Framework_MockObject_MockObject
* @return CRM_Utils_HttpClient|PHPUnit\Framework\MockObject\MockObject
*/
protected function expectOneHttpRequest($response) {
$mockFunction = $this->mockMethod;
......
......@@ -4,7 +4,7 @@
* Class CRM_Core_ComposerConfigTest
* @group headless
*/
class CRM_Core_ComposerConfigTest extends \PHPUnit_Framework_TestCase {
class CRM_Core_ComposerConfigTest extends \PHPUnit\Framework\TestCase {
/**
* Assert that `composer.lock` remains as expected.
......
......@@ -323,7 +323,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
*
* @param array $params
*
* @throws PHPUnit_Framework_SkippedTestError
* @throws PHPUnit\Framework\SkippedTestError
*/
public function doPayment($params) {
try {
......
......@@ -154,7 +154,6 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
}
/**
* @expectedException PHPUnit_Framework_AssertionFailedError
* @dataProvider badDataProvider
* @param $reportClass
* @param $inputParams
......@@ -170,7 +169,15 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
$reportCsvArray = $this->getArrayFromCsv($reportCsvFile);
$expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}");
$this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
try {
$this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
}
catch (PHPUnit\Framework\AssertionFailedError $e) {
/* OK */
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
/* OK */
}
}
/**
......
......@@ -8,7 +8,7 @@ use Civi\Angular\Page\Main;
*
* @group headless
*/
class ExampleHookTest extends \PHPUnit_Framework_TestCase implements HeadlessInterface, HookInterface {
class ExampleHookTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface {
/**
* @var \CRM_Contact_DAO_Contact
......
......@@ -9,7 +9,7 @@ namespace Civi\Test;
*
* @group headless
*/
class ExampleTransactionalTest extends \PHPUnit_Framework_TestCase implements HeadlessInterface, TransactionalInterface {
class ExampleTransactionalTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, TransactionalInterface {
/**
* @var array
......
......@@ -9,7 +9,7 @@
* Note: If you need to work as a different user, try using `cv()` or
* a web-service.
*/
class CiviEndToEndTestCase extends PHPUnit_Framework_TestCase implements \Civi\Test\EndToEndInterface {
class CiviEndToEndTestCase extends PHPUnit\Framework\TestCase implements \Civi\Test\EndToEndInterface {
public static function setUpBeforeClass() {
CRM_Core_Config::singleton(1, 1);
......
......@@ -43,7 +43,7 @@
/**
* Class CiviMailUtils
*/
class CiviMailUtils extends PHPUnit_Framework_TestCase {
class CiviMailUtils extends PHPUnit\Framework\TestCase {
/**
* @var mixed current outbound email option
......
......@@ -31,7 +31,7 @@
*
* @package CiviCRM
*/
class CiviTestSuite extends PHPUnit_Framework_TestSuite {
class CiviTestSuite extends PHPUnit\Framework\TestSuite {
/**
* Simple name based constructor.
......@@ -89,7 +89,7 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite {
// also split AllTests to All Tests
$name = str_replace('AllTests', 'All Tests', $name);
$suite = new PHPUnit_Framework_TestSuite($name);
$suite = new PHPUnit\Framework\TestSuite($name);
$this->addAllTests($suite, $myfile,
new SplFileInfo(dirname($myfile))
);
......@@ -99,7 +99,7 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite {
/**
* Add all test classes *Test and all test suites *Tests in subdirectories
*
* @param PHPUnit_Framework_TestSuite $suite
* @param PHPUnit\Framework\TestSuite $suite
* Test suite object to add tests to
* @param $myfile
* @param SplFileInfo $dirInfo
......@@ -108,7 +108,7 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite {
* @return void
*/
protected function addAllTests(
PHPUnit_Framework_TestSuite &$suite,
PHPUnit\Framework\TestSuite &$suite,
$myfile, SplFileInfo $dirInfo
) {
//echo get_class($this)."::addAllTests($myfile,".$dirInfo->getRealPath().")\n";
......
......@@ -195,7 +195,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
// FIXME: loosen coupling
_civix_phpunit_setUp();
}
if (version_compare(PHPUnit_Runner_Version::id(), '5', '>=')) {
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '5', '>=')) {
$this->mockMethod = 'createMock';
}
elseif (class_exists('PHPUnit\Runner\Version') && version_compare(PHPUnit\Runner\Version::id(), '6', '>=')) {
$this->mockMethod = 'createMock';
}
}
......
......@@ -10,7 +10,7 @@
* names. Each name may be a class (eg "MyFirstTest") or a method
* (eg "MyFirstTest::testFoo").
*/
class EnvTests extends \PHPUnit_Framework_TestSuite {
class EnvTests extends \PHPUnit\Framework\TestSuite {
/**
* @return \EnvTests
......
......@@ -42,7 +42,7 @@
/**
* Class HelloTest
*/
class HelloTest extends PHPUnit_Framework_TestCase {
class HelloTest extends PHPUnit\Framework\TestCase {
/**
* contains the object handle of the string class
* @var string
......
......@@ -471,7 +471,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
* @dataProvider entities
* confirm that with check permissions we don't get entities
* @param $entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testEntitiesGetCoreACLLimitingCheck($entity) {
$this->setupCoreACL();
......@@ -487,7 +487,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
* @dataProvider entities
* Function tests that an empty where hook returns no results
* @param string $entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testEntityGetNoResultsHook($entity) {
$this->markTestIncomplete('hook acls only work with contacts so far');
......
......@@ -126,7 +126,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
*
* @param $reportID
*
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testReportTemplateSelectWhere($reportID) {
$this->hookClass->setHook('civicrm_selectWhereClause', array($this, 'hookSelectWhere'));
......@@ -253,7 +253,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
*
* @param $reportID
*
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testReportTemplateGetRowsAllReports($reportID) {
//$reportID = 'logging/contact/summary';
......@@ -311,7 +311,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
*
* @param $reportID
*
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testReportTemplateGetRowsAllReportsACL($reportID) {
if (stristr($reportID, 'has existing issues')) {
......@@ -330,7 +330,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
*
* @param $reportID
*
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testReportTemplateGetStatisticsAllReports($reportID) {
if (stristr($reportID, 'has existing issues')) {
......
......@@ -796,6 +796,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
catch (ArgumentCountError $e) {
/* ok */
}
catch (PHPUnit\Framework\Error $e) {
/* ok */
}
catch (PHPUnit_Framework_Error $e) {
/* ok */
}
......@@ -1181,7 +1184,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
* hence FKs only set by createTestObject when required. e.g parent_id on campaign is not being followed through
* Currency - only seems to support US
* @param $entityName
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testByIDAlias_get($entityName) {
if (in_array($entityName, self::toBeSkipped_automock(TRUE))) {
......@@ -1285,7 +1288,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
*
* Check that create doesn't work with an invalid
* @param $Entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testInvalidSort_get($Entity) {
$invalidEntitys = array('ActivityType', 'Setting', 'System');
......@@ -1300,7 +1303,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
*
* Check that create doesn't work with an invalid
* @param $Entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testValidSortSingleArrayById_get($Entity) {
$invalidEntitys = array('ActivityType', 'Setting', 'System');
......@@ -1327,7 +1330,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
*
* Check that create doesn't work with an invalid
* @param $Entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testInvalidID_create($Entity) {
// turn test off for noew
......@@ -1605,6 +1608,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
catch (ArgumentCountError $e) {
/* ok */
}
catch (PHPUnit\Framework\Error $e) {
/* ok */
}
catch (PHPUnit_Framework_Error $e) {
/* ok */
}
......@@ -1627,7 +1633,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
/**
* @dataProvider entities_delete
* @param $Entity
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testInvalidID_delete($Entity) {
$result = $this->callAPIFailure($Entity, 'Delete', array('id' => 999999));
......@@ -1651,7 +1657,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
* hence FKs only set by createTestObject when required. e.g parent_id on campaign is not being followed through
* Currency - only seems to support US
* @param $entityName
* @throws \PHPUnit_Framework_IncompleteTestError
* @throws \PHPUnit\Framework\IncompleteTestError
*/
public function testByID_delete($entityName) {
// turn test off for noew
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment