From 5bfce597a92a3b1f84d12f0886c620d425aaba26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 10 Feb 2017 16:20:25 +0100 Subject: [PATCH] [CI] Can we get some faster phpunit execution? (#27113) * Don't backup globals and static attributes * Unset global variable to remove impact on followup tests Signed-off-by: Morris Jobke --- apps/dav/tests/unit/Connector/Sabre/FileTest.php | 3 +++ .../Connector/Sabre/RequestTest/RequestTest.php | 2 ++ .../tests/Controller/ShareAPIControllerTest.php | 3 ++- tests/lib/Repair/RepairCollationTest.php | 13 +++++++++---- tests/phpunit-autotest.xml | 1 + 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 999326463a..31344b3646 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -48,6 +48,9 @@ class FileTest extends \Test\TestCase { public function setUp() { parent::setUp(); + unset($_SERVER['HTTP_OC_CHUNKED']); + unset($_SERVER['CONTENT_LENGTH']); + unset($_SERVER['REQUEST_METHOD']); \OC_Hook::clear(); diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php index 8b06678407..10cd73baf6 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php @@ -57,6 +57,8 @@ abstract class RequestTest extends TestCase { protected function setUp() { parent::setUp(); + unset($_SERVER['HTTP_OC_CHUNKED']); + $this->serverFactory = new ServerFactory( \OC::$server->getConfig(), \OC::$server->getLogger(), diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 97774081b6..726c4bde31 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -38,6 +38,7 @@ use OCP\Files\IRootFolder; use OCP\Lock\LockedException; use OCP\Share\IManager; use OCP\Share; +use Test\TestCase; /** * Class ShareAPIControllerTest @@ -45,7 +46,7 @@ use OCP\Share; * @package OCA\Files_Sharing\Tests\Controller * @group DB */ -class ShareAPIControllerTest extends \Test\TestCase { +class ShareAPIControllerTest extends TestCase { /** @var string */ private $appName = 'files_sharing'; diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php index 897f772a79..7ff069d37b 100644 --- a/tests/lib/Repair/RepairCollationTest.php +++ b/tests/lib/Repair/RepairCollationTest.php @@ -8,10 +8,15 @@ namespace Test\Repair; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\MySqlPlatform; +use OC\Repair\Collation; +use OCP\IDBConnection; use OCP\ILogger; use OCP\Migration\IOutput; +use Test\TestCase; -class TestCollationRepair extends \OC\Repair\Collation { +class TestCollationRepair extends Collation { /** * @param \Doctrine\DBAL\Connection $connection * @return string[] @@ -28,7 +33,7 @@ class TestCollationRepair extends \OC\Repair\Collation { * * @see \OC\Repair\RepairMimeTypes */ -class RepairCollationTest extends \Test\TestCase { +class RepairCollationTest extends TestCase { /** * @var TestCollationRepair @@ -36,7 +41,7 @@ class RepairCollationTest extends \Test\TestCase { private $repair; /** - * @var \Doctrine\DBAL\Connection + * @var Connection|IDBConnection */ private $connection; @@ -59,7 +64,7 @@ class RepairCollationTest extends \Test\TestCase { $this->connection = \OC::$server->getDatabaseConnection(); $this->logger = $this->createMock(ILogger::class); $this->config = \OC::$server->getConfig(); - if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { + if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { $this->markTestSkipped("Test only relevant on MySql"); } diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index ba16bbdbaa..9a9c9c957e 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -2,6 +2,7 @@