diff options
Diffstat (limited to 'tests')
59 files changed, 1168 insertions, 3682 deletions
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php index e19668dea9d..c94e3351b91 100644 --- a/tests/Core/Command/Apps/AppsDisableTest.php +++ b/tests/Core/Command/Apps/AppsDisableTest.php @@ -68,18 +68,18 @@ class AppsDisableTest extends TestCase { public function dataCommandInput(): array { return [ - [['admin_audit'], 0, 'admin_audit 1.10.0 disabled'], - [['comments'], 0, 'comments 1.10.0 disabled'], + [['admin_audit'], 0, 'admin_audit 1.11.0 disabled'], + [['comments'], 0, 'comments 1.11.0 disabled'], [['invalid_app'], 0, 'No such app enabled: invalid_app'], - [['admin_audit', 'comments'], 0, "admin_audit 1.10.0 disabled\ncomments 1.10.0 disabled"], - [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit 1.10.0 disabled\ncomments 1.10.0 disabled\nNo such app enabled: invalid_app"], + [['admin_audit', 'comments'], 0, "admin_audit 1.11.0 disabled\ncomments 1.11.0 disabled"], + [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit 1.11.0 disabled\ncomments 1.11.0 disabled\nNo such app enabled: invalid_app"], [['files'], 2, "files can't be disabled"], [['provisioning_api'], 2, "provisioning_api can't be disabled"], - [['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit 1.10.0 disabled"], - [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments 1.10.0 disabled"], + [['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit 1.11.0 disabled"], + [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments 1.11.0 disabled"], ]; } diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php index bcf3d9dd82c..2fa9240b4eb 100644 --- a/tests/Core/Command/Apps/AppsEnableTest.php +++ b/tests/Core/Command/Apps/AppsEnableTest.php @@ -73,28 +73,28 @@ class AppsEnableTest extends TestCase { public function dataCommandInput(): array { $data = [ - [['admin_audit'], null, 0, 'admin_audit 1.10.0 enabled'], - [['comments'], null, 0, 'comments 1.10.0 enabled'], - [['comments', 'comments'], null, 0, "comments 1.10.0 enabled\ncomments already enabled"], + [['admin_audit'], null, 0, 'admin_audit 1.11.0 enabled'], + [['comments'], null, 0, 'comments 1.11.0 enabled'], + [['comments', 'comments'], null, 0, "comments 1.11.0 enabled\ncomments already enabled"], [['invalid_app'], null, 1, 'Could not download app invalid_app'], - [['admin_audit', 'comments'], null, 0, "admin_audit 1.10.0 enabled\ncomments 1.10.0 enabled"], - [['admin_audit', 'comments', 'invalid_app'], null, 1, "admin_audit 1.10.0 enabled\ncomments 1.10.0 enabled\nCould not download app invalid_app"], + [['admin_audit', 'comments'], null, 0, "admin_audit 1.11.0 enabled\ncomments 1.11.0 enabled"], + [['admin_audit', 'comments', 'invalid_app'], null, 1, "admin_audit 1.11.0 enabled\ncomments 1.11.0 enabled\nCould not download app invalid_app"], [['admin_audit'], ['admin'], 1, "admin_audit can't be enabled for groups"], [['comments'], ['admin'], 1, "comments can't be enabled for groups"], - [['updatenotification'], ['admin'], 0, 'updatenotification 1.10.0 enabled for groups: admin'], - [['updatenotification', 'accessibility'], ['admin'], 0, "updatenotification 1.10.0 enabled for groups: admin\naccessibility 1.6.0 enabled for groups: admin"], + [['updatenotification'], ['admin'], 0, 'updatenotification 1.11.0 enabled for groups: admin'], + [['updatenotification', 'accessibility'], ['admin'], 0, "updatenotification 1.11.0 enabled for groups: admin\naccessibility 1.7.0 enabled for groups: admin"], - [['updatenotification'], ['admin', 'invalid_group'], 0, 'updatenotification 1.10.0 enabled for groups: admin'], - [['updatenotification', 'accessibility'], ['admin', 'invalid_group'], 0, "updatenotification 1.10.0 enabled for groups: admin\naccessibility 1.6.0 enabled for groups: admin"], - [['updatenotification', 'accessibility', 'invalid_app'], ['admin', 'invalid_group'], 1, "updatenotification 1.10.0 enabled for groups: admin\naccessibility 1.6.0 enabled for groups: admin\nCould not download app invalid_app"], + [['updatenotification'], ['admin', 'invalid_group'], 0, 'updatenotification 1.11.0 enabled for groups: admin'], + [['updatenotification', 'accessibility'], ['admin', 'invalid_group'], 0, "updatenotification 1.11.0 enabled for groups: admin\naccessibility 1.7.0 enabled for groups: admin"], + [['updatenotification', 'accessibility', 'invalid_app'], ['admin', 'invalid_group'], 1, "updatenotification 1.11.0 enabled for groups: admin\naccessibility 1.7.0 enabled for groups: admin\nCould not download app invalid_app"], ]; if (getenv('CI') === false) { /** Tests disabled on drone/ci due to appstore dependency */ - $data[] = [['updatenotification', 'contacts'], ['admin'], 0, "updatenotification 1.10.0 enabled for groups: admin\ncontacts 3.3.0 enabled for groups: admin"]; + $data[] = [['updatenotification', 'contacts'], ['admin'], 0, "updatenotification 1.11.0 enabled for groups: admin\ncontacts 3.3.0 enabled for groups: admin"]; $data[] = [['updatenotification', 'contacts'], ['admin', 'invalid_group'], 0, "updatenotification enabled for groups: admin\ncontacts 3.3.0 enabled for groups: admin"]; $data[] = [['updatenotification', 'contacts', 'invalid_app'], ['admin', 'invalid_group'], 1, "updatenotification enabled for groups: admin\ncontacts enabled for groups: admin\nCould not download app invalid_app"]; } diff --git a/tests/Core/Command/Group/InfoTest.php b/tests/Core/Command/Group/InfoTest.php index 40b0f78f5ab..fc98cf647c7 100644 --- a/tests/Core/Command/Group/InfoTest.php +++ b/tests/Core/Command/Group/InfoTest.php @@ -1,8 +1,8 @@ <?php /** - * @copyright 2021, hosting.de, Johannes Leuker <j.leuker@hosting.de> + * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de> * - * @author Johannes Leuker <j.leuker@hosting.de> + * @author Johannes Leuker <developers@hosting.de> * * @license GNU AGPL version 3 or any later version * diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php index 68f32c1f498..c37e57f848c 100644 --- a/tests/Core/Command/Preview/RepairTest.php +++ b/tests/Core/Command/Preview/RepairTest.php @@ -9,6 +9,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\IConfig; use OCP\ILogger; +use OCP\Lock\ILockingProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Input\InputInterface; @@ -43,7 +44,13 @@ class RepairTest extends TestCase { ->getMock(); $this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class) ->getMock(); - $this->repair = new Repair($this->config, $this->rootFolder, $this->logger, $this->iniGetWrapper); + $this->repair = new Repair( + $this->config, + $this->rootFolder, + $this->logger, + $this->iniGetWrapper, + $this->createMock(ILockingProvider::class) + ); $this->input = $this->getMockBuilder(InputInterface::class) ->getMock(); $this->input->expects($this->any()) diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php index 91cf53bd585..7d81e0ec115 100644 --- a/tests/Core/Controller/AppPasswordControllerTest.php +++ b/tests/Core/Controller/AppPasswordControllerTest.php @@ -35,11 +35,11 @@ use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\Exceptions\PasswordUnavailableException; use OCP\Authentication\LoginCredentials\ICredentials; use OCP\Authentication\LoginCredentials\IStore; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IRequest; use OCP\ISession; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class AppPasswordControllerTest extends TestCase { @@ -59,7 +59,7 @@ class AppPasswordControllerTest extends TestCase { /** @var IRequest|MockObject */ private $request; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ private $eventDispatcher; /** @var AppPasswordController */ @@ -73,7 +73,7 @@ class AppPasswordControllerTest extends TestCase { $this->tokenProvider = $this->createMock(IProvider::class); $this->credentialStore = $this->createMock(IStore::class); $this->request = $this->createMock(IRequest::class); - $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); + $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->controller = new AppPasswordController( 'core', @@ -144,7 +144,7 @@ class AppPasswordControllerTest extends TestCase { ); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $this->controller->getAppPassword(); } @@ -185,7 +185,7 @@ class AppPasswordControllerTest extends TestCase { ); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $this->controller->getAppPassword(); } diff --git a/tests/Core/Controller/AutoCompleteControllerTest.php b/tests/Core/Controller/AutoCompleteControllerTest.php index 73bc8492113..61fc90e3c82 100644 --- a/tests/Core/Controller/AutoCompleteControllerTest.php +++ b/tests/Core/Controller/AutoCompleteControllerTest.php @@ -75,8 +75,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'source' => 'users'], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'source' => 'users'], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], ], '', 'files', @@ -96,8 +96,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'source' => 'users'], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'source' => 'users'], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], ], '', null, @@ -117,8 +117,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'source' => 'users'], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'source' => 'users'], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], ], '', 'files', @@ -138,8 +138,8 @@ class AutoCompleteControllerTest extends TestCase { ], ], [ - [ 'id' => 'bob', 'label' => 'Bob Y.', 'source' => 'users'], - [ 'id' => 'bobby', 'label' => 'Robert R.', 'source' => 'users'], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'bobby', 'label' => 'Robert R.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], ], 'bob', 'files', diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index 037147e01b7..51a17743c93 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -32,6 +32,7 @@ use OCA\OAuth2\Db\ClientMapper; use OCP\AppFramework\Http; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\IRequest; use OCP\ISession; @@ -41,7 +42,6 @@ use OCP\IUserSession; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class ClientFlowLoginControllerTest extends TestCase { @@ -67,7 +67,7 @@ class ClientFlowLoginControllerTest extends TestCase { private $accessTokenMapper; /** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */ private $crypto; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ private $eventDispatcher; @@ -94,7 +94,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->clientMapper = $this->createMock(ClientMapper::class); $this->accessTokenMapper = $this->createMock(AccessTokenMapper::class); $this->crypto = $this->createMock(ICrypto::class); - $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); + $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->clientFlowLoginController = new ClientFlowLoginController( 'core', @@ -392,7 +392,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->willReturn(''); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); @@ -488,7 +488,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->willReturn($client); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $expected = new Http\RedirectResponse($redirectUrl); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier')); @@ -563,7 +563,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->willReturn(''); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); @@ -694,7 +694,7 @@ class ClientFlowLoginControllerTest extends TestCase { ->willReturnMap($headers); $this->eventDispatcher->expects($this->once()) - ->method('dispatch'); + ->method('dispatchTyped'); $expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index e9d4a89aa7d..e3469621eec 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -440,6 +440,7 @@ class LoginControllerTest extends TestCase { ->with('core.login.showLoginForm', [ 'user' => $user, 'redirect_url' => '/apps/files', + 'direct' => 1, ]) ->willReturn($loginPageUrl); $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl); @@ -597,6 +598,7 @@ class LoginControllerTest extends TestCase { ->with('core.login.showLoginForm', [ 'user' => 'john@doe.com', 'redirect_url' => '/apps/files', + 'direct' => 1, ]) ->willReturn($loginPageUrl); $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl); diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php index 267f01ca43f..a487e021187 100644 --- a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php +++ b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php @@ -52,7 +52,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManager; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->rootFolder = $this->createMock(IRootFolder::class); diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php index 131b80517fb..abd166057be 100644 --- a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php +++ b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php @@ -46,7 +46,7 @@ class CleanPreviewsTest extends TestCase { /** @var CleanPreviews */ private $repair; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->jobList = $this->createMock(IJobList::class); diff --git a/tests/Test/Repair/Owncloud/InstallCoreBundleTest.php b/tests/Test/Repair/Owncloud/InstallCoreBundleTest.php index 37163aee961..61be5006c41 100644 --- a/tests/Test/Repair/Owncloud/InstallCoreBundleTest.php +++ b/tests/Test/Repair/Owncloud/InstallCoreBundleTest.php @@ -41,7 +41,7 @@ class InstallCoreBundleTest extends TestCase { /** @var InstallCoreBundle */ private $installCoreBundle; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->bundleFetcher = $this->createMock(BundleFetcher::class); $this->config = $this->createMock(IConfig::class); diff --git a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php index 171b7701194..3b0b2f57f5f 100644 --- a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php +++ b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php @@ -43,7 +43,7 @@ class UpdateLanguageCodesTest extends TestCase { /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */ private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); @@ -86,6 +86,7 @@ class UpdateLanguageCodesTest extends TestCase { ->from('preferences') ->where($qb->expr()->eq('appid', $qb->createNamedParameter('core'))) ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lang'))) + ->orderBy('userid') ->execute(); $rows = $result->fetchAll(); diff --git a/tests/acceptance/composer.json b/tests/acceptance/composer.json index d1e7fdc5d40..a2ec896d94e 100644 --- a/tests/acceptance/composer.json +++ b/tests/acceptance/composer.json @@ -1,10 +1,10 @@ { "require-dev": { - "behat/behat": "3.7.0", - "behat/mink": "1.7.1", + "behat/behat": "3.8.1", + "behat/mink": "1.8.1", "behat/mink-extension": "2.3.1", - "behat/mink-selenium2-driver": "1.3.1", - "phpunit/phpunit": "4.8.36" + "behat/mink-selenium2-driver": "1.4.0", + "phpunit/phpunit": "6.5.14" }, "autoload": { "psr-4": { diff --git a/tests/acceptance/composer.lock b/tests/acceptance/composer.lock index 84a365ec84f..20d93036ba9 100644 --- a/tests/acceptance/composer.lock +++ b/tests/acceptance/composer.lock @@ -4,41 +4,41 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "2680419ed5b247f3b4d21687a84ea2cf", + "content-hash": "d2c44a0ea2452a05e7f45d8ca6ef0387", "packages": [], "packages-dev": [ { "name": "behat/behat", - "version": "v3.7.0", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/Behat/Behat.git", - "reference": "08052f739619a9e9f62f457a67302f0715e6dd13" + "reference": "fbb065457d523d9856d4b50775b4151a7598b510" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Behat/zipball/08052f739619a9e9f62f457a67302f0715e6dd13", - "reference": "08052f739619a9e9f62f457a67302f0715e6dd13", + "url": "https://api.github.com/repos/Behat/Behat/zipball/fbb065457d523d9856d4b50775b4151a7598b510", + "reference": "fbb065457d523d9856d4b50775b4151a7598b510", "shasum": "" }, "require": { "behat/gherkin": "^4.6.0", "behat/transliterator": "^1.2", "ext-mbstring": "*", - "php": ">=5.3.3", + "php": "^7.2 || ^8.0", "psr/container": "^1.0", - "symfony/config": "^2.7.51 || ^3.0 || ^4.0 || ^5.0", - "symfony/console": "^2.7.51 || ^2.8.33 || ^3.3.15 || ^3.4.3 || ^4.0.3 || ^5.0", - "symfony/dependency-injection": "^2.7.51 || ^3.0 || ^4.0 || ^5.0", - "symfony/event-dispatcher": "^2.7.51 || ^3.0 || ^4.0 || ^5.0", - "symfony/translation": "^2.7.51 || ^3.0 || ^4.0 || ^5.0", - "symfony/yaml": "^2.7.51 || ^3.0 || ^4.0 || ^5.0" + "symfony/config": "^4.4 || ^5.0", + "symfony/console": "^4.4 || ^5.0", + "symfony/dependency-injection": "^4.4 || ^5.0", + "symfony/event-dispatcher": "^4.4 || ^5.0", + "symfony/translation": "^4.4 || ^5.0", + "symfony/yaml": "^4.4 || ^5.0" }, "require-dev": { "container-interop/container-interop": "^1.2", "herrera-io/box": "~1.6.1", - "phpunit/phpunit": "^4.8.36 || ^6.5.14 || ^7.5.20", - "symfony/process": "~2.5 || ^3.0 || ^4.0 || ^5.0" + "phpunit/phpunit": "^8.5 || ^9.0", + "symfony/process": "^4.4 || ^5.0" }, "suggest": { "ext-dom": "Needed to output test results in JUnit format." @@ -49,7 +49,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.6.x-dev" + "dev-master": "3.8.x-dev" } }, "autoload": { @@ -69,7 +69,7 @@ "homepage": "http://everzet.com" } ], - "description": "Scenario-oriented BDD framework for PHP 5.3", + "description": "Scenario-oriented BDD framework for PHP", "homepage": "http://behat.org/", "keywords": [ "Agile", @@ -85,7 +85,7 @@ "symfony", "testing" ], - "time": "2020-06-03T13:08:44+00:00" + "time": "2020-11-07T15:55:18+00:00" }, { "name": "behat/gherkin", @@ -148,35 +148,38 @@ }, { "name": "behat/mink", - "version": "v1.7.1", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/minkphp/Mink.git", - "reference": "e6930b9c74693dff7f4e58577e1b1743399f3ff9" + "reference": "07c6a9fe3fa98c2de074b25d9ed26c22904e3887" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minkphp/Mink/zipball/e6930b9c74693dff7f4e58577e1b1743399f3ff9", - "reference": "e6930b9c74693dff7f4e58577e1b1743399f3ff9", + "url": "https://api.github.com/repos/minkphp/Mink/zipball/07c6a9fe3fa98c2de074b25d9ed26c22904e3887", + "reference": "07c6a9fe3fa98c2de074b25d9ed26c22904e3887", "shasum": "" }, "require": { "php": ">=5.3.1", - "symfony/css-selector": "~2.1|~3.0" + "symfony/css-selector": "^2.7|^3.0|^4.0|^5.0" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7|~3.0" + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20", + "symfony/debug": "^2.7|^3.0|^4.0", + "symfony/phpunit-bridge": "^3.4.38 || ^5.0.5" }, "suggest": { "behat/mink-browserkit-driver": "extremely fast headless driver for Symfony\\Kernel-based apps (Sf2, Silex)", "behat/mink-goutte-driver": "fast headless driver for any app without JS emulation", "behat/mink-selenium2-driver": "slow, but JS-enabled driver for any app (requires Selenium2)", - "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)" + "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)", + "dmore/chrome-mink-driver": "fast and JS-enabled driver for any app (requires chromium or google chrome)" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -202,7 +205,7 @@ "testing", "web" ], - "time": "2016-03-05T08:26:18+00:00" + "time": "2020-03-11T15:45:53+00:00" }, { "name": "behat/mink-extension", @@ -265,30 +268,30 @@ }, { "name": "behat/mink-selenium2-driver", - "version": "v1.3.1", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/minkphp/MinkSelenium2Driver.git", - "reference": "473a9f3ebe0c134ee1e623ce8a9c852832020288" + "reference": "312a967dd527f28980cce40850339cd5316da092" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/473a9f3ebe0c134ee1e623ce8a9c852832020288", - "reference": "473a9f3ebe0c134ee1e623ce8a9c852832020288", + "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/312a967dd527f28980cce40850339cd5316da092", + "reference": "312a967dd527f28980cce40850339cd5316da092", "shasum": "" }, "require": { "behat/mink": "~1.7@dev", "instaclick/php-webdriver": "~1.1", - "php": ">=5.3.1" + "php": ">=5.4" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "mink/driver-testsuite": "dev-master" }, "type": "mink-driver", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { @@ -302,14 +305,14 @@ ], "authors": [ { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { "name": "Pete Otaqui", "email": "pete@otaqui.com", "homepage": "https://github.com/pete-otaqui" + }, + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" } ], "description": "Selenium2 (WebDriver) driver for Mink framework", @@ -322,7 +325,7 @@ "testing", "webdriver" ], - "time": "2016-03-05T09:10:18+00:00" + "time": "2020-03-11T14:43:21+00:00" }, { "name": "behat/transliterator", @@ -480,6 +483,156 @@ "time": "2019-09-25T09:05:11+00:00" }, { + "name": "myclabs/deep-copy", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2020-11-13T09:40:50+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^1.0.1", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2017-03-05T18:14:27+00:00" + }, + { + "name": "phar-io/version", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2017-03-05T17:38:23+00:00" + }, + { "name": "phpdocumentor/reflection-common", "version": "2.2.0", "source": { @@ -690,39 +843,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "version": "5.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "reference": "c89677919c5dd6d3b3852f230a663118762218ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", + "reference": "c89677919c5dd6d3b3852f230a663118762218ac", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.0", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^2.0.1", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "phpunit/phpunit": "^6.0" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.5.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "5.3.x-dev" } }, "autoload": { @@ -737,7 +891,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -748,7 +902,7 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "time": "2018-04-06T15:36:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -889,29 +1043,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.12", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -935,45 +1089,57 @@ "tokenizer" ], "abandoned": true, - "time": "2017-12-04T08:55:13+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "4.8.36", + "version": "6.5.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "^1.6.1", + "phar-io/manifest": "^1.0.1", + "phar-io/version": "^1.0", + "php": "^7.0", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^5.3", + "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^1.0.9", + "phpunit/phpunit-mock-objects": "^5.0.9", + "sebastian/comparator": "^2.1", + "sebastian/diff": "^2.0", + "sebastian/environment": "^3.1", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^1.0", + "sebastian/version": "^2.0.1" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2", + "phpunit/dbunit": "<3.0" + }, + "require-dev": { + "ext-pdo": "*" }, "suggest": { - "phpunit/php-invoker": "~1.1" + "ext-xdebug": "*", + "phpunit/php-invoker": "^1.1" }, "bin": [ "phpunit" @@ -981,7 +1147,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "6.5.x-dev" } }, "autoload": { @@ -1007,30 +1173,33 @@ "testing", "xunit" ], - "time": "2017-06-21T08:07:12+00:00" + "time": "2019-02-01T05:22:47+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "version": "5.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" + "doctrine/instantiator": "^1.0.5", + "php": "^7.0", + "phpunit/php-text-template": "^1.2.1", + "sebastian/exporter": "^3.1" + }, + "conflict": { + "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.5.11" }, "suggest": { "ext-soap": "*" @@ -1038,7 +1207,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "5.0.x-dev" } }, "autoload": { @@ -1053,7 +1222,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1064,7 +1233,7 @@ "xunit" ], "abandoned": true, - "time": "2015-10-02T06:51:40+00:00" + "time": "2018-08-09T05:50:03+00:00" }, { "name": "psr/container", @@ -1162,31 +1331,76 @@ "time": "2019-01-08T18:20:26+00:00" }, { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^8.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2020-11-30T08:15:22+00:00" + }, + { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.0", + "sebastian/diff": "^2.0 || ^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "2.1.x-dev" } }, "autoload": { @@ -1217,38 +1431,38 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-02-01T13:46:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", + "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1275,32 +1489,32 @@ "keywords": [ "diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2017-08-03T08:09:46+00:00" }, { "name": "sebastian/environment", - "version": "1.3.8", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" + "phpunit/phpunit": "^6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1325,34 +1539,34 @@ "environment", "hhvm" ], - "time": "2016-08-18T05:49:44+00:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", - "version": "1.2.2", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "php": ">=7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1366,6 +1580,10 @@ ], "authors": [ { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" }, @@ -1374,16 +1592,12 @@ "email": "github@wallbash.com" }, { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1392,27 +1606,27 @@ "export", "exporter" ], - "time": "2016-06-17T09:04:28+00:00" + "time": "2020-11-30T07:47:53+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -1420,7 +1634,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1443,32 +1657,124 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2017-04-27T15:39:26+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2020-11-30T07:40:27+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2020-11-30T07:37:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "1.0.5", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1482,37 +1788,87 @@ ], "authors": [ { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { "name": "Adam Harvey", "email": "aharvey@php.net" } ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" + "time": "2020-11-30T07:34:24+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" }, { "name": "sebastian/version", - "version": "1.0.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, + "require": { + "php": ">=5.6" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1531,7 +1887,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" + "time": "2016-10-03T07:35:21+00:00" }, { "name": "symfony/config", @@ -1674,20 +2030,20 @@ }, { "name": "symfony/css-selector", - "version": "v3.4.47", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "da3d9da2ce0026771f5fe64cb332158f1bd2bc33" + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/da3d9da2ce0026771f5fe64cb332158f1bd2bc33", - "reference": "da3d9da2ce0026771f5fe64cb332158f1bd2bc33", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/f789e7ead4c79e04ca9a6d6162fc629c89bd8054", + "reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": ">=7.2.5" }, "type": "library", "autoload": { @@ -1718,7 +2074,7 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2020-10-24T10:57:07+00:00" + "time": "2020-12-08T17:02:38+00:00" }, { "name": "symfony/dependency-injection", @@ -2659,31 +3015,35 @@ }, { "name": "symfony/yaml", - "version": "v3.4.47", + "version": "v5.2.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "88289caa3c166321883f67fe5130188ebbb47094" + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/88289caa3c166321883f67fe5130188ebbb47094", - "reference": "88289caa3c166321883f67fe5130188ebbb47094", + "url": "https://api.github.com/repos/symfony/yaml/zipball/290ea5e03b8cf9b42c783163123f54441fb06939", + "reference": "290ea5e03b8cf9b42c783163123f54441fb06939", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/console": "<3.4" + "symfony/console": "<4.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, + "bin": [ + "Resources/bin/yaml-lint" + ], "type": "library", "autoload": { "psr-4": { @@ -2709,7 +3069,47 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-10-24T10:57:07+00:00" + "time": "2020-12-08T17:02:38+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "75a63c33a8577608444246075ea0af0d052e452a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2020-07-12T23:59:07+00:00" }, { "name": "webmozart/assert", diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index dfea50b3c5a..a43bcb504a6 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -2,7 +2,7 @@ default: suites: default: paths: - - %paths.base%/../features + - "%paths.base%/../features" contexts: - ActorContext - NextcloudTestServerContext @@ -31,7 +31,7 @@ default: tags: "~@apache" apache: paths: - - %paths.base%/../features + - "%paths.base%/../features" contexts: - ActorContext - NextcloudTestServerContext: diff --git a/tests/acceptance/features/bootstrap/AppNavigationContext.php b/tests/acceptance/features/bootstrap/AppNavigationContext.php index 06a1c563b03..ef8cb8cae8b 100644 --- a/tests/acceptance/features/bootstrap/AppNavigationContext.php +++ b/tests/acceptance/features/bootstrap/AppNavigationContext.php @@ -23,6 +23,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class AppNavigationContext implements Context, ActorAwareInterface { use ActorAware; @@ -105,7 +106,7 @@ class AppNavigationContext implements Context, ActorAwareInterface { * @Then I see that the current section is :section */ public function iSeeThatTheCurrentSectionIs($section) { - PHPUnit_Framework_Assert::assertEquals($this->actor->find(self::appNavigationCurrentSectionItem(), 10)->getText(), $section); + Assert::assertEquals($this->actor->find(self::appNavigationCurrentSectionItem(), 10)->getText(), $section); } /** @@ -116,7 +117,7 @@ class AppNavigationContext implements Context, ActorAwareInterface { $this->actor, self::appNavigationSectionItemFor($section), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The section $section in the app navigation is not shown yet after $timeout seconds"); + Assert::fail("The section $section in the app navigation is not shown yet after $timeout seconds"); } } @@ -128,7 +129,7 @@ class AppNavigationContext implements Context, ActorAwareInterface { $this->actor, self::appNavigationSectionItemFor($section), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The section $section in the app navigation is still shown after $timeout seconds"); + Assert::fail("The section $section in the app navigation is still shown after $timeout seconds"); } } @@ -136,7 +137,7 @@ class AppNavigationContext implements Context, ActorAwareInterface { * @Then I see that the section :section has a count of :count */ public function iSeeThatTheSectionHasACountOf($section, $count) { - PHPUnit_Framework_Assert::assertEquals($this->actor->find(self::counterForTheSection($section), 10)->getText(), $count); + Assert::assertEquals($this->actor->find(self::counterForTheSection($section), 10)->getText(), $count); } /** @@ -147,7 +148,7 @@ class AppNavigationContext implements Context, ActorAwareInterface { $this->actor, self::counterForTheSection($section), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The counter for section $section is still shown after $timeout seconds"); + Assert::fail("The counter for section $section is still shown after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/AppSettingsContext.php b/tests/acceptance/features/bootstrap/AppSettingsContext.php index c9ff57f376c..c7859edcb64 100644 --- a/tests/acceptance/features/bootstrap/AppSettingsContext.php +++ b/tests/acceptance/features/bootstrap/AppSettingsContext.php @@ -23,6 +23,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class AppSettingsContext implements Context, ActorAwareInterface { use ActorAware; @@ -92,7 +93,7 @@ class AppSettingsContext implements Context, ActorAwareInterface { $this->actor, self::appSettingsContent(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The app settings are not open yet after $timeout seconds"); + Assert::fail("The app settings are not open yet after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/AppsManagementContext.php b/tests/acceptance/features/bootstrap/AppsManagementContext.php index 332c3b020ec..747ef3d96b5 100644 --- a/tests/acceptance/features/bootstrap/AppsManagementContext.php +++ b/tests/acceptance/features/bootstrap/AppsManagementContext.php @@ -24,6 +24,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class AppsManagementContext implements Context, ActorAwareInterface { use ActorAware; @@ -170,7 +171,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { */ public function iSeeThatTheAppHasBeenEnabled($app) { // TODO: Find a way to check if the enable button is removed - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::disableButtonForApp($app), 10)->isVisible() ); } @@ -180,7 +181,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { */ public function iSeeThatTheAppHasBeenDisabled($app) { // TODO: Find a way to check if the disable button is removed - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::enableButtonForApp($app), 10)->isVisible() ); } @@ -189,7 +190,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { * @Then /^I see that there are no available updates$/ */ public function iSeeThatThereAreNoAvailableUpdates() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::emptyAppList(), 10)->isVisible() ); } @@ -202,7 +203,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { $this->actor, self::appEntries(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The apps from the app store were not shown yet after $timeout seconds"); + Assert::fail("The apps from the app store were not shown yet after $timeout seconds"); } } @@ -220,7 +221,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { try { $this->actor->find(self::disableButtonForAnyApp(), 2); - PHPUnit_Framework_Assert::fail("Found enabled apps"); + Assert::fail("Found enabled apps"); } catch (NoSuchElementException $exception) { } } @@ -232,7 +233,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { try { $this->actor->find(self::enableButtonForAnyApp(), 2); - PHPUnit_Framework_Assert::fail("Found disabled apps"); + Assert::fail("Found disabled apps"); } catch (NoSuchElementException $exception) { } } @@ -241,10 +242,10 @@ class AppsManagementContext implements Context, ActorAwareInterface { * @Given /^I see the app bundles$/ */ public function iSeeTheAppBundles() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::rowForApp('Auditing / Logging'), 2)->isVisible() ); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::rowForApp('LDAP user and group backend'), 2)->isVisible() ); } @@ -260,7 +261,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { * @Given /^I see that the "([^"]*)" is disabled$/ */ public function iSeeThatTheIsDisabled($bundle) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::enableAllBundleButton($bundle), 2)->isVisible() ); } @@ -276,7 +277,7 @@ class AppsManagementContext implements Context, ActorAwareInterface { $this->actor, self::sidebar(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The sidebar was not shown yet after $timeout seconds"); + Assert::fail("The sidebar was not shown yet after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php index 57e60afa60e..577b14b7e72 100644 --- a/tests/acceptance/features/bootstrap/CommentsAppContext.php +++ b/tests/acceptance/features/bootstrap/CommentsAppContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class CommentsAppContext implements Context, ActorAwareInterface { use ActorAware; @@ -87,7 +88,7 @@ class CommentsAppContext implements Context, ActorAwareInterface { $this->actor, self::emptyContent(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The no comments message is not visible yet after $timeout seconds"); + Assert::fail("The no comments message is not visible yet after $timeout seconds"); } } @@ -95,7 +96,7 @@ class CommentsAppContext implements Context, ActorAwareInterface { * @Then /^I see a comment with "([^"]*)" as message$/ */ public function iSeeACommentWithAsMessage($commentText) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::commentWithText($commentText), 10)->isVisible()); } @@ -104,7 +105,7 @@ class CommentsAppContext implements Context, ActorAwareInterface { */ public function iSeeThatThereIsNoCommentWithAsMessage($commentText) { try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::commentWithText($commentText))->isVisible()); } catch (NoSuchElementException $exception) { } diff --git a/tests/acceptance/features/bootstrap/ContactsMenuContext.php b/tests/acceptance/features/bootstrap/ContactsMenuContext.php index 860e84fa950..35786062150 100644 --- a/tests/acceptance/features/bootstrap/ContactsMenuContext.php +++ b/tests/acceptance/features/bootstrap/ContactsMenuContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class ContactsMenuContext implements Context, ActorAwareInterface { use ActorAware; @@ -88,7 +89,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { * @Then I see that the Contacts menu is shown */ public function iSeeThatTheContactsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::contactsMenu(), 10)->isVisible()); } @@ -96,7 +97,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { * @Then I see that the Contacts menu search input is shown */ public function iSeeThatTheContactsMenuSearchInputIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::contactsMenuSearchInput(), 10)->isVisible()); } @@ -104,7 +105,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { * @Then I see that the no results message in the Contacts menu is shown */ public function iSeeThatTheNoResultsMessageInTheContactsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::noResultsMessage(), 10)->isVisible()); } @@ -112,7 +113,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { * @Then I see that the contact :contactName in the Contacts menu is shown */ public function iSeeThatTheContactInTheContactsMenuIsShown($contactName) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::menuItemFor($contactName), 10)->isVisible()); } @@ -123,7 +124,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { $this->iSeeThatThecontactsMenuIsShown(); try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::menuItemFor($contactName))->isVisible()); } catch (NoSuchElementException $exception) { } @@ -139,7 +140,7 @@ class ContactsMenuContext implements Context, ActorAwareInterface { $this->actor, self::menuItemFor($contactName), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The $contactName contact in Contacts menu is still shown after $timeout seconds"); + Assert::fail("The $contactName contact in Contacts menu is still shown after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/DialogContext.php b/tests/acceptance/features/bootstrap/DialogContext.php index cbd02b35553..dea9f434bab 100644 --- a/tests/acceptance/features/bootstrap/DialogContext.php +++ b/tests/acceptance/features/bootstrap/DialogContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class DialogContext implements Context, ActorAwareInterface { use ActorAware; @@ -58,7 +59,7 @@ class DialogContext implements Context, ActorAwareInterface { $this->actor, self::theDialog(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The confirmation dialog was not shown yet after $timeout seconds"); + Assert::fail("The confirmation dialog was not shown yet after $timeout seconds"); } } @@ -70,7 +71,7 @@ class DialogContext implements Context, ActorAwareInterface { $this->actor, self::theDialog(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The confirmation dialog is still shown after $timeout seconds"); + Assert::fail("The confirmation dialog is still shown after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php index 0b0c80bc272..ce2bd9971e0 100644 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ b/tests/acceptance/features/bootstrap/FileListContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class FileListContext implements Context, ActorAwareInterface { @@ -125,7 +126,7 @@ class FileListContext implements Context, ActorAwareInterface { * @return Locator */ public static function createNewFolderMenuItemNameInput($fileListAncestor) { - return Locator::forThe()->css(".filenameform input")-> + return Locator::forThe()->css(".filenameform input[type=text]")-> descendantOf(self::createNewFolderMenuItem($fileListAncestor))-> describedAs("Name input in create new folder menu item in file list"); } @@ -133,6 +134,15 @@ class FileListContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function createNewFolderMenuItemConfirmButton($fileListAncestor) { + return Locator::forThe()->css(".filenameform input[type=submit]")-> + descendantOf(self::createNewFolderMenuItem($fileListAncestor))-> + describedAs("Confirm button in create new folder menu item in file list"); + } + + /** + * @return Locator + */ public static function fileListHeader($fileListAncestor) { return Locator::forThe()->css("thead")-> descendantOf($fileListAncestor)-> @@ -355,7 +365,8 @@ class FileListContext implements Context, ActorAwareInterface { $this->actor->find(self::createMenuButton($this->fileListAncestor), 10)->click(); $this->actor->find(self::createNewFolderMenuItem($this->fileListAncestor), 2)->click(); - $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName . "\r"); + $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName); + $this->actor->find(self::createNewFolderMenuItemConfirmButton($this->fileListAncestor), 2)->click(); } /** @@ -409,7 +420,7 @@ class FileListContext implements Context, ActorAwareInterface { // This should not be a problem, though, as the default behaviour is to // bring the browser window to the foreground when switching to a // different actor. - $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2 . "\r"); + $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2); } /** @@ -476,7 +487,7 @@ class FileListContext implements Context, ActorAwareInterface { $this->actor, self::mainWorkingIcon($this->fileListAncestor), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The main working icon for the file list is still shown after $timeout seconds"); + Assert::fail("The main working icon for the file list is still shown after $timeout seconds"); } } @@ -486,7 +497,7 @@ class FileListContext implements Context, ActorAwareInterface { public function iSeeThatTheFileListIsCurrentlyIn($path) { // The text of the breadcrumbs is the text of all the crumbs separated // by white spaces. - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( str_replace('/', ' ', $path), $this->actor->find(self::breadcrumbs($this->fileListAncestor), 10)->getText()); } @@ -496,14 +507,14 @@ class FileListContext implements Context, ActorAwareInterface { public function iSeeThatItIsNotPossibleToCreateNewFiles() { // Once a file list is loaded the "Create" menu button is always in the // DOM, so it is checked if it is visible or not. - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::createMenuButton($this->fileListAncestor))->isVisible()); + Assert::assertFalse($this->actor->find(self::createMenuButton($this->fileListAncestor))->isVisible()); } /** * @Then I see that the file list contains a file named :fileName */ public function iSeeThatTheFileListContainsAFileNamed($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)); + Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)); } /** @@ -514,7 +525,7 @@ class FileListContext implements Context, ActorAwareInterface { $this->actor, self::rowForFile($this->fileListAncestor, $fileName), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The file list still contains a file named $fileName after $timeout seconds"); + Assert::fail("The file list still contains a file named $fileName after $timeout seconds"); } } @@ -522,35 +533,35 @@ class FileListContext implements Context, ActorAwareInterface { * @Then I see that :fileName1 precedes :fileName2 in the file list */ public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($this->fileListAncestor, $fileName1, $fileName2), 10)); + Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($this->fileListAncestor, $fileName1, $fileName2), 10)); } /** * @Then I see that :fileName is not selected */ public function iSeeThatIsNotSelected($fileName) { - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked()); + Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked()); } /** * @Then I see that :fileName is marked as favorite */ public function iSeeThatIsMarkedAsFavorite($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); + Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); } /** * @Then I see that :fileName is not marked as favorite */ public function iSeeThatIsNotMarkedAsFavorite($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::notFavoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); + Assert::assertNotNull($this->actor->find(self::notFavoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); } /** * @Then I see that :fileName has unread comments */ public function iSeeThatHasUnreadComments($fileName) { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->isVisible()); + Assert::assertTrue($this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->isVisible()); } private function waitForRowForFileToBeFullyOpaque($fileName) { @@ -567,7 +578,7 @@ class FileListContext implements Context, ActorAwareInterface { }; if (!Utils::waitFor($fileRowIsFullyOpaqueCallback, $timeout = 2 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The row for file $fileName in file list is not fully opaque after $timeout seconds"); + Assert::fail("The row for file $fileName in file list is not fully opaque after $timeout seconds"); } } diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 906a57b9e61..fe93bf194a2 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class FilesAppContext implements Context, ActorAwareInterface { use ActorAware; @@ -295,7 +296,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the current page is the Files app */ public function iSeeThatTheCurrentPageIsTheFilesApp() { - PHPUnit_Framework_Assert::assertStringStartsWith( + Assert::assertStringStartsWith( $this->actor->locatePath("/apps/files/"), $this->actor->getSession()->getCurrentUrl()); @@ -313,7 +314,7 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->actor, self::detailsView(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The details view is not open yet after $timeout seconds"); + Assert::fail("The details view is not open yet after $timeout seconds"); } } @@ -325,7 +326,7 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->actor, self::detailsView(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The details view is not closed yet after $timeout seconds"); + Assert::fail("The details view is not closed yet after $timeout seconds"); } } @@ -333,7 +334,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the file name shown in the details view is :fileName */ public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName); } @@ -341,7 +342,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the file is marked as favorite in the details view */ public function iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView() { - PHPUnit_Framework_Assert::assertNotNull( + Assert::assertNotNull( $this->actor->find(self::favoritedStateIconInFileDetailsInDetailsView(), 10)); } @@ -349,7 +350,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the file is not marked as favorite in the details view */ public function iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView() { - PHPUnit_Framework_Assert::assertNotNull( + Assert::assertNotNull( $this->actor->find(self::notFavoritedStateIconInFileDetailsInDetailsView(), 10)); } @@ -357,7 +358,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the input field for tags in the details view is shown */ public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::inputFieldForTagsInDetailsView(), 10)->isVisible()); } @@ -365,7 +366,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the input field for tags in the details view contains the tag :tag */ public function iSeeThatTheInputFieldForTagsInTheDetailsViewContainsTheTag($tag) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag), 10)->isVisible()); } @@ -376,7 +377,7 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown(); try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag))->isVisible()); } catch (NoSuchElementException $exception) { } @@ -386,7 +387,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the tag :tag in the dropdown for tags in the details view is checked */ public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsChecked($tag) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::checkmarkInItemInDropdownForTag($tag), 10)->isVisible()); } @@ -394,10 +395,10 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the tag :tag in the dropdown for tags in the details view is not checked */ public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($tag) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::itemInDropdownForTag($tag), 10)->isVisible()); - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::checkmarkInItemInDropdownForTag($tag))->isVisible()); } @@ -409,7 +410,7 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->actor, self::loadingIconForTabInDetailsViewNamed($tabName), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds"); + Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index 07ebbba1a36..e8515fa1124 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class FilesAppSharingContext implements Context, ActorAwareInterface { use ActorAware; @@ -371,8 +372,8 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { self::shareLinkMenu($shareLinkMenuTriggerElement), $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { // It may not be possible to click on the menu button (due to the - // menu itself covering it), so "Esc" key is pressed instead. - $this->actor->find(self::shareLinkMenu($shareLinkMenuTriggerElement), 2)->getWrappedElement()->keyPress(27); + // menu itself covering it), so "Enter" key is pressed instead. + $this->actor->find(self::shareLinkMenuButton(), 2)->getWrappedElement()->keyPress(13); } $this->actor->find(self::copyLinkButton(), 10)->click(); @@ -513,7 +514,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @Then I see that the file is shared with me by :sharedByName */ public function iSeeThatTheFileIsSharedWithMeBy($sharedByName) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::sharedByLabel(), 10)->getText(), "Shared with you by $sharedByName"); } @@ -521,7 +522,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @Then I see that the file is shared with :sharedWithName */ public function iSeeThatTheFileIsSharedWith($sharedWithName) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible()); } @@ -533,7 +534,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->actor, self::sharedWithRow($sharedWithName), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds"); + Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds"); } } @@ -541,9 +542,9 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @Then I see that resharing the file is not allowed */ public function iSeeThatResharingTheFileIsNotAllowed() { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed"); } @@ -555,7 +556,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->actor, self::shareLinkAddNewButton(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The add new share link button is still shown after $timeout seconds"); + Assert::fail("The add new share link button is still shown after $timeout seconds"); } } @@ -566,7 +567,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); } @@ -577,7 +578,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -588,7 +589,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -599,7 +600,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); } @@ -610,7 +611,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -621,7 +622,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -636,7 +637,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->actor, self::canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds"); + Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds"); } } @@ -647,7 +648,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -658,7 +659,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareWithMenuIfNeeded($sharedWithName); $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -669,7 +670,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareLinkMenuIfNeeded(); $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); + Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -679,7 +680,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareLinkMenuIfNeeded(); $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); + Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -708,7 +709,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->actor, self::disabledPasswordProtectField($shareLinkMenuTriggerElement), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The password protect field is still disabled after $timeout seconds"); + Assert::fail("The password protect field is still disabled after $timeout seconds"); } } @@ -719,8 +720,8 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareLinkMenuIfNeeded(); $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked(), "Password protect checkbox is checked"); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 10)->isVisible(), "Password protect field is visible"); + Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked(), "Password protect checkbox is checked"); + Assert::assertTrue($this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 10)->isVisible(), "Password protect field is visible"); } /** @@ -730,7 +731,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareLinkMenuIfNeeded(); $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); + Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -740,7 +741,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $this->showShareLinkMenuIfNeeded(); $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); + Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -751,7 +752,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement))->isVisible()); } catch (NoSuchElementException $exception) { } diff --git a/tests/acceptance/features/bootstrap/LoginPageContext.php b/tests/acceptance/features/bootstrap/LoginPageContext.php index bf44d31fb03..e22ee22e743 100644 --- a/tests/acceptance/features/bootstrap/LoginPageContext.php +++ b/tests/acceptance/features/bootstrap/LoginPageContext.php @@ -23,6 +23,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use PHPUnit\Framework\Assert; class LoginPageContext implements Context, ActorAwareInterface { use ActorAware; @@ -90,7 +91,7 @@ class LoginPageContext implements Context, ActorAwareInterface { * @Then I see that the current page is the Login page */ public function iSeeThatTheCurrentPageIsTheLoginPage() { - PHPUnit_Framework_Assert::assertStringStartsWith( + Assert::assertStringStartsWith( $this->actor->locatePath("/login"), $this->actor->getSession()->getCurrentUrl()); } @@ -99,7 +100,7 @@ class LoginPageContext implements Context, ActorAwareInterface { * @Then I see that a wrong password message is shown */ public function iSeeThatAWrongPasswordMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible()); } @@ -107,7 +108,7 @@ class LoginPageContext implements Context, ActorAwareInterface { * @Then I see that the disabled user message is shown */ public function iSeeThatTheDisabledUserMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::userDisabledMessage(), 10)->isVisible()); } diff --git a/tests/acceptance/features/bootstrap/PublicShareContext.php b/tests/acceptance/features/bootstrap/PublicShareContext.php index 2213cf877f9..2895202ed7f 100644 --- a/tests/acceptance/features/bootstrap/PublicShareContext.php +++ b/tests/acceptance/features/bootstrap/PublicShareContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class PublicShareContext implements Context, ActorAwareInterface { use ActorAware; @@ -143,7 +144,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that the current page is the Authenticate page for the shared link I wrote down */ public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->getSharedNotebook()["shared link"] . "/authenticate/showShare", $this->actor->getSession()->getCurrentUrl()); } @@ -152,7 +153,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that the current page is the Authenticate page for the direct download shared link I wrote down */ public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheDirectDownloadSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->getSharedNotebook()["shared link"] . "/authenticate/downloadShare", $this->actor->getSession()->getCurrentUrl()); } @@ -161,7 +162,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that the current page is the shared link I wrote down */ public function iSeeThatTheCurrentPageIsTheSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->getSharedNotebook()["shared link"], $this->actor->getSession()->getCurrentUrl()); @@ -172,7 +173,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that the current page is the direct download shared link I wrote down */ public function iSeeThatTheCurrentPageIsTheDirectDownloadSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->getSharedNotebook()["shared link"] . "/download", $this->actor->getSession()->getCurrentUrl()); } @@ -181,7 +182,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that a wrong password for the shared file message is shown */ public function iSeeThatAWrongPasswordForTheSharedFileMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible()); } @@ -194,19 +195,19 @@ class PublicShareContext implements Context, ActorAwareInterface { // command not having been processed by the browser. if (!WaitFor::elementToBeEventuallyShown( $this->actor, self::shareMenu(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The Share menu is not visible yet after $timeout seconds"); + Assert::fail("The Share menu is not visible yet after $timeout seconds"); } // The acceptance tests are run in a window wider than the mobile breakpoint, so the // download item should not be shown in the menu (although it will be in // the DOM). - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::downloadItemInShareMenu())->isVisible(), "Download item in share menu is visible"); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::directLinkItemInShareMenu())->isVisible(), "Direct link item in share menu is not visible"); - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::saveItemInShareMenu())->isVisible(), "Save item in share menu is not visible"); } @@ -216,7 +217,7 @@ class PublicShareContext implements Context, ActorAwareInterface { */ public function iSeeThatTheShareMenuButtonIsNotShown() { try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::shareMenuButton())->isVisible()); } catch (NoSuchElementException $exception) { } @@ -226,7 +227,7 @@ class PublicShareContext implements Context, ActorAwareInterface { * @Then I see that the shared file preview shows the text :text */ public function iSeeThatTheSharedFilePreviewShowsTheText($text) { - PHPUnit_Framework_Assert::assertContains($text, $this->actor->find(self::textPreview(), 10)->getText()); + Assert::assertContains($text, $this->actor->find(self::textPreview(), 10)->getText()); } /** @@ -235,7 +236,7 @@ class PublicShareContext implements Context, ActorAwareInterface { public function iSeeThatTheDownloadButtonIsShown() { if (!WaitFor::elementToBeEventuallyShown( $this->actor, self::downloadButton(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The download button is not visible yet after $timeout seconds"); + Assert::fail("The download button is not visible yet after $timeout seconds"); } } @@ -244,7 +245,7 @@ class PublicShareContext implements Context, ActorAwareInterface { */ public function iSeeThatTheDownloadButtonIsNotShown() { try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::downloadButton())->isVisible()); } catch (NoSuchElementException $exception) { } diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php index bd4ba2beaef..ba0d9d9933d 100644 --- a/tests/acceptance/features/bootstrap/SearchContext.php +++ b/tests/acceptance/features/bootstrap/SearchContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class SearchContext implements Context, ActorAwareInterface { use ActorAware; @@ -99,7 +100,7 @@ class SearchContext implements Context, ActorAwareInterface { * @Then I see that the search result :number is :name */ public function iSeeThatTheSearchResultIs($number, $name) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $name, $this->actor->find(self::searchResultName($number), 10)->getText()); } @@ -107,7 +108,7 @@ class SearchContext implements Context, ActorAwareInterface { * @Then I see that the search result :number was found in :path */ public function iSeeThatTheSearchResultWasFoundIn($number, $path) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $path, $this->actor->find(self::searchResultPath($number), 10)->getText()); } } diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php index 6b60b2c3176..1e0eadd044a 100644 --- a/tests/acceptance/features/bootstrap/SettingsContext.php +++ b/tests/acceptance/features/bootstrap/SettingsContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class SettingsContext implements Context, ActorAwareInterface { use ActorAware; @@ -180,7 +181,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that shares are accepted by default */ public function iSeeThatSharesAreAcceptedByDefault() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked()); } @@ -188,7 +189,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that resharing is enabled */ public function iSeeThatResharingIsEnabled() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked()); } @@ -196,7 +197,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that resharing is disabled */ public function iSeeThatResharingIsDisabled() { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked()); } @@ -204,7 +205,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that username autocompletion is restricted to groups */ public function iSeeThatUsernameAutocompletionIsRestrictedToGroups() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked()); } @@ -212,7 +213,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that username autocompletion is not restricted to groups */ public function iSeeThatUsernameAutocompletionIsNotRestrictedToGroups() { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked()); } @@ -220,7 +221,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that shares are not accepted by default */ public function iSeeThatSharesAreNotAcceptedByDefault() { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked()); } @@ -228,7 +229,7 @@ class SettingsContext implements Context, ActorAwareInterface { * @Then I see that the button to select tags is shown */ public function iSeeThatTheButtonToSelectTagsIsShown() { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); + Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); } /** @@ -243,7 +244,7 @@ class SettingsContext implements Context, ActorAwareInterface { // necessary to repeatedly open the dropdown until the tag is shown in // the dropdown (or the limit of tries is reached). - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); + Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); $actor = $this->actor; @@ -277,6 +278,6 @@ class SettingsContext implements Context, ActorAwareInterface { } } - PHPUnit_Framework_Assert::fail("The dropdown in system tags section in Administration Settings does not contain the tag $tag after $numberOfTries tries"); + Assert::fail("The dropdown in system tags section in Administration Settings does not contain the tag $tag after $numberOfTries tries"); } } diff --git a/tests/acceptance/features/bootstrap/SettingsMenuContext.php b/tests/acceptance/features/bootstrap/SettingsMenuContext.php index 678d7c5eabb..1572dea3faa 100644 --- a/tests/acceptance/features/bootstrap/SettingsMenuContext.php +++ b/tests/acceptance/features/bootstrap/SettingsMenuContext.php @@ -23,6 +23,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class SettingsMenuContext implements Context, ActorAwareInterface { use ActorAware; @@ -155,7 +156,7 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @Then I see that the Settings menu is shown */ public function iSeeThatTheSettingsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::settingsMenu(), 10)->isVisible()); } @@ -163,14 +164,14 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @Then I see that the Settings menu has only :items items */ public function iSeeThatTheSettingsMenuHasOnlyXItems($items) { - PHPUnit_Framework_Assert::assertCount(intval($items), self::menuItems()); + Assert::assertCount(intval($items), self::menuItems()); } /** * @Then I see that the :itemText item in the Settings menu is shown */ public function iSeeThatTheItemInTheSettingsMenuIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::menuItemFor($itemText), 10)->isVisible()); } @@ -181,7 +182,7 @@ class SettingsMenuContext implements Context, ActorAwareInterface { $this->iSeeThatTheSettingsMenuIsShown(); try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::menuItemFor($itemText))->isVisible()); } catch (NoSuchElementException $exception) { } @@ -191,7 +192,7 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @Then I see that the :itemText settings panel is shown */ public function iSeeThatTheItemSettingsPanelIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible() ); } @@ -200,7 +201,7 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @Then I see that the :itemText entry in the settings panel is shown */ public function iSeeThatTheItemEntryInTheSettingsPanelIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::settingsPanelEntryFor($itemText), 10)->isVisible() ); } @@ -210,7 +211,7 @@ class SettingsMenuContext implements Context, ActorAwareInterface { */ public function iSeeThatTheItemSettingsPanelIsNotShown($itemText) { try { - PHPUnit_Framework_Assert::assertFalse( + Assert::assertFalse( $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible() ); } catch (NoSuchElementException $exception) { diff --git a/tests/acceptance/features/bootstrap/ThemingAppContext.php b/tests/acceptance/features/bootstrap/ThemingAppContext.php index de25bafd6c3..70fb2b01e16 100644 --- a/tests/acceptance/features/bootstrap/ThemingAppContext.php +++ b/tests/acceptance/features/bootstrap/ThemingAppContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class ThemingAppContext implements Context, ActorAwareInterface { use ActorAware; @@ -88,7 +89,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { // background of the input element, it means the color element has been // initialized. - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::inputFieldFor("Color"), 10)->isVisible()); + Assert::assertTrue($this->actor->find(self::inputFieldFor("Color"), 10)->isVisible()); $actor = $this->actor; @@ -103,7 +104,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { }; if (!Utils::waitFor($colorSelectorLoadedCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The color selector in Theming app has not been loaded after $timeout seconds"); + Assert::fail("The color selector in Theming app has not been loaded after $timeout seconds"); } } @@ -117,7 +118,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { // HEX Color, convert to RGB array. $tmpColor = sscanf($color, "%02X%02X%02X"); } else { - PHPUnit_Framework_Assert::fail("The acceptance test does not know how to handle the color string : '$color'. " + Assert::fail("The acceptance test does not know how to handle the color string : '$color'. " . "Please provide # before HEX colors in your features."); } return $tmpColor; @@ -136,7 +137,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { }; if (!Utils::waitFor($headerColorMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The header color is not $color yet after $timeout seconds"); + Assert::fail("The header color is not $color yet after $timeout seconds"); } } @@ -144,7 +145,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { * @Then I see that the parameters in the Theming app are eventually saved */ public function iSeeThatTheParametersInTheThemingAppAreEventuallySaved() { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::statusMessage(), 10)->isVisible()); + Assert::assertTrue($this->actor->find(self::statusMessage(), 10)->isVisible()); $actor = $this->actor; @@ -157,7 +158,7 @@ class ThemingAppContext implements Context, ActorAwareInterface { }; if (!Utils::waitFor($savedStatusMessageShownCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The 'Saved' status messages in Theming app has not been shown after $timeout seconds"); + Assert::fail("The 'Saved' status messages in Theming app has not been shown after $timeout seconds"); } } } diff --git a/tests/acceptance/features/bootstrap/ToastContext.php b/tests/acceptance/features/bootstrap/ToastContext.php index 5a67d7f2581..3dc941901c1 100644 --- a/tests/acceptance/features/bootstrap/ToastContext.php +++ b/tests/acceptance/features/bootstrap/ToastContext.php @@ -22,6 +22,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class ToastContext implements Context, ActorAwareInterface { use ActorAware; @@ -47,7 +48,7 @@ class ToastContext implements Context, ActorAwareInterface { * @Then I see that the :message toast is shown */ public function iSeeThatTheToastIsShown($message) { - PHPUnit_Framework_Assert::assertTrue($this->actor->find( + Assert::assertTrue($this->actor->find( self::toastMessage($message), 10)->isVisible()); } } diff --git a/tests/acceptance/features/bootstrap/UsersSettingsContext.php b/tests/acceptance/features/bootstrap/UsersSettingsContext.php index 6b0aa787791..02e1825e4c9 100644 --- a/tests/acceptance/features/bootstrap/UsersSettingsContext.php +++ b/tests/acceptance/features/bootstrap/UsersSettingsContext.php @@ -24,6 +24,7 @@ */ use Behat\Behat\Context\Context; +use PHPUnit\Framework\Assert; class UsersSettingsContext implements Context, ActorAwareInterface { use ActorAware; @@ -271,7 +272,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor, self::rowForUser($user), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The user $user in the list of users is not shown yet after $timeout seconds"); + Assert::fail("The user $user in the list of users is not shown yet after $timeout seconds"); } } @@ -283,7 +284,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor, self::rowForUser($user), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The user $user in the list of users is still shown after $timeout seconds"); + Assert::fail("The user $user in the list of users is still shown after $timeout seconds"); } } @@ -291,7 +292,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the new user form is shown */ public function iSeeThatTheNewUserFormIsShown() { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::newUserForm(), 10)->isVisible()); } @@ -299,7 +300,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the :action action in the :user actions menu is shown */ public function iSeeTheAction($action, $user) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::theAction($action, $user), 10)->isVisible()); } @@ -307,7 +308,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the :column column is shown */ public function iSeeThatTheColumnIsShown($column) { - PHPUnit_Framework_Assert::assertTrue( + Assert::assertTrue( $this->actor->find(self::theColumn($column), 10)->isVisible()); } @@ -315,7 +316,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the :field of :user is :value */ public function iSeeThatTheFieldOfUserIs($field, $user, $value) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::inputForUserInCell($field, $user), 10)->getValue(), $value); } @@ -323,7 +324,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the display name for the user :user is :displayName */ public function iSeeThatTheDisplayNameForTheUserIs($user, $displayName) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $displayName, $this->actor->find(self::displayNameCellForUser($user), 10)->getValue()); } @@ -349,7 +350,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor, self::classCellForUser($cell . ' icon-loading-small', $user), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The loading icon for user $user is still shown after $timeout seconds"); + Assert::fail("The loading icon for user $user is still shown after $timeout seconds"); } } @@ -357,7 +358,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { * @Then I see that the user quota of :user is :quota */ public function iSeeThatTheuserQuotaIs($user, $quota) { - PHPUnit_Framework_Assert::assertEquals( + Assert::assertEquals( $this->actor->find(self::selectedSelectOption('quota', $user), 2)->getText(), $quota); } @@ -369,7 +370,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor, self::editModeOn($user), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The edit mode for user $user in the list of users is not on yet after $timeout seconds"); + Assert::fail("The edit mode for user $user in the list of users is not on yet after $timeout seconds"); } } } diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php index 932af5ff277..b3c8b6f0459 100644 --- a/tests/acceptance/features/core/ActorContext.php +++ b/tests/acceptance/features/core/ActorContext.php @@ -135,6 +135,8 @@ class ActorContext extends RawMinkContext { $this->actors = []; $this->sharedNotebook = []; + $this->getSession()->start(); + $this->actors["default"] = new Actor("default", $this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook); $this->actors["default"]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier); @@ -159,6 +161,8 @@ class ActorContext extends RawMinkContext { */ public function iActAs($actorName) { if (!array_key_exists($actorName, $this->actors)) { + $this->getSession($actorName)->start(); + $this->actors[$actorName] = new Actor($actorName, $this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook); $this->actors[$actorName]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier); } diff --git a/tests/data/db_structure.xml b/tests/data/db_structure.xml deleted file mode 100644 index b155114f2ed..00000000000 --- a/tests/data/db_structure.xml +++ /dev/null @@ -1,311 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<database> - - <name>*dbname*</name> - <create>false</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*cntcts_addrsbks</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - <comments>This is the id</comments> - </field> - - <field> - <name>userid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>displayname</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <field> - <name>uri</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>200</length> - </field> - - <field> - <name>description</name> - <type>text</type> - <notnull>false</notnull> - <length>255</length> - </field> - - <field> - <name>ctag</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>active</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <length>4</length> - </field> - - </declaration> - - </table> - - <table> - - <name>*dbprefix*cntcts_cards</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>addressbookid</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>fullname</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <field> - <name>carddata</name> - <type>clob</type> - <notnull>false</notnull> - </field> - - <field> - <name>uri</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>200</length> - </field> - - <field> - <name>lastmodified</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - </declaration> - - </table> - - <table> - - <name>*dbprefix*vcategory</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>category</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - </declaration> - </table> - - <table> - <name>*dbprefix*timestamp</name> - <declaration> - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>timestamptest</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - </declaration> - </table> - - <table> - <name>*dbprefix*decimal</name> - <declaration> - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>decimaltest</name> - <type>decimal</type> - <default/> - <notnull>true</notnull> - <precision>12</precision> - <scale>2</scale> - </field> - </declaration> - </table> - -<table> - <name>*dbprefix*migratekeyword</name> - - <declaration> - - <field> - <name>select</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - </declaration> -</table> - - <table> - <name>*dbprefix*uniconst</name> - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - - <!-- Foreign Key storages::numeric_id --> - <field> - <name>storage</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>path_hash</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>32</length> - </field> - - <field> - <name>etag</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>40</length> - </field> - - <index> - <!--<name>fs_storage_path_hash</name>--> - <unique>true</unique> - <field> - <name>storage</name> - <sorting>ascending</sorting> - </field> - <field> - <name>path_hash</name> - <sorting>ascending</sorting> - </field> - </index> - - </declaration> - - </table> - - <table> - - <name>*dbprefix*text_table</name> - <declaration> - - <field> - <name>textfield</name> - <type>text</type> - <notnull>false</notnull> - <length>255</length> - </field> - - </declaration> - </table> - -</database> diff --git a/tests/data/db_structure2.xml b/tests/data/db_structure2.xml deleted file mode 100644 index 568d90ab0a9..00000000000 --- a/tests/data/db_structure2.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<database> - - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*cntcts_addrsbks</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>userid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>displayname</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <field> - <name>uri</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>200</length> - </field> - - <field> - <name>description</name> - <type>text</type> - <notnull>false</notnull> - <length>1024</length> - </field> - - <field> - <name>ctag</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>active</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <length>1</length> - </field> - - </declaration> - - </table> - - <table> - <name>*dbprefix*timestamp</name> - <declaration> - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>timestamptest</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - </declaration> - </table> - - <table> - <name>*dbprefix*decimal</name> - <declaration> - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>decimaltest</name> - <type>decimal</type> - <default/> - <notnull>true</notnull> - <precision>12</precision> - <scale>2</scale> - </field> - </declaration> - </table> - - <table> - <name>*dbprefix*migratekeyword</name> - - <declaration> - - <field> - <name>select</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - </declaration> - </table> - -</database> diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index fcd1a78add7..27ebed69793 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -153,6 +153,129 @@ class AccountManagerTest extends TestCase { ]; } + public function updateUserSetScopeProvider() { + return [ + // regular scope switching + [ + [ + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_AVATAR => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_ADDRESS => ['value' => 'some street', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::SCOPE_PRIVATE], + ], + [ + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PRIVATE], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_ADDRESS => ['value' => 'some street', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::SCOPE_PUBLISHED], + ], + [ + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PRIVATE], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_ADDRESS => ['value' => 'some street', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::SCOPE_PUBLISHED], + ], + ], + // legacy scope mapping, the given visibility values get converted to scopes + [ + [ + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::SCOPE_PRIVATE], + ], + [ + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::VISIBILITY_PUBLIC], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::VISIBILITY_PRIVATE], + ], + [ + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_FEDERATED], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://example.org', 'scope' => IAccountManager::SCOPE_LOCAL], + ], + ], + // invalid or unsupported scope values get converted to SCOPE_LOCAL + [ + [ + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_FEDERATED], + ], + [ + // SCOPE_PRIVATE is not allowed for display name and email + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_PRIVATE], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_PRIVATE], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => 'invalid'], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => ''], + ], + [ + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_LOCAL], + IAccountManager::PROPERTY_PHONE => ['value' => '+491601231212', 'scope' => IAccountManager::SCOPE_LOCAL], + ], + // don't throw but fall back + false, false, + ], + // invalid or unsupported scope values throw an exception when passing $throwOnData=true + [ + [IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_PUBLISHED]], + [IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'Display Name', 'scope' => IAccountManager::SCOPE_PRIVATE]], + null, + // throw exception + true, true, + ], + [ + [IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_PUBLISHED]], + [IAccountManager::PROPERTY_EMAIL => ['value' => 'test@example.org', 'scope' => IAccountManager::SCOPE_PRIVATE]], + null, + // throw exception + true, true, + ], + [ + [IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => IAccountManager::SCOPE_PUBLISHED]], + [IAccountManager::PROPERTY_TWITTER => ['value' => '@sometwitter', 'scope' => 'invalid']], + null, + // throw exception + true, true, + ], + ]; + } + + /** + * @dataProvider updateUserSetScopeProvider + */ + public function testUpdateUserSetScope($oldData, $newData, $savedData, $throwOnData = true, $expectedThrow = false) { + $accountManager = $this->getInstance(['getUser', 'insertNewUser', 'updateExistingUser', 'updateVerifyStatus', 'checkEmailVerification']); + /** @var IUser $user */ + $user = $this->createMock(IUser::class); + + $accountManager->expects($this->once())->method('getUser')->with($user)->willReturn($oldData); + + if ($expectedThrow) { + $accountManager->expects($this->never())->method('updateExistingUser'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('scope'); + } else { + $accountManager->expects($this->once())->method('checkEmailVerification') + ->with($oldData, $savedData, $user)->willReturn($savedData); + $accountManager->expects($this->once())->method('updateVerifyStatus') + ->with($oldData, $savedData)->willReturn($savedData); + $accountManager->expects($this->once())->method('updateExistingUser') + ->with($user, $savedData); + $accountManager->expects($this->never())->method('insertNewUser'); + } + + $accountManager->updateUser($user, $newData, $throwOnData); + } /** * @dataProvider dataTestGetUser @@ -278,26 +401,26 @@ class AccountManagerTest extends TestCase { IAccountManager::PROPERTY_TWITTER => [ 'value' => '@twitterhandle', - 'scope' => IAccountManager::VISIBILITY_PRIVATE, + 'scope' => IAccountManager::SCOPE_LOCAL, 'verified' => IAccountManager::NOT_VERIFIED, ], IAccountManager::PROPERTY_EMAIL => [ 'value' => 'test@example.com', - 'scope' => IAccountManager::VISIBILITY_PUBLIC, + 'scope' => IAccountManager::SCOPE_PUBLISHED, 'verified' => IAccountManager::VERIFICATION_IN_PROGRESS, ], IAccountManager::PROPERTY_WEBSITE => [ 'value' => 'https://example.com', - 'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY, + 'scope' => IAccountManager::SCOPE_FEDERATED, 'verified' => IAccountManager::VERIFIED, ], ]; $expected = new Account($user); - $expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::NOT_VERIFIED); - $expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFICATION_IN_PROGRESS); - $expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::VERIFIED); + $expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::SCOPE_LOCAL, IAccountManager::NOT_VERIFIED); + $expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFICATION_IN_PROGRESS); + $expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_FEDERATED, IAccountManager::VERIFIED); $accountManager->expects($this->once()) ->method('getUser') diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index afd807a44b4..f99abc21f83 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/tests/lib/Accounts/AccountPropertyTest.php @@ -37,12 +37,12 @@ class AccountPropertyTest extends TestCase { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED ); $this->assertEquals(IAccountManager::PROPERTY_WEBSITE, $accountProperty->getName()); $this->assertEquals('https://example.com', $accountProperty->getValue()); - $this->assertEquals(IAccountManager::VISIBILITY_PUBLIC, $accountProperty->getScope()); + $this->assertEquals(IAccountManager::SCOPE_PUBLISHED, $accountProperty->getScope()); $this->assertEquals(IAccountManager::VERIFIED, $accountProperty->getVerified()); } @@ -50,7 +50,7 @@ class AccountPropertyTest extends TestCase { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED ); $actualReturn = $accountProperty->setValue('https://example.org'); @@ -62,19 +62,48 @@ class AccountPropertyTest extends TestCase { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED ); - $actualReturn = $accountProperty->setScope(IAccountManager::VISIBILITY_PRIVATE); - $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $accountProperty->getScope()); - $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $actualReturn->getScope()); + $actualReturn = $accountProperty->setScope(IAccountManager::SCOPE_LOCAL); + $this->assertEquals(IAccountManager::SCOPE_LOCAL, $accountProperty->getScope()); + $this->assertEquals(IAccountManager::SCOPE_LOCAL, $actualReturn->getScope()); + } + + public function scopesProvider() { + return [ + // current values + [IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE], + [IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL], + [IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED], + // legacy values + [IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL], + [IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::SCOPE_FEDERATED], + [IAccountManager::VISIBILITY_PUBLIC, IAccountManager::SCOPE_PUBLISHED], + // fallback + ['', IAccountManager::SCOPE_LOCAL], + ['unknown', IAccountManager::SCOPE_LOCAL], + ]; + } + + /** + * @dataProvider scopesProvider + */ + public function testSetScopeMapping($storedScope, $returnedScope) { + $accountProperty = new AccountProperty( + IAccountManager::PROPERTY_WEBSITE, + 'https://example.com', + $storedScope, + IAccountManager::VERIFIED + ); + $this->assertEquals($returnedScope, $accountProperty->getScope()); } public function testSetVerified() { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED ); $actualReturn = $accountProperty->setVerified(IAccountManager::NOT_VERIFIED); @@ -86,13 +115,13 @@ class AccountPropertyTest extends TestCase { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED ); $this->assertEquals([ 'name' => IAccountManager::PROPERTY_WEBSITE, 'value' => 'https://example.com', - 'scope' => IAccountManager::VISIBILITY_PUBLIC, + 'scope' => IAccountManager::SCOPE_PUBLISHED, 'verified' => IAccountManager::VERIFIED ], $accountProperty->jsonSerialize()); } diff --git a/tests/lib/Accounts/AccountTest.php b/tests/lib/Accounts/AccountTest.php index 11b13637bd0..8afcc44afd1 100644 --- a/tests/lib/Accounts/AccountTest.php +++ b/tests/lib/Accounts/AccountTest.php @@ -43,21 +43,21 @@ class AccountTest extends TestCase { public function testSetProperty() { $user = $this->createMock(IUser::class); - $property = new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $property = new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); $account = new Account($user); - $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); $this->assertEquals($property, $account->getProperty(IAccountManager::PROPERTY_WEBSITE)); } public function testGetProperties() { $user = $this->createMock(IUser::class); $properties = [ - IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), - IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED) + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED) ]; $account = new Account($user); - $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); - $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED); $this->assertEquals($properties, $account->getProperties()); } @@ -65,14 +65,14 @@ class AccountTest extends TestCase { public function testGetFilteredProperties() { $user = $this->createMock(IUser::class); $properties = [ - IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), - IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED), - IAccountManager::PROPERTY_PHONE => new AccountProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED), + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED), + IAccountManager::PROPERTY_PHONE => new AccountProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED), ]; $account = new Account($user); - $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); - $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); - $account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED); $this->assertEquals( @@ -80,7 +80,7 @@ class AccountTest extends TestCase { IAccountManager::PROPERTY_WEBSITE => $properties[IAccountManager::PROPERTY_WEBSITE], IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], ], - $account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC) + $account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED) ); $this->assertEquals( [ @@ -91,19 +91,19 @@ class AccountTest extends TestCase { ); $this->assertEquals( [IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE]], - $account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED) + $account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED) ); } public function testJsonSerialize() { $user = $this->createMock(IUser::class); $properties = [ - IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), - IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED) + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED) ]; $account = new Account($user); - $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); - $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED); $this->assertEquals($properties, $account->jsonSerialize()); } diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php index 5a061cd10e9..d3bc60efb59 100644 --- a/tests/lib/Avatar/AvatarManagerTest.php +++ b/tests/lib/Avatar/AvatarManagerTest.php @@ -25,19 +25,27 @@ namespace Test\Avatar; use OC\Avatar\AvatarManager; +use OC\Avatar\PlaceholderAvatar; use OC\Avatar\UserAvatar; +use OC\KnownUser\KnownUserService; use OC\User\Manager; +use OCP\Accounts\IAccount; +use OCP\Accounts\IAccountManager; +use OCP\Accounts\IAccountProperty; use OCP\Files\IAppData; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; use OCP\IUser; +use OCP\IUserSession; /** * Class AvatarManagerTest */ class AvatarManagerTest extends \Test\TestCase { + /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + private $userSession; /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */ private $userManager; /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ @@ -48,28 +56,37 @@ class AvatarManagerTest extends \Test\TestCase { private $logger; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; + /** @var IAccountManager|\PHPUnit\Framework\MockObject\MockObject */ + private $accountManager; /** @var AvatarManager | \PHPUnit\Framework\MockObject\MockObject */ private $avatarManager; + /** @var KnownUserService | \PHPUnit\Framework\MockObject\MockObject */ + private $knownUserService; protected function setUp(): void { parent::setUp(); + $this->userSession = $this->createMock(IUserSession::class); $this->userManager = $this->createMock(Manager::class); $this->appData = $this->createMock(IAppData::class); $this->l10n = $this->createMock(IL10N::class); $this->logger = $this->createMock(ILogger::class); $this->config = $this->createMock(IConfig::class); + $this->accountManager = $this->createMock(IAccountManager::class); + $this->knownUserService = $this->createMock(KnownUserService::class); $this->avatarManager = new AvatarManager( + $this->userSession, $this->userManager, $this->appData, $this->l10n, $this->logger, - $this->config + $this->config, + $this->accountManager, + $this->knownUserService ); } - public function testGetAvatarInvalidUser() { $this->expectException(\Exception::class); $this->expectExceptionMessage('user does not exist'); @@ -83,17 +100,45 @@ class AvatarManagerTest extends \Test\TestCase { $this->avatarManager->getAvatar('invalidUser'); } - public function testGetAvatarValidUser() { + public function testGetAvatarForSelf() { $user = $this->createMock(IUser::class); $user - ->expects($this->once()) + ->expects($this->any()) ->method('getUID') ->willReturn('valid-user'); + + // requesting user + $this->userSession->expects($this->once()) + ->method('getUser') + ->willReturn($user); + $this->userManager ->expects($this->once()) ->method('get') ->with('valid-user') ->willReturn($user); + + $account = $this->createMock(IAccount::class); + $this->accountManager->expects($this->once()) + ->method('getAccount') + ->with($user) + ->willReturn($account); + + $property = $this->createMock(IAccountProperty::class); + $account->expects($this->once()) + ->method('getProperty') + ->with(IAccountManager::PROPERTY_AVATAR) + ->willReturn($property); + + $property->expects($this->once()) + ->method('getScope') + ->willReturn(IAccountManager::SCOPE_PRIVATE); + + $this->knownUserService->expects($this->any()) + ->method('isKnownToUser') + ->with('valid-user', 'valid-user') + ->willReturn(true); + $folder = $this->createMock(ISimpleFolder::class); $this->appData ->expects($this->once()) @@ -126,4 +171,86 @@ class AvatarManagerTest extends \Test\TestCase { $expected = new UserAvatar($folder, $this->l10n, $user, $this->logger, $this->config); $this->assertEquals($expected, $this->avatarManager->getAvatar('vaLid-USER')); } + + public function knownUnknownProvider() { + return [ + [IAccountManager::SCOPE_LOCAL, false, false, false], + [IAccountManager::SCOPE_LOCAL, true, false, false], + + // public access cannot see real avatar + [IAccountManager::SCOPE_PRIVATE, true, false, true], + // unknown users cannot see real avatar + [IAccountManager::SCOPE_PRIVATE, false, false, true], + // known users can see real avatar + [IAccountManager::SCOPE_PRIVATE, false, true, false], + ]; + } + + /** + * @dataProvider knownUnknownProvider + */ + public function testGetAvatarScopes($avatarScope, $isPublicCall, $isKnownUser, $expectedPlaceholder) { + if ($isPublicCall) { + $requestingUser = null; + } else { + $requestingUser = $this->createMock(IUser::class); + $requestingUser->method('getUID')->willReturn('requesting-user'); + } + + // requesting user + $this->userSession->expects($this->once()) + ->method('getUser') + ->willReturn($requestingUser); + + $user = $this->createMock(IUser::class); + $user + ->expects($this->once()) + ->method('getUID') + ->willReturn('valid-user'); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('valid-user') + ->willReturn($user); + + $account = $this->createMock(IAccount::class); + $this->accountManager->expects($this->once()) + ->method('getAccount') + ->with($user) + ->willReturn($account); + + $property = $this->createMock(IAccountProperty::class); + $account->expects($this->once()) + ->method('getProperty') + ->with(IAccountManager::PROPERTY_AVATAR) + ->willReturn($property); + + $property->expects($this->once()) + ->method('getScope') + ->willReturn($avatarScope); + + $folder = $this->createMock(ISimpleFolder::class); + $this->appData + ->expects($this->once()) + ->method('getFolder') + ->with('valid-user') + ->willReturn($folder); + + if (!$isPublicCall) { + $this->knownUserService->expects($this->any()) + ->method('isKnownToUser') + ->with('requesting-user', 'valid-user') + ->willReturn($isKnownUser); + } else { + $this->knownUserService->expects($this->never()) + ->method('isKnownToUser'); + } + + if ($expectedPlaceholder) { + $expected = new PlaceholderAvatar($folder, $user, $this->createMock(ILogger::class)); + } else { + $expected = new UserAvatar($folder, $this->l10n, $user, $this->logger, $this->config); + } + $this->assertEquals($expected, $this->avatarManager->getAvatar('valid-user')); + } } diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php deleted file mode 100644 index d628d9814e0..00000000000 --- a/tests/lib/DB/ConnectionTest.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php - -/** - * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -use Doctrine\DBAL\Platforms\SqlitePlatform; -use OC\DB\MDB2SchemaManager; -use OCP\DB\QueryBuilder\IQueryBuilder; - -/** - * Class Connection - * - * @group DB - * - * @package Test\DB - */ -class ConnectionTest extends \Test\TestCase { - /** - * @var \OCP\IDBConnection - */ - private $connection; - - public static function setUpBeforeClass(): void { - self::dropTestTable(); - parent::setUpBeforeClass(); - } - - public static function tearDownAfterClass(): void { - self::dropTestTable(); - parent::tearDownAfterClass(); - } - - protected static function dropTestTable() { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') { - \OC::$server->getDatabaseConnection()->dropTable('table'); - } - } - - protected function setUp(): void { - parent::setUp(); - $this->connection = \OC::$server->get(\OC\DB\Connection::class); - } - - protected function tearDown(): void { - parent::tearDown(); - $this->connection->dropTable('table'); - } - - /** - * @param string $table - */ - public function assertTableExist($table) { - if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { - // sqlite removes the tables after closing the DB - $this->addToAssertionCount(1); - } else { - $this->assertTrue($this->connection->tableExists($table), 'Table ' . $table . ' exists.'); - } - } - - /** - * @param string $table - */ - public function assertTableNotExist($table) { - if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { - // sqlite removes the tables after closing the DB - $this->addToAssertionCount(1); - } else { - $this->assertFalse($this->connection->tableExists($table), 'Table ' . $table . " doesn't exist."); - } - } - - private function makeTestTable() { - $schemaManager = new MDB2SchemaManager($this->connection); - $schemaManager->createDbFromStructure(__DIR__ . '/testschema.xml'); - } - - public function testTableExists() { - $this->assertTableNotExist('table'); - $this->makeTestTable(); - $this->assertTableExist('table'); - } - - /** - * @depends testTableExists - */ - public function testDropTable() { - $this->makeTestTable(); - $this->assertTableExist('table'); - $this->connection->dropTable('table'); - $this->assertTableNotExist('table'); - } - - private function getTextValueByIntegerField($integerField) { - $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('*') - ->from('table') - ->where($builder->expr()->eq('integerfield', $builder->createNamedParameter($integerField, IQueryBuilder::PARAM_INT))); - - $result = $query->execute(); - $row = $result->fetch(); - $result->closeCursor(); - - return $row['textfield'] ?? null; - } - - public function testSetValues() { - $this->makeTestTable(); - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo', - 'clobfield' => 'not_null' - ]); - - $this->assertEquals('foo', $this->getTextValueByIntegerField(1)); - } - - public function testSetValuesOverWrite() { - $this->makeTestTable(); - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo' - ]); - - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'bar' - ]); - - $this->assertEquals('bar', $this->getTextValueByIntegerField(1)); - } - - public function testSetValuesOverWritePrecondition() { - $this->makeTestTable(); - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo', - 'booleanfield' => true, - 'clobfield' => 'not_null' - ]); - - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'bar' - ], [ - 'booleanfield' => true - ]); - - $this->assertEquals('bar', $this->getTextValueByIntegerField(1)); - } - - - public function testSetValuesOverWritePreconditionFailed() { - $this->expectException(\OCP\PreConditionNotMetException::class); - - $this->makeTestTable(); - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo', - 'booleanfield' => true, - 'clobfield' => 'not_null' - ]); - - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'bar' - ], [ - 'booleanfield' => false - ]); - } - - public function testSetValuesSameNoError() { - $this->makeTestTable(); - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo', - 'clobfield' => 'not_null' - ]); - - // this will result in 'no affected rows' on certain optimizing DBs - // ensure the PreConditionNotMetException isn't thrown - $this->connection->setValues('table', [ - 'integerfield' => 1 - ], [ - 'textfield' => 'foo' - ]); - - $this->addToAssertionCount(1); - } - - public function testInsertIfNotExist() { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { - self::markTestSkipped('Insert if not exist does not work with clob on oracle'); - } - - $this->makeTestTable(); - $categoryEntries = [ - ['user' => 'test', 'category' => 'Family', 'expectedResult' => 1], - ['user' => 'test', 'category' => 'Friends', 'expectedResult' => 1], - ['user' => 'test', 'category' => 'Coworkers', 'expectedResult' => 1], - ['user' => 'test', 'category' => 'Coworkers', 'expectedResult' => 0], - ['user' => 'test', 'category' => 'School', 'expectedResult' => 1], - ['user' => 'test2', 'category' => 'Coworkers2', 'expectedResult' => 1], - ['user' => 'test2', 'category' => 'Coworkers2', 'expectedResult' => 0], - ['user' => 'test2', 'category' => 'School2', 'expectedResult' => 1], - ['user' => 'test2', 'category' => 'Coworkers', 'expectedResult' => 1], - ]; - - $row = 0; - foreach ($categoryEntries as $entry) { - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'textfield' => $entry['user'], - 'clobfield' => $entry['category'], - 'integerfield' => $row++, - ], ['textfield', 'clobfield']); - $this->assertEquals($entry['expectedResult'], $result, json_encode($entry)); - } - - $query = $this->connection->prepare('SELECT * FROM `*PREFIX*table`'); - $result = $query->execute(); - $this->assertTrue((bool)$result); - $this->assertEquals(7, count($result->fetchAll())); - } - - public function testInsertIfNotExistNull() { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { - self::markTestSkipped('Insert if not exist does not work with clob on oracle'); - } - - $this->makeTestTable(); - $categoryEntries = [ - ['addressbookid' => 123, 'fullname' => null, 'expectedResult' => 1], - ['addressbookid' => 123, 'fullname' => null, 'expectedResult' => 0], - ['addressbookid' => 123, 'fullname' => 'test', 'expectedResult' => 1], - ]; - - $row = 0; - foreach ($categoryEntries as $entry) { - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'integerfield_default' => $entry['addressbookid'], - 'clobfield' => $entry['fullname'], - 'integerfield' => $row++, - ], ['integerfield_default', 'clobfield']); - $this->assertEquals($entry['expectedResult'], $result, json_encode($entry)); - } - - $query = $this->connection->prepare('SELECT * FROM `*PREFIX*table`'); - $result = $query->execute(); - $this->assertTrue((bool)$result); - $this->assertEquals(2, count($result->fetchAll())); - } - - public function testInsertIfNotExistDonTOverwrite() { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { - self::markTestSkipped('Insert if not exist does not work with clob on oracle'); - } - - $this->makeTestTable(); - $fullName = 'fullname test'; - $uri = 'uri_1'; - - // Normal test to have same known data inserted. - $query = $this->connection->prepare('INSERT INTO `*PREFIX*table` (`textfield`, `clobfield`) VALUES (?, ?)'); - $result = $query->execute([$fullName, $uri]); - $this->assertEquals(1, $result->rowCount()); - $query = $this->connection->prepare('SELECT `textfield`, `clobfield` FROM `*PREFIX*table` WHERE `clobfield` = ?'); - $result = $query->execute([$uri]); - $rowset = $result->fetchAll(); - $this->assertEquals(1, count($rowset)); - $this->assertArrayHasKey('textfield', $rowset[0]); - $this->assertEquals($fullName, $rowset[0]['textfield']); - - // Try to insert a new row - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'textfield' => $fullName, - 'clobfield' => $uri, - ]); - $this->assertEquals(0, $result); - - $query = $this->connection->prepare('SELECT `textfield`, `clobfield` FROM `*PREFIX*table` WHERE `clobfield` = ?'); - $result = $query->execute([$uri]); - // Test that previously inserted data isn't overwritten - // And that a new row hasn't been inserted. - $rowset = $result->fetchAll(); - $this->assertEquals(1, count($rowset)); - $this->assertArrayHasKey('textfield', $rowset[0]); - $this->assertEquals($fullName, $rowset[0]['textfield']); - } - - public function testInsertIfNotExistsViolating() { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { - self::markTestSkipped('Insert if not exist does not work with clob on oracle'); - } - - $this->makeTestTable(); - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'textfield' => md5('welcome.txt'), - 'clobfield' => $this->getUniqueID() - ]); - $this->assertEquals(1, $result); - - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'textfield' => md5('welcome.txt'), - 'clobfield' => $this->getUniqueID() - ],['textfield']); - - $this->assertEquals(0, $result); - } - - public function insertIfNotExistsViolatingThrows() { - return [ - [null], - [['clobfield']], - ]; - } - - /** - * @dataProvider insertIfNotExistsViolatingThrows - * - * @param array $compareKeys - */ - public function testInsertIfNotExistsViolatingUnique($compareKeys) { - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { - self::markTestSkipped('Insert if not exist does not work with clob on oracle'); - } - - $this->makeTestTable(); - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'integerfield' => 1, - 'clobfield' => $this->getUniqueID() - ]); - $this->assertEquals(1, $result); - - $result = $this->connection->insertIfNotExist('*PREFIX*table', - [ - 'integerfield' => 1, - 'clobfield' => $this->getUniqueID() - ], $compareKeys); - - $this->assertEquals(0, $result); - } - - - public function testUniqueConstraintViolating() { - $this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class); - - $this->makeTestTable(); - - $testQuery = 'INSERT INTO `*PREFIX*table` (`integerfield`, `textfield`) VALUES(?, ?)'; - $testParams = [1, 'hello']; - - $this->connection->executeUpdate($testQuery, $testParams); - $this->connection->executeUpdate($testQuery, $testParams); - } -} diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php deleted file mode 100644 index 4f24c3f67aa..00000000000 --- a/tests/lib/DB/DBSchemaTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -use Doctrine\DBAL\Platforms\SqlitePlatform; -use OC_DB; -use OCP\ITempManager; -use OCP\Security\ISecureRandom; -use Test\TestCase; - -/** - * Class DBSchemaTest - * - * @group DB - */ -class DBSchemaTest extends TestCase { - protected $schema_file; - protected $schema_file2; - protected $table1; - protected $table2; - /** @var ITempManager */ - protected $tempManager; - - protected function setUp(): void { - parent::setUp(); - - $this->tempManager = \OC::$server->getTempManager(); - $this->schema_file = $this->tempManager->getTemporaryFile(); - $this->schema_file2 = $this->tempManager->getTemporaryFile(); - - $dbfile = \OC::$SERVERROOT.'/tests/data/db_structure.xml'; - $dbfile2 = \OC::$SERVERROOT.'/tests/data/db_structure2.xml'; - - $r = '_' . \OC::$server->getSecureRandom()-> - generate(4, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS) . '_'; - $content = file_get_contents($dbfile); - $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); - file_put_contents($this->schema_file, $content); - $content = file_get_contents($dbfile2); - $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); - file_put_contents($this->schema_file2, $content); - - $this->table1 = $r.'cntcts_addrsbks'; - $this->table2 = $r.'cntcts_cards'; - } - - protected function tearDown(): void { - unlink($this->schema_file); - unlink($this->schema_file2); - - parent::tearDown(); - } - - // everything in one test, they depend on each other - /** - * @medium - */ - public function testSchema() { - $this->doTestSchemaCreating(); - $this->doTestSchemaChanging(); - $this->doTestSchemaRemoving(); - } - - public function doTestSchemaCreating() { - OC_DB::createDbFromStructure($this->schema_file); - $this->assertTableExist($this->table1); - $this->assertTableExist($this->table2); - } - - public function doTestSchemaChanging() { - OC_DB::updateDbFromStructure($this->schema_file2); - $this->assertTableExist($this->table2); - } - - public function doTestSchemaRemoving() { - OC_DB::removeDBStructure($this->schema_file); - $this->assertTableNotExist($this->table1); - $this->assertTableNotExist($this->table2); - } - - /** - * @param string $table - */ - public function assertTableExist($table) { - $this->assertTrue(OC_DB::tableExists($table), 'Table ' . $table . ' does not exist'); - } - - /** - * @param string $table - */ - public function assertTableNotExist($table) { - $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform(); - if ($platform instanceof SqlitePlatform) { - // sqlite removes the tables after closing the DB - $this->addToAssertionCount(1); - } else { - $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.'); - } - } -} diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php deleted file mode 100644 index d4913cbe6f5..00000000000 --- a/tests/lib/DB/LegacyDBTest.php +++ /dev/null @@ -1,323 +0,0 @@ -<?php -/** - * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -use OC_DB; - -/** - * Class LegacyDBTest - * - * @group DB - */ -class LegacyDBTest extends \Test\TestCase { - protected $backupGlobals = false; - - protected static $schema_file; - protected $test_prefix; - - public static function setUpBeforeClass(): void { - self::$schema_file = \OC::$server->getTempManager()->getTemporaryFile(); - } - - - /** - * @var string - */ - private $table1; - - /** - * @var string - */ - private $table2; - - /** - * @var string - */ - private $table3; - - /** - * @var string - */ - private $table4; - - /** - * @var string - */ - private $table5; - - /** - * @var string - */ - private $text_table; - - protected function setUp(): void { - parent::setUp(); - - $dbFile = \OC::$SERVERROOT.'/tests/data/db_structure.xml'; - - $r = $this->getUniqueID('_', 4).'_'; - $content = file_get_contents($dbFile); - $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); - file_put_contents(self::$schema_file, $content); - OC_DB::createDbFromStructure(self::$schema_file); - - $this->test_prefix = $r; - $this->table1 = $this->test_prefix.'cntcts_addrsbks'; - $this->table2 = $this->test_prefix.'cntcts_cards'; - $this->table3 = $this->test_prefix.'vcategory'; - $this->table4 = $this->test_prefix.'decimal'; - $this->table5 = $this->test_prefix.'uniconst'; - $this->text_table = $this->test_prefix.'text_table'; - } - - protected function tearDown(): void { - OC_DB::removeDBStructure(self::$schema_file); - unlink(self::$schema_file); - - parent::tearDown(); - } - - public function testQuotes() { - $query = OC_DB::prepare('SELECT `fullname` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(['uri_1']); - $this->assertTrue((bool)$result); - $row = $result->fetchRow(); - $this->assertFalse($row); - $result->closeCursor(); - - $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result = $query->execute(['fullname test', 'uri_1']); - $this->assertEquals(1, $result); - $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(['uri_1']); - $this->assertTrue((bool)$result); - $row = $result->fetchRow(); - $this->assertArrayHasKey('fullname', $row); - $this->assertEquals($row['fullname'], 'fullname test'); - $row = $result->fetchRow(); - $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null - $result->closeCursor(); - } - - /** - * @medium - */ - public function testNOW() { - $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)'); - $result = $query->execute(['uri_2']); - $this->assertEquals(1, $result); - $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(['uri_2']); - $this->assertTrue((bool)$result); - $result->closeCursor(); - } - - public function testUNIX_TIMESTAMP() { - $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)'); - $result = $query->execute(['uri_3']); - $this->assertEquals(1, $result); - $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(['uri_3']); - $this->assertTrue((bool)$result); - $result->closeCursor(); - } - - public function testLastInsertId() { - $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result1 = OC_DB::executeAudited($query, ['insertid 1','uri_1']); - $id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); - - // we don't know the id we should expect, so insert another row - $result2 = OC_DB::executeAudited($query, ['insertid 2','uri_2']); - $id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); - // now we can check if the two ids are in correct order - $this->assertGreaterThan($id1, $id2); - } - - public function testUtf8Data() { - $table = "*PREFIX*{$this->table2}"; - $expected = "Ћö雙喜\xE2\x80\xA2"; - - $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $result = $query->execute([$expected, 'uri_1', 'This is a vCard']); - $this->assertEquals(1, $result); - - $query = OC_DB::prepare("SELECT `fullname` FROM `$table`"); - - $result = $query->execute(); - $actual = $result->fetchOne(); - $result->closeCursor(); - - $this->assertSame($expected, $actual); - } - - /** - * Insert, select and delete decimal(12,2) values - * @dataProvider decimalData - */ - public function XtestDecimal($insert, $expect) { - $table = "*PREFIX*" . $this->table4; - $rowname = 'decimaltest'; - - $query = OC_DB::prepare('INSERT INTO `' . $table . '` (`' . $rowname . '`) VALUES (?)'); - $result = $query->execute([$insert]); - $this->assertEquals(1, $result); - $query = OC_DB::prepare('SELECT `' . $rowname . '` FROM `' . $table . '`'); - $result = $query->execute(); - $this->assertTrue((bool)$result); - $row = $result->fetchRow(); - $result->closeCursor(); - $this->assertArrayHasKey($rowname, $row); - $this->assertEquals($expect, $row[$rowname]); - $query = OC_DB::prepare('DELETE FROM `' . $table . '`'); - $result = $query->execute(); - $this->assertTrue((bool)$result); - } - - public function decimalData() { - return [ - ['1337133713.37', '1337133713.37'], - ['1234567890', '1234567890.00'], - ]; - } - - public function testUpdateAffectedRowsNoMatch() { - $this->insertCardData('fullname1', 'uri1'); - // The WHERE clause does not match any rows - $this->assertSame(0, $this->updateCardData('fullname3', 'uri2')); - } - - public function testUpdateAffectedRowsDifferent() { - $this->insertCardData('fullname1', 'uri1'); - // The WHERE clause matches a single row and the value we are updating - // is different from the one already present. - $this->assertSame(1, $this->updateCardData('fullname1', 'uri2')); - } - - public function testUpdateAffectedRowsSame() { - $this->insertCardData('fullname1', 'uri1'); - // The WHERE clause matches a single row and the value we are updating - // to is the same as the one already present. MySQL reports 0 here when - // the PDO::MYSQL_ATTR_FOUND_ROWS flag is not specified. - $this->assertSame(1, $this->updateCardData('fullname1', 'uri1')); - } - - public function testUpdateAffectedRowsMultiple() { - $this->insertCardData('fullname1', 'uri1'); - $this->insertCardData('fullname2', 'uri2'); - // The WHERE clause matches two rows. One row contains a value that - // needs to be updated, the other one already contains the value we are - // updating to. MySQL reports 1 here when the PDO::MYSQL_ATTR_FOUND_ROWS - // flag is not specified. - $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ?"); - $this->assertSame(2, $query->execute(['uri1'])); - } - - protected function insertCardData($fullname, $uri) { - $query = OC_DB::prepare("INSERT INTO `*PREFIX*{$this->table2}` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $this->assertSame(1, $query->execute([$fullname, $uri, $this->getUniqueID()])); - } - - protected function updateCardData($fullname, $uri) { - $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ? WHERE `fullname` = ?"); - return $query->execute([$uri, $fullname]); - } - - public function testILIKE() { - $table = "*PREFIX*{$this->table2}"; - - $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(['fooBAR', 'foo', 'bar']); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(['foobar']); - $this->assertCount(0, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(['foobar']); - $this->assertCount(1, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(['foo']); - $this->assertCount(0, $result->fetchAll()); - $result->closeCursor(); - } - - public function testILIKEWildcard() { - $table = "*PREFIX*{$this->table2}"; - - $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(['FooBAR', 'foo', 'bar']); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(['%bar']); - $this->assertCount(0, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(['foo%']); - $this->assertCount(0, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(['%ba%']); - $this->assertCount(0, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(['%bar']); - $this->assertCount(1, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(['foo%']); - $this->assertCount(1, $result->fetchAll()); - $result->closeCursor(); - - $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(['%ba%']); - $this->assertCount(1, $result->fetchAll()); - $result->closeCursor(); - } - - /** - * @dataProvider insertAndSelectDataProvider - */ - public function testInsertAndSelectData($expected, $throwsOnMysqlWithoutUTF8MB4) { - $table = "*PREFIX*{$this->text_table}"; - $config = \OC::$server->getConfig(); - - $query = OC_DB::prepare("INSERT INTO `$table` (`textfield`) VALUES (?)"); - if ($throwsOnMysqlWithoutUTF8MB4 && $config->getSystemValue('dbtype', 'sqlite') === 'mysql' && $config->getSystemValue('mysql.utf8mb4', false) === false) { - $this->markTestSkipped('MySQL requires UTF8mb4 to store value: ' . $expected); - } - $result = $query->execute([$expected]); - $this->assertEquals(1, $result); - - $query = OC_DB::prepare("SELECT `textfield` FROM `$table`"); - - $result = $query->execute(); - $actual = $result->fetchOne(); - $result->closeCursor(); - $this->assertSame($expected, $actual); - } - - public function insertAndSelectDataProvider() { - return [ - ['abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXYZ', false], - ['0123456789', false], - ['äöüÄÖÜß!"§$%&/()=?#\'+*~°^`´', false], - ['²³¼½¬{[]}\\', false], - ['♡⚗', false], - ['💩', true], # :hankey: on github - ]; - } -} diff --git a/tests/lib/DB/MDB2SchemaManagerTest.php b/tests/lib/DB/MDB2SchemaManagerTest.php deleted file mode 100644 index 693de746b5e..00000000000 --- a/tests/lib/DB/MDB2SchemaManagerTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -/** - * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -use Doctrine\DBAL\Platforms\OraclePlatform; - -/** - * Class MDB2SchemaManager - * - * @group DB - * - * @package Test\DB - */ -class MDB2SchemaManagerTest extends \Test\TestCase { - protected function tearDown(): void { - // do not drop the table for Oracle as it will create a bogus transaction - // that will break the following test suites requiring transactions - if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') { - \OC::$server->getDatabaseConnection()->dropTable('table'); - } - - parent::tearDown(); - } - - public function testAutoIncrement() { - $connection = \OC::$server->get(\OC\DB\Connection::class); - if ($connection->getDatabasePlatform() instanceof OraclePlatform) { - $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.'); - } - - $manager = new \OC\DB\MDB2SchemaManager($connection); - - $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml'); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['abc']); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['abc']); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['123']); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['123']); - $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); - - $this->addToAssertionCount(1); - } -} diff --git a/tests/lib/DB/MDB2SchemaReaderTest.php b/tests/lib/DB/MDB2SchemaReaderTest.php deleted file mode 100644 index 1e7d3a20b7c..00000000000 --- a/tests/lib/DB/MDB2SchemaReaderTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -use Doctrine\DBAL\Platforms\MySQLPlatform; -use Doctrine\DBAL\Schema\Schema; -use OC\DB\MDB2SchemaReader; -use OCP\IConfig; -use Test\TestCase; -use Doctrine\DBAL\Types\IntegerType; -use Doctrine\DBAL\Types\TextType; -use Doctrine\DBAL\Types\StringType; -use Doctrine\DBAL\Types\BooleanType; - -/** - * Class MDB2SchemaReaderTest - * - * @group DB - * - * @package Test\DB - */ -class MDB2SchemaReaderTest extends TestCase { - /** - * @var MDB2SchemaReader $reader - */ - protected $reader; - - /** - * @return IConfig - */ - protected function getConfig() { - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject $config */ - $config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $config->expects($this->any()) - ->method('getSystemValue') - ->willReturnMap([ - ['dbname', 'owncloud', 'testDB'], - ['dbtableprefix', 'oc_', 'test_'] - ]); - return $config; - } - - public function testRead() { - $reader = new MDB2SchemaReader($this->getConfig(), new MySQLPlatform()); - $schema = $reader->loadSchemaFromFile(__DIR__ . '/testschema.xml', new Schema()); - $this->assertCount(1, $schema->getTables()); - - $table = $schema->getTable('test_table'); - $this->assertCount(9, $table->getColumns()); - - $this->assertEquals(4, $table->getColumn('id')->getLength()); - $this->assertTrue($table->getColumn('id')->getAutoincrement()); - $this->assertEquals(0, $table->getColumn('id')->getDefault()); - $this->assertTrue($table->getColumn('id')->getNotnull()); - $this->assertInstanceOf(IntegerType::class, $table->getColumn('id')->getType()); - - $this->assertSame(10, $table->getColumn('integerfield_default')->getDefault()); - - $this->assertEquals(32, $table->getColumn('textfield')->getLength()); - $this->assertFalse($table->getColumn('textfield')->getAutoincrement()); - $this->assertSame('foo', $table->getColumn('textfield')->getDefault()); - $this->assertTrue($table->getColumn('textfield')->getNotnull()); - $this->assertInstanceOf(StringType::class, $table->getColumn('textfield')->getType()); - - $this->assertNull($table->getColumn('clobfield')->getLength()); - $this->assertFalse($table->getColumn('clobfield')->getAutoincrement()); - $this->assertNull($table->getColumn('clobfield')->getDefault()); - $this->assertFalse($table->getColumn('clobfield')->getNotnull()); - $this->assertInstanceOf(StringType::class, $table->getColumn('clobfield')->getType()); -// $this->assertInstanceOf(TextType::class, $table->getColumn('clobfield')->getType()); - - $this->assertNull($table->getColumn('booleanfield')->getLength()); - $this->assertFalse($table->getColumn('booleanfield')->getAutoincrement()); - $this->assertNull($table->getColumn('booleanfield')->getDefault()); - $this->assertInstanceOf(BooleanType::class, $table->getColumn('booleanfield')->getType()); - - $this->assertTrue($table->getColumn('booleanfield_true')->getDefault()); - $this->assertFalse($table->getColumn('booleanfield_false')->getDefault()); - - $this->assertEquals(12, $table->getColumn('decimalfield_precision_scale')->getPrecision()); - $this->assertEquals(2, $table->getColumn('decimalfield_precision_scale')->getScale()); - - $this->assertCount(3, $table->getIndexes()); - $this->assertEquals(['id'], $table->getIndex('primary')->getUnquotedColumns()); - $this->assertTrue($table->getIndex('primary')->isPrimary()); - $this->assertTrue($table->getIndex('primary')->isUnique()); - $this->assertEquals(['integerfield'], $table->getIndex('index_integerfield')->getUnquotedColumns()); - $this->assertFalse($table->getIndex('index_integerfield')->isPrimary()); - $this->assertTrue($table->getIndex('index_integerfield')->isUnique()); - $this->assertEquals(['booleanfield'], $table->getIndex('index_boolean')->getUnquotedColumns()); - $this->assertFalse($table->getIndex('index_boolean')->isPrimary()); - $this->assertFalse($table->getIndex('index_boolean')->isUnique()); - } -} diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index 12ff3bd0749..1d2afaa405e 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -12,9 +12,15 @@ namespace Test\DB; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaConfig; +use OC\DB\Migrator; +use OC\DB\MySQLMigrator; +use OC\DB\OracleMigrator; +use OC\DB\PostgreSqlMigrator; +use OC\DB\SQLiteMigrator; use OCP\IConfig; /** @@ -31,11 +37,6 @@ class MigratorTest extends \Test\TestCase { private $connection; /** - * @var \OC\DB\MDB2SchemaManager - */ - private $manager; - - /** * @var IConfig **/ private $config; @@ -54,11 +55,27 @@ class MigratorTest extends \Test\TestCase { if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('DB migration tests are not supported on OCI'); } - $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); + $this->tableName = $this->getUniqueTableName(); $this->tableNameTmp = $this->getUniqueTableName(); } + private function getMigrator(): Migrator { + $platform = $this->connection->getDatabasePlatform(); + $random = \OC::$server->getSecureRandom(); + $dispatcher = \OC::$server->getEventDispatcher(); + if ($platform instanceof SqlitePlatform) { + return new SQLiteMigrator($this->connection, $this->config, $dispatcher); + } elseif ($platform instanceof OraclePlatform) { + return new OracleMigrator($this->connection, $this->config, $dispatcher); + } elseif ($platform instanceof MySQLPlatform) { + return new MySQLMigrator($this->connection, $this->config, $dispatcher); + } elseif ($platform instanceof PostgreSQL94Platform) { + return new PostgreSqlMigrator($this->connection, $this->config, $dispatcher); + } + return new Migrator($this->connection, $this->config, $dispatcher); + } + private function getUniqueTableName() { return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_')); } @@ -132,7 +149,7 @@ class MigratorTest extends \Test\TestCase { public function testUpgrade() { [$startSchema, $endSchema] = $this->getDuplicateKeySchemas(); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); @@ -150,7 +167,7 @@ class MigratorTest extends \Test\TestCase { $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix') . 'test_')); [$startSchema, $endSchema] = $this->getDuplicateKeySchemas(); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); @@ -165,7 +182,7 @@ class MigratorTest extends \Test\TestCase { public function testInsertAfterUpgrade() { [$startSchema, $endSchema] = $this->getDuplicateKeySchemas(); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); $migrator->migrate($endSchema); @@ -192,7 +209,7 @@ class MigratorTest extends \Test\TestCase { $table->addColumn('name', 'string'); $table->setPrimaryKey(['id']); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); $migrator->migrate($endSchema); @@ -213,7 +230,7 @@ class MigratorTest extends \Test\TestCase { $table->addColumn('user', 'string', ['length' => 64]); $table->setPrimaryKey(['id']); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); $migrator->migrate($endSchema); @@ -234,7 +251,7 @@ class MigratorTest extends \Test\TestCase { $tableFk->addColumn('name', 'string'); $tableFk->addForeignKeyConstraint($this->tableName, ['fk_id'], ['id'], [], $fkName); - $migrator = $this->manager->getMigrator(); + $migrator = $this->getMigrator(); $migrator->migrate($startSchema); diff --git a/tests/lib/DB/MySqlMigrationTest.php b/tests/lib/DB/MySqlMigrationTest.php deleted file mode 100644 index 38cb64916ec..00000000000 --- a/tests/lib/DB/MySqlMigrationTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -/** - * Class MySqlMigration - * - * @group DB - */ -class MySqlMigrationTest extends \Test\TestCase { - - /** @var \Doctrine\DBAL\Connection */ - private $connection; - - /** @var string */ - private $tableName; - - protected function setUp(): void { - parent::setUp(); - - $this->connection = \OC::$server->get(\OC\DB\Connection::class); - if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { - $this->markTestSkipped("Test only relevant on MySql"); - } - - $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); - $this->tableName = $this->getUniqueID($dbPrefix . '_enum_bit_test'); - $this->connection->exec("CREATE TABLE $this->tableName(b BIT, e ENUM('1','2','3','4'))"); - } - - protected function tearDown(): void { - $this->connection->getSchemaManager()->dropTable($this->tableName); - parent::tearDown(); - } - - public function testNonOCTables() { - $manager = new \OC\DB\MDB2SchemaManager($this->connection); - $manager->updateDbFromStructure(__DIR__ . '/testschema.xml'); - - $this->addToAssertionCount(1); - } -} diff --git a/tests/lib/DB/SchemaDiffTest.php b/tests/lib/DB/SchemaDiffTest.php deleted file mode 100644 index 0e5612e3b3b..00000000000 --- a/tests/lib/DB/SchemaDiffTest.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Test\DB; - -use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Schema\SchemaDiff; -use OC\DB\MDB2SchemaManager; -use OC\DB\MDB2SchemaReader; -use OCP\IConfig; -use OCP\IDBConnection; -use Test\TestCase; - -/** - * Class MigratorTest - * - * @group DB - * - * @package Test\DB - */ -class SchemaDiffTest extends TestCase { - /** @var IDBConnection $connection */ - private $connection; - /** @var \Doctrine\DBAL\Connection $connection */ - private $internalConnection; - - /** @var MDB2SchemaManager */ - private $manager; - - /** @var IConfig */ - private $config; - - /** @var string */ - private $testPrefix; - - private $schemaFile; - - protected function setUp(): void { - parent::setUp(); - - $this->schemaFile = \OC::$server->getTempManager()->getTemporaryFile(); - - $this->config = \OC::$server->getConfig(); - $this->connection = \OC::$server->getDatabaseConnection(); - $this->internalConnection = \OC::$server->get(\OC\DB\Connection::class); - $this->manager = new MDB2SchemaManager($this->internalConnection); - $this->testPrefix = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_'), 3)); - } - - protected function tearDown(): void { - $this->manager->removeDBStructure($this->schemaFile); - parent::tearDown(); - } - - /** - * @dataProvider providesSchemaFiles - * @param string $xml - */ - public function testZeroChangeOnSchemaMigrations($xml) { - $xml = str_replace('*dbprefix*', $this->testPrefix, $xml); - $schemaFile = $this->schemaFile; - file_put_contents($schemaFile, $xml); - - // apply schema - $this->manager->createDbFromStructure($schemaFile); - - $schemaReader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform()); - $toSchema = new Schema([], [], $this->internalConnection->getSchemaManager()->createSchemaConfig()); - $endSchema = $schemaReader->loadSchemaFromFile($schemaFile, $toSchema); - - // get the diff - /** @var SchemaDiff $diff */ - $migrator = $this->manager->getMigrator(); - $diff = $this->invokePrivate($migrator, 'getDiff', [$endSchema, $this->internalConnection]); - - // no sql statement is expected - $sqls = $diff->toSql($this->connection->getDatabasePlatform()); - $this->assertEmpty($sqls); - } - - public function providesSchemaFiles() { - return [ - 'explicit test on autoincrement' => [file_get_contents(__DIR__ . '/schemDiffData/autoincrement.xml')], - 'explicit test on clob' => [file_get_contents(__DIR__ . '/schemDiffData/clob.xml')], - 'explicit test on unsigned' => [file_get_contents(__DIR__ . '/schemDiffData/unsigned.xml')], - 'explicit test on default -1' => [file_get_contents(__DIR__ . '/schemDiffData/default-1.xml')], - 'testing core schema' => [file_get_contents(__DIR__ . '/schemDiffData/core.xml')], - ]; - } -} diff --git a/tests/lib/DB/SqliteMigrationTest.php b/tests/lib/DB/SqliteMigrationTest.php deleted file mode 100644 index b0bf39b4035..00000000000 --- a/tests/lib/DB/SqliteMigrationTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\DB; - -/** - * Class SqliteMigration - * - * @group DB - */ -class SqliteMigrationTest extends \Test\TestCase { - - /** @var \Doctrine\DBAL\Connection */ - private $connection; - - /** @var string */ - private $tableName; - - protected function setUp(): void { - parent::setUp(); - - $this->connection = \OC::$server->get(\OC\DB\Connection::class); - if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { - $this->markTestSkipped("Test only relevant on Sqlite"); - } - - $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); - $this->tableName = $this->getUniqueID($dbPrefix . '_enum_bit_test'); - $this->connection->prepare("CREATE TABLE $this->tableName(t0 tinyint unsigned, t1 tinyint)")->execute(); - } - - protected function tearDown(): void { - $this->connection->getSchemaManager()->dropTable($this->tableName); - parent::tearDown(); - } - - public function testNonOCTables() { - $manager = new \OC\DB\MDB2SchemaManager($this->connection); - $manager->updateDbFromStructure(__DIR__ . '/testschema.xml'); - - $this->addToAssertionCount(1); - } -} diff --git a/tests/lib/DB/schemDiffData/autoincrement.xml b/tests/lib/DB/schemDiffData/autoincrement.xml deleted file mode 100644 index 458c5d8166f..00000000000 --- a/tests/lib/DB/schemDiffData/autoincrement.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - <table> - <name>*dbprefix*external_config</name> - <declaration> - <field> - <name>config_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>6</length> - </field> - </declaration> - </table> -</database> diff --git a/tests/lib/DB/schemDiffData/clob.xml b/tests/lib/DB/schemDiffData/clob.xml deleted file mode 100644 index 08aef18c31d..00000000000 --- a/tests/lib/DB/schemDiffData/clob.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - <table> - <name>*dbprefix*external_config</name> - <declaration> - <field> - <name>value</name> - <type>text</type> - <notnull>true</notnull> - <length>100000</length> - </field> - </declaration> - </table> -</database> diff --git a/tests/lib/DB/schemDiffData/core.xml b/tests/lib/DB/schemDiffData/core.xml deleted file mode 100644 index d7edc7dc73e..00000000000 --- a/tests/lib/DB/schemDiffData/core.xml +++ /dev/null @@ -1,1347 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <table> - - <!-- - Namespaced Key-Value Store for Application Configuration. - - Keys are namespaced per appid. - - E.g. (core, global_cache_gc_lastrun) -> 1385463286 - --> - <name>*dbprefix*appconfig</name> - - <declaration> - - <field> - <name>appid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>32</length> - </field> - - <field> - <name>configkey</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>configvalue</name> - <type>clob</type> - <notnull>false</notnull> - </field> - </declaration> - - </table> - - <table> - - <!-- - Bidirectional Map for Storage Names and Storage Ids. - - Assigns each storage name a unique storage id integer. - - Long storage names are hashed. - - E.g. local::/tmp/ <-> 2 - - E.g. b5db994aa8c6625100e418406c798269 <-> 27 - --> - <name>*dbprefix*storages</name> - - <declaration> - - <field> - <name>id</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>64</length> - </field> - - <field> - <name>numeric_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - - <field> - <name>available</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - </field> - - <field> - <name>last_checked</name> - <type>integer</type> - </field> - </declaration> - - </table> - - <!-- a list of all mounted storage per user, populated on filesystem setup --> - <table> - - <name>*dbprefix*mounts</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - - <field> - <name>storage_id</name> - <type>integer</type> - <notnull>true</notnull> - </field> - - <!-- fileid of the root of the mount, foreign key: oc_filecache.fileid --> - <field> - <name>root_id</name> - <type>integer</type> - <notnull>true</notnull> - </field> - - <field> - <name>user_id</name> - <type>text</type> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>mount_point</name> - <type>text</type> - <notnull>true</notnull> - <length>4000</length> - </field> - - - </declaration> - - </table> - - <table> - - <!-- - Bidirectional Map for Mimetypes and Mimetype Id - - Assigns each mimetype (and supertype) a unique mimetype id integer. - - E.g. application <-> 5 - - E.g. application/pdf <-> 6 - --> - <name>*dbprefix*mimetypes</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - - <field> - <name>mimetype</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Main file table containing one row for each directory and file. - - Assigns a unique integer fileid to each file (and directory) - - Assigns an etag to each file (and directory) - - Caches various file/dir properties such as: - - path (filename, e.g. files/combinatoricslib-2.0_doc.zip) - - path_hash = md5(path) - - name (basename, e.g. combinatoricslib-2.0_doc.zip) - - size (for directories this is the sum of all contained file sizes) - --> - <name>*dbprefix*filecache</name> - - <declaration> - - <field> - <name>fileid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - - <!-- Foreign Key storages::numeric_id --> - <field> - <name>storage</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>path</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>4000</length> - </field> - - <field> - <name>path_hash</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>32</length> - </field> - - <!-- Foreign Key filecache::fileid --> - <field> - <name>parent</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>name</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>250</length> - </field> - - <!-- Foreign Key mimetypes::id --> - <field> - <name>mimetype</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <!-- Foreign Key mimetypes::id --> - <field> - <name>mimepart</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>size</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>8</length> - </field> - - <field> - <name>mtime</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>storage_mtime</name> - <type>integer</type> - <default></default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>encrypted</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>unencrypted_size</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>8</length> - </field> - - <field> - <name>etag</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>40</length> - </field> - - <field> - <name>permissions</name> - <type>integer</type> - <default>0</default> - <notnull>false</notnull> - <length>4</length> - </field> - - <field> - <name>checksum</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - - - </declaration> - - </table> - - <table> - - <!-- - Stores which groups have which users as members in an n:m relationship. - - Maps group id (gid) to a set of users (uid) - - Maps user id (uid) to a set of groups (gid) (but without index) - --> - <name>*dbprefix*group_user</name> - - <declaration> - - <!-- Foreign Key groups::gid --> - <field> - <name>gid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Stores which groups have which users as admins in an n:m relationship. - - Maps group id (gid) to a set of users (uid) - - Maps user id (uid) to a set of groups (gid) - - NOTE: This could (very likely) be reduced to a single bit in group_user - instead of repeating varchars gid and uid here - --> - <name>*dbprefix*group_admin</name> - - <declaration> - - <!-- Foreign Key groups::gid --> - <field> - <name>gid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - A simple list of groups. - --> - <name>*dbprefix*groups</name> - - <declaration> - - <field> - <name>gid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Namespaced Key-Value Store for User Preferences - - Keys are namespaced per userid and appid. - - E.g. (admin, files, cache_version) -> 5 - --> - <name>*dbprefix*preferences</name> - - <declaration> - - <!-- Foreign Key users::uid --> - <field> - <name>userid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>appid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>32</length> - </field> - - <field> - <name>configkey</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>configvalue</name> - <type>clob</type> - <notnull>false</notnull> - </field> - - </declaration> - - </table> - - <table> - - <!-- - WebDAV properties. - --> - <name>*dbprefix*properties</name> - - <declaration> - - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>userid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>propertypath</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>propertyname</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>propertyvalue</name> - <type>text</type> - <notnull>true</notnull> - <length>255</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Shares of all types (user-to-user, external-via-link, etc.) - --> - <name>*dbprefix*share</name> - - <declaration> - - <field> - <name>id</name> - <autoincrement>1</autoincrement> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <!-- Constant OCP\Share\IShare::TYPE_* --> - <field> - <name>share_type</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>1</length> - </field> - - <!-- Foreign Key users::uid or NULL --> - <field> - <name>share_with</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <!-- Foreign Key users::uid --> - <!-- This is the owner of the share - which does not have to be the initiator of the share --> - <field> - <name>uid_owner</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Foreign Key users::uid --> - <!-- This is the initiator of the share --> - <field> - <name>uid_initiator</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>64</length> - </field> - - - - <!-- Foreign Key share::id or NULL --> - <field> - <name>parent</name> - <type>integer</type> - <notnull>false</notnull> - <length>4</length> - </field> - - <!-- E.g. file or folder --> - <field> - <name>item_type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Foreign Key filecache::fileid --> - <field> - <name>item_source</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <field> - <name>item_target</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>255</length> - </field> - - <!-- Foreign Key filecache::fileid --> - <field> - <name>file_source</name> - <type>integer</type> - <notnull>false</notnull> - <length>4</length> - </field> - - <field> - <name>file_target</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>512</length> - </field> - - <!-- Permission bitfield --> - <field> - <name>permissions</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>1</length> - </field> - - <!-- Time of share creation --> - <field> - <name>stime</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>8</length> - </field> - - <!-- Whether the receiver accepted the share, if share_with is set. --> - <field> - <name>accepted</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>1</length> - </field> - - <!-- Time of share expiration --> - <field> - <name>expiration</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>token</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>32</length> - </field> - - <field> - <name>mail_send</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>1</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Scheduled background jobs. - See OC\BackgroundJob\JobList. - --> - <name>*dbprefix*jobs</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>class</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>argument</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>4000</length> - </field> - - <field> - <!-- timestamp when the job was executed the last time --> - <name>last_run</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <!-- timestamp when the job was checked if it needs execution the last time --> - <name>last_checked</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <!-- timestamp when the job was reserved the last time, 1 day timeout --> - <name>reserved_at</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - </declaration> - - </table> - - <table> - - <!-- - List of usernames, their display name and login password. - --> - <name>*dbprefix*users</name> - - <declaration> - - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>displayname</name> - <type>text</type> - <default></default> - <length>64</length> - </field> - - <field> - <name>password</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - - </declaration> - - </table> - - <table> - <name>*dbprefix*authtoken</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>login_name</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>password</name> - <type>clob</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>name</name> - <type>clob</type> - <default></default> - <notnull>true</notnull> - </field> - - <field> - <name>token</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>200</length> - </field> - - <field> - <name>type</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>2</length> - </field> - - <field> - <name>last_activity</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - </declaration> - </table> - - <table> - - <!-- - List of tags (category) + a unique tag id (id) per user (uid) and type. - --> - <name>*dbprefix*vcategory</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>uid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>category</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - </declaration> - </table> - - <table> - - <!-- - Object-Tag associations per tag type. - --> - <name>*dbprefix*vcategory_to_object</name> - - <declaration> - - <field> - <name>objid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <!-- Foreign Key vcategory::id --> - <field> - <name>categoryid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - <!-- - List of system-wide tags - --> - <name>*dbprefix*systemtag</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <!-- Tag name --> - <field> - <name>name</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Visibility: 0 user-not-visible, 1 user-visible --> - <field> - <name>visibility</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <length>1</length> - </field> - - <!-- Editable: 0 user-not-editable, 1 user-editable --> - <field> - <name>editable</name> - <type>integer</type> - <default>1</default> - <notnull>true</notnull> - <length>1</length> - </field> - - </declaration> - </table> - - <table> - - <!-- - System tag to object associations per object type. - --> - <name>*dbprefix*systemtag_object_mapping</name> - - <declaration> - - <!-- object id (ex: file id for files)--> - <field> - <name>objectid</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- object type (ex: "files")--> - <field> - <name>objecttype</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <!-- Foreign Key systemtag::id --> - <field> - <name>systemtagid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - - </declaration> - - </table> - - <table> - - <!-- - System tag to group mapping - --> - <name>*dbprefix*systemtag_group</name> - - <declaration> - - <!-- Foreign Key systemtag::id --> - <field> - <name>systemtagid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>gid</name> - <type>string</type> - <notnull>true</notnull> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Namespaced Key-Value Store for arbitrary data. - - Keys are namespaced per userid and appid. - - E.g. (admin, files, foo) -> bar - --> - <name>*dbprefix*privatedata</name> - - <declaration> - - <field> - <name>keyid</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - <autoincrement>1</autoincrement> - </field> - - <!-- Foreign Key users::uid --> - <field> - <name>user</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>app</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>key</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>value</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - </declaration> - - </table> - - <table> - - <!-- - Table for storing transactional file locking - --> - <name>*dbprefix*file_locks</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - <autoincrement>1</autoincrement> - </field> - - <field> - <name>lock</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>key</name> - <type>text</type> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>ttl</name> - <type>integer</type> - <default>-1</default> - <notnull>true</notnull> - <length>4</length> - </field> - - </declaration> - - </table> - - <table> - <!-- - default place to store comment data - --> - <name>*dbprefix*comments</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - <autoincrement>1</autoincrement> - </field> - - <field> - <name>parent_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>topmost_parent_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>children_count</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>actor_type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>actor_id</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>message</name> - <type>clob</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>verb</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>64</length> - </field> - - <field> - <name>creation_timestamp</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>latest_child_timestamp</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>object_type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>object_id</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - <!-- - default place to store per user and object read markers - --> - <name>*dbprefix*comments_read_markers</name> - - <declaration> - - <field> - <name>user_id</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>marker_datetime</name> - <type>timestamp</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <name>object_type</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>object_id</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - - </declaration> - - </table> - - <table> - <!-- - Encrypted credentials storage - --> - <name>*dbprefix*credentials</name> - - <declaration> - - <field> - <name>user</name> - <type>text</type> - <default></default> - <notnull>false</notnull> - <length>64</length> - </field> - - <field> - <name>identifier</name> - <type>text</type> - <notnull>true</notnull> - <length>64</length> - </field> - - <field> - <name>credentials</name> - <type>clob</type> - <notnull>false</notnull> - </field> - - </declaration> - - </table> - -</database> diff --git a/tests/lib/DB/schemDiffData/default-1.xml b/tests/lib/DB/schemDiffData/default-1.xml deleted file mode 100644 index 39b95a1f273..00000000000 --- a/tests/lib/DB/schemDiffData/default-1.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <table> - - <!-- - Table for storing transactional file locking - --> - <name>*dbprefix*file_locks</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <unsigned>true</unsigned> - <length>4</length> - <autoincrement>1</autoincrement> - </field> - - <field> - <name>lock</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - - <field> - <name>key</name> - <type>text</type> - <notnull>true</notnull> - <default>(stupid text)</default> - <length>64</length> - </field> - - <field> - <name>ttl</name> - <type>integer</type> - <default>-1</default> - <notnull>true</notnull> - <length>4</length> - </field> - - </declaration> - - </table> - -</database> diff --git a/tests/lib/DB/schemDiffData/unsigned.xml b/tests/lib/DB/schemDiffData/unsigned.xml deleted file mode 100644 index e89fd6a5d4e..00000000000 --- a/tests/lib/DB/schemDiffData/unsigned.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <table> - - <!-- - Scheduled background jobs. - See OC\BackgroundJob\JobList. - --> - <name>*dbprefix*jobs</name> - - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <unsigned>true</unsigned> - <length>4</length> - </field> - - <field> - <name>class</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>255</length> - </field> - - <field> - <name>argument</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>4000</length> - </field> - - <field> - <!-- timestamp when the job was executed the last time --> - <name>last_run</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <!-- timestamp when the job was checked if it needs execution the last time --> - <name>last_checked</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - <field> - <!-- timestamp when the job was reserved the last time, 1 day timeout --> - <name>reserved_at</name> - <type>integer</type> - <default></default> - <notnull>false</notnull> - </field> - - </declaration> - - </table> - -</database> diff --git a/tests/lib/DB/testschema.xml b/tests/lib/DB/testschema.xml deleted file mode 100644 index a2b01d8259e..00000000000 --- a/tests/lib/DB/testschema.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*table</name> - - <declaration> - <field> - <name>id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <primary>true</primary> - <length>4</length> - <autoincrement>1</autoincrement> - </field> - <field> - <name>integerfield</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <length>4</length> - </field> - <field> - <name>integerfield_default</name> - <type>integer</type> - <default>10</default> - <notnull>true</notnull> - <length>4</length> - </field> - <field> - <name>textfield</name> - <type>text</type> - <default>foo</default> - <notnull>true</notnull> - <length>32</length> - </field> - <field> - <name>clobfield</name> - <type>text</type> - </field> - <field> - <name>booleanfield</name> - <type>boolean</type> - </field> - <field> - <name>booleanfield_true</name> - <type>boolean</type> - <default>true</default> - </field> - <field> - <name>booleanfield_false</name> - <type>boolean</type> - <default>false</default> - </field> - <field> - <name>decimalfield_precision_scale</name> - <type>decimal</type> - <precision>12</precision> - <scale>2</scale> - </field> - - <index> - <name>index_primary</name> - <primary>true</primary> - <unique>true</unique> - <field> - <name>id</name> - <sorting>ascending</sorting> - </field> - </index> - - <index> - <name>index_integerfield</name> - <unique>true</unique> - <field> - <name>integerfield</name> - <sorting>ascending</sorting> - </field> - </index> - - <index> - <name>index_boolean</name> - <unique>false</unique> - <field> - <name>booleanfield</name> - <sorting>ascending</sorting> - </field> - </index> - </declaration> - </table> -</database> diff --git a/tests/lib/DB/ts-autoincrement-after.xml b/tests/lib/DB/ts-autoincrement-after.xml deleted file mode 100644 index d4445f1e247..00000000000 --- a/tests/lib/DB/ts-autoincrement-after.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*table</name> - - <declaration> - <field> - <name>auto_id</name> - <type>integer</type> - <default>0</default> - <notnull>true</notnull> - <autoincrement>1</autoincrement> - <length>4</length> - </field> - <field> - <name>textfield</name> - <type>text</type> - <default>foo</default> - <notnull>true</notnull> - <length>32</length> - </field> - </declaration> - </table> -</database> diff --git a/tests/lib/DB/ts-autoincrement-before.xml b/tests/lib/DB/ts-autoincrement-before.xml deleted file mode 100644 index 412739e9a71..00000000000 --- a/tests/lib/DB/ts-autoincrement-before.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<database> - - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - - <charset>utf8</charset> - - <table> - - <name>*dbprefix*table</name> - - <declaration> - <field> - <name>textfield</name> - <type>text</type> - <default>foo</default> - <notnull>true</notnull> - <length>32</length> - </field> - </declaration> - </table> -</database> diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index f6ce4894dbb..40626bdb571 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -1558,9 +1558,6 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testDeleteFromSelfGroupUserNotInGroup() { - $this->expectException(\OC\Share20\Exception\ProviderException::class); - $this->expectExceptionMessage('Recipient not in receiving group'); - $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->insert('share') ->values([ diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 08c59633e42..b5dcd76faf9 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -459,15 +459,27 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { } } + protected function getGroupAnnotations(): array { + if (method_exists($this, 'getAnnotations')) { + $annotations = $this->getAnnotations(); + return $annotations['class']['group'] ?? []; + } + + $r = new \ReflectionClass($this); + $doc = $r->getDocComment(); + preg_match_all('#@group\s+(.*?)\n#s', $doc, $annotations); + return $annotations[1] ?? []; + } + protected function IsDatabaseAccessAllowed() { // on travis-ci.org we allow database access in any case - otherwise // this will break all apps right away if (true == getenv('TRAVIS')) { return true; } - $annotations = $this->getAnnotations(); - if (isset($annotations['class']['group'])) { - if (in_array('DB', $annotations['class']['group']) || in_array('SLOWDB', $annotations['class']['group'])) { + $annotations = $this->getGroupAnnotations(); + if (isset($annotations)) { + if (in_array('DB', $annotations) || in_array('SLOWDB', $annotations)) { return true; } } diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index 17b0b62c0b7..c293d1c7d59 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -8,8 +8,8 @@ > <testsuite name='ownCloud'> <directory suffix='.php'>lib/</directory> - <directory suffix='.php'>core/</directory> - <directory suffix='.php'>ocs-provider/</directory> + <directory suffix='.php'>Core/</directory> + <directory suffix='.php'>Test/</directory> <file>apps.php</file> </testsuite> <!-- filters for code coverage --> @@ -32,4 +32,3 @@ <listener class="StartSessionListener" file="startsessionlistener.php" /> </listeners> </phpunit> - |