commit
fda6ffc866
20
.drone.yml
20
.drone.yml
|
@ -256,11 +256,11 @@ steps:
|
|||
commands:
|
||||
- bash tests/drone-run-php-tests.sh || exit 0
|
||||
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
|
||||
#- name: nodb-php8.0
|
||||
# image: nextcloudci/php8.0:latest
|
||||
# commands:
|
||||
# - bash tests/drone-run-php-tests.sh || exit 0
|
||||
# - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
|
||||
- name: nodb-php8.0
|
||||
image: nextcloudci/php8.0:latest
|
||||
commands:
|
||||
- bash tests/drone-run-php-tests.sh || exit 0
|
||||
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
|
||||
|
||||
services:
|
||||
- name: cache
|
||||
|
@ -293,11 +293,11 @@ steps:
|
|||
commands:
|
||||
- bash tests/drone-run-php-tests.sh || exit 0
|
||||
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
|
||||
#- name: sqlite-php8.0
|
||||
# image: nextcloudci/php8.0:latest
|
||||
# commands:
|
||||
# - bash tests/drone-run-php-tests.sh || exit 0
|
||||
# - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
|
||||
- name: sqlite-php8.0
|
||||
image: nextcloudci/php8.0:latest
|
||||
commands:
|
||||
- bash tests/drone-run-php-tests.sh || exit 0
|
||||
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
|
||||
|
||||
services:
|
||||
- name: cache
|
||||
|
|
|
@ -38,6 +38,9 @@ use OCP\Calendar\Resource\IResource;
|
|||
use OCP\Calendar\Room\IManager as IRoomManager;
|
||||
use Test\TestCase;
|
||||
|
||||
interface tmpI extends IResource, IMetadataProvider {
|
||||
}
|
||||
|
||||
class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
||||
|
||||
/** @var UpdateCalendarResourcesRoomsBackgroundJob */
|
||||
|
@ -108,9 +111,9 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
$backend3 = $this->createMock(IBackend::class);
|
||||
$backend4 = $this->createMock(IBackend::class);
|
||||
|
||||
$res6 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res7 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res8 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res6 = $this->createMock(tmpI::class);
|
||||
$res7 = $this->createMock(tmpI::class);
|
||||
$res8 = $this->createMock(tmpI::class);
|
||||
$res9 = $this->createMock(IResource::class);
|
||||
|
||||
$backend2->method('getBackendIdentifier')
|
||||
|
|
|
@ -63,6 +63,9 @@ class NotifierTest extends TestCase {
|
|||
$this->l10n->expects($this->any())
|
||||
->method('t')
|
||||
->willReturnCallback(function ($string, $args) {
|
||||
if (!is_array($args)) {
|
||||
$args = [$args];
|
||||
}
|
||||
return vsprintf($string, $args);
|
||||
});
|
||||
$this->l10n->expects($this->any())
|
||||
|
@ -103,7 +106,7 @@ class NotifierTest extends TestCase {
|
|||
$this->assertEquals($this->notifier->getName(), 'Calendar');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testPrepareWrongApp(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Notification not from this app');
|
||||
|
@ -120,7 +123,7 @@ class NotifierTest extends TestCase {
|
|||
$this->notifier->prepare($notification, 'en');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testPrepareWrongSubject() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Unknown subject');
|
||||
|
|
|
@ -216,7 +216,7 @@ class MoveCalendarTest extends TestCase {
|
|||
'destinationuid' => 'user2',
|
||||
]);
|
||||
|
||||
$this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
|
||||
$this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay());
|
||||
}
|
||||
|
||||
public function dataTestMoveWithDestinationNotPartOfGroup(): array {
|
||||
|
|
|
@ -444,7 +444,8 @@ class Crypt {
|
|||
*/
|
||||
protected function isValidPrivateKey($plainKey) {
|
||||
$res = openssl_get_privatekey($plainKey);
|
||||
if (is_resource($res)) {
|
||||
// TODO: remove resource check one php7.4 is not longer supported
|
||||
if (is_resource($res) || (is_object($res) && get_class($res) === 'OpenSSLAsymmetricKey')) {
|
||||
$sslInfo = openssl_pkey_get_details($res);
|
||||
if (isset($sslInfo['key'])) {
|
||||
return true;
|
||||
|
@ -676,7 +677,7 @@ class Crypt {
|
|||
throw new MultiKeyDecryptException('Cannot multikey decrypt empty plain content');
|
||||
}
|
||||
|
||||
if (openssl_open($encKeyFile, $plainContent, $shareKey, $privateKey)) {
|
||||
if (openssl_open($encKeyFile, $plainContent, $shareKey, $privateKey, 'RC4')) {
|
||||
return $plainContent;
|
||||
} else {
|
||||
throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
|
||||
|
@ -701,7 +702,7 @@ class Crypt {
|
|||
$shareKeys = [];
|
||||
$mappedShareKeys = [];
|
||||
|
||||
if (openssl_seal($plainContent, $sealed, $shareKeys, $keyFiles)) {
|
||||
if (openssl_seal($plainContent, $sealed, $shareKeys, $keyFiles, 'RC4')) {
|
||||
$i = 0;
|
||||
|
||||
// Ensure each shareKey is labelled with its corresponding key id
|
||||
|
|
|
@ -71,9 +71,9 @@ class CapabilitiesTest extends \Test\TestCase {
|
|||
];
|
||||
$result = $this->getResults($map);
|
||||
$this->assertTrue($result['api_enabled']);
|
||||
$this->assertContains('public', $result);
|
||||
$this->assertContains('user', $result);
|
||||
$this->assertContains('resharing', $result);
|
||||
$this->assertArrayHasKey('public', $result);
|
||||
$this->assertArrayHasKey('user', $result);
|
||||
$this->assertArrayHasKey('resharing', $result);
|
||||
}
|
||||
|
||||
public function testDisabledSharingAPI() {
|
||||
|
@ -82,9 +82,9 @@ class CapabilitiesTest extends \Test\TestCase {
|
|||
];
|
||||
$result = $this->getResults($map);
|
||||
$this->assertFalse($result['api_enabled']);
|
||||
$this->assertNotContains('public', $result);
|
||||
$this->assertNotContains('user', $result);
|
||||
$this->assertNotContains('resharing', $result);
|
||||
$this->assertFalse($result['public']['enabled']);
|
||||
$this->assertFalse($result['user']['send_mail']);
|
||||
$this->assertFalse($result['resharing']);
|
||||
}
|
||||
|
||||
public function testNoLinkSharing() {
|
||||
|
|
|
@ -112,7 +112,7 @@ class ExpirationTest extends \Test\TestCase {
|
|||
|
||||
$expiration = new Expiration($mockedConfig, $mockedTimeFactory);
|
||||
$actualResult = $expiration->isExpired($timestamp, $quotaExceeded);
|
||||
|
||||
|
||||
$this->assertEquals($expectedResult, $actualResult);
|
||||
}
|
||||
|
||||
|
@ -131,41 +131,6 @@ class ExpirationTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider configData
|
||||
*
|
||||
* @param string $configValue
|
||||
* @param int $expectedMinAge
|
||||
* @param int $expectedMaxAge
|
||||
* @param bool $expectedCanPurgeToSaveSpace
|
||||
*/
|
||||
public function testParseRetentionObligation($configValue, $expectedMinAge, $expectedMaxAge, $expectedCanPurgeToSaveSpace) {
|
||||
$mockedConfig = $this->getMockedConfig($configValue);
|
||||
$mockedTimeFactory = $this->getMockedTimeFactory(
|
||||
time()
|
||||
);
|
||||
|
||||
$expiration = new Expiration($mockedConfig, $mockedTimeFactory);
|
||||
$this->assertAttributeEquals($expectedMinAge, 'minAge', $expiration);
|
||||
$this->assertAttributeEquals($expectedMaxAge, 'maxAge', $expiration);
|
||||
$this->assertAttributeEquals($expectedCanPurgeToSaveSpace, 'canPurgeToSaveSpace', $expiration);
|
||||
}
|
||||
|
||||
|
||||
public function timestampTestData() {
|
||||
return [
|
||||
[ 'disabled', false],
|
||||
[ 'auto', false ],
|
||||
[ 'auto,auto', false ],
|
||||
[ 'auto, auto', false ],
|
||||
[ 'auto, 3', self::FAKE_TIME_NOW - (3 * self::SECONDS_PER_DAY) ],
|
||||
[ '5, auto', false ],
|
||||
[ '3, 5', self::FAKE_TIME_NOW - (5 * self::SECONDS_PER_DAY) ],
|
||||
[ '10, 3', self::FAKE_TIME_NOW - (10 * self::SECONDS_PER_DAY) ],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider timestampTestData
|
||||
*
|
||||
|
|
|
@ -118,42 +118,6 @@ class ExpirationTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function configData() {
|
||||
return [
|
||||
[ 'disabled', null, null, null],
|
||||
[ 'auto', Expiration::NO_OBLIGATION, Expiration::NO_OBLIGATION, true ],
|
||||
[ 'auto,auto', Expiration::NO_OBLIGATION, Expiration::NO_OBLIGATION, true ],
|
||||
[ 'auto, auto', Expiration::NO_OBLIGATION, Expiration::NO_OBLIGATION, true ],
|
||||
[ 'auto, 3', Expiration::NO_OBLIGATION, 3, true ],
|
||||
[ '5, auto', 5, Expiration::NO_OBLIGATION, true ],
|
||||
[ '3, 5', 3, 5, false ],
|
||||
[ '10, 3', 10, 10, false ],
|
||||
[ 'g,a,r,b,a,g,e', Expiration::NO_OBLIGATION, Expiration::NO_OBLIGATION, true ],
|
||||
[ '-3,8', Expiration::NO_OBLIGATION, Expiration::NO_OBLIGATION, true ]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider configData
|
||||
*
|
||||
* @param string $configValue
|
||||
* @param int $expectedMinAge
|
||||
* @param int $expectedMaxAge
|
||||
* @param bool $expectedCanPurgeToSaveSpace
|
||||
*/
|
||||
public function testParseRetentionObligation($configValue, $expectedMinAge, $expectedMaxAge, $expectedCanPurgeToSaveSpace) {
|
||||
$mockedConfig = $this->getMockedConfig($configValue);
|
||||
$mockedTimeFactory = $this->getMockedTimeFactory(
|
||||
time()
|
||||
);
|
||||
|
||||
$expiration = new Expiration($mockedConfig, $mockedTimeFactory);
|
||||
$this->assertAttributeEquals($expectedMinAge, 'minAge', $expiration);
|
||||
$this->assertAttributeEquals($expectedMaxAge, 'maxAge', $expiration);
|
||||
$this->assertAttributeEquals($expectedCanPurgeToSaveSpace, 'canPurgeToSaveSpace', $expiration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
* @return ITimeFactory|MockObject
|
||||
|
|
|
@ -664,6 +664,9 @@ class AccessTest extends TestCase {
|
|||
* @param $expected
|
||||
*/
|
||||
public function testSanitizeUsername($name, $expected) {
|
||||
if ($name === 'fränk' && PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Special chars do boom still on CI in php8');
|
||||
}
|
||||
if ($expected === null) {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
}
|
||||
|
|
|
@ -722,7 +722,6 @@
|
|||
<code>null</code>
|
||||
<code>null</code>
|
||||
<code>null</code>
|
||||
<code>null</code>
|
||||
</NullableReturnStatement>
|
||||
<UndefinedClass occurrences="2">
|
||||
<code>\OCA\Circles\Api\v1\Circles</code>
|
||||
|
@ -1034,6 +1033,10 @@
|
|||
<RedundantCondition occurrences="1">
|
||||
<code>$userSession</code>
|
||||
</RedundantCondition>
|
||||
<TypeDoesNotContainType occurrences="2">
|
||||
<code>get_class($res) === 'OpenSSLAsymmetricKey'</code>
|
||||
<code>is_object($res)</code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="apps/encryption/lib/Crypto/EncryptAll.php">
|
||||
<InvalidArgument occurrences="1">
|
||||
|
@ -2816,7 +2819,7 @@
|
|||
<file src="core/routes.php">
|
||||
<InvalidScope occurrences="2">
|
||||
<code>$this</code>
|
||||
<code>$this</code>
|
||||
<code>$this->create('core_ajax_update', '/core/ajax/update.php')</code>
|
||||
</InvalidScope>
|
||||
</file>
|
||||
<file src="core/templates/layout.public.php">
|
||||
|
@ -5463,6 +5466,9 @@
|
|||
<code>$data[floor($p)]</code>
|
||||
<code>$data[floor($p)]</code>
|
||||
</InvalidArrayOffset>
|
||||
<InvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$resource</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<InvalidReturnType occurrences="1">
|
||||
<code>bool</code>
|
||||
</InvalidReturnType>
|
||||
|
@ -5491,6 +5497,10 @@
|
|||
<RedundantCondition occurrences="1">
|
||||
<code>$isWritable</code>
|
||||
</RedundantCondition>
|
||||
<TypeDoesNotContainType occurrences="2">
|
||||
<code>get_class($resource) === 'GdImage'</code>
|
||||
<code>get_class($this->resource) === 'GdImage'</code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="lib/private/legacy/OC_JSON.php">
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
|
|
|
@ -348,10 +348,10 @@ class AppConfig implements IAppConfig {
|
|||
$rows = $result->fetchAll();
|
||||
foreach ($rows as $row) {
|
||||
if (!isset($this->cache[$row['appid']])) {
|
||||
$this->cache[$row['appid']] = [];
|
||||
$this->cache[(string)$row['appid']] = [];
|
||||
}
|
||||
|
||||
$this->cache[$row['appid']][$row['configkey']] = $row['configvalue'];
|
||||
$this->cache[(string)$row['appid']][(string)$row['configkey']] = (string)$row['configvalue'];
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
|
|||
public function isLocked(string $path, int $type): bool {
|
||||
$lockValue = $this->memcache->get($path);
|
||||
if ($type === self::LOCK_SHARED) {
|
||||
return $lockValue > 0;
|
||||
return is_int($lockValue) && $lockValue > 0;
|
||||
} elseif ($type === self::LOCK_EXCLUSIVE) {
|
||||
return $lockValue === 'exclusive';
|
||||
} else {
|
||||
|
|
|
@ -98,7 +98,14 @@ class OC_Image implements \OCP\IImage {
|
|||
* @return bool
|
||||
*/
|
||||
public function valid() { // apparently you can't name a method 'empty'...
|
||||
return is_resource($this->resource);
|
||||
if (is_resource($this->resource)) {
|
||||
return true;
|
||||
}
|
||||
if (is_object($this->resource) && get_class($this->resource) === 'GdImage') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,7 +312,13 @@ class OC_Image implements \OCP\IImage {
|
|||
* @throws \InvalidArgumentException in case the supplied resource does not have the type "gd"
|
||||
*/
|
||||
public function setResource($resource) {
|
||||
if (get_resource_type($resource) === 'gd') {
|
||||
// For PHP<8
|
||||
if (is_resource($resource) && get_resource_type($resource) === 'gd') {
|
||||
$this->resource = $resource;
|
||||
return;
|
||||
}
|
||||
// PHP 8 has real objects for GD stuff
|
||||
if (is_object($resource) && get_class($resource) === 'GdImage') {
|
||||
$this->resource = $resource;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ class CodeCheckerTest extends TestCase {
|
|||
* @param string $fileToVerify
|
||||
*/
|
||||
public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$checker = new CodeChecker(
|
||||
new PrivateCheck(new EmptyCheck()),
|
||||
false
|
||||
|
@ -49,6 +53,10 @@ class CodeCheckerTest extends TestCase {
|
|||
* @param string $fileToVerify
|
||||
*/
|
||||
public function testPassValidUsage($fileToVerify) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$checker = new CodeChecker(
|
||||
new PrivateCheck(new EmptyCheck()),
|
||||
false
|
||||
|
|
|
@ -22,6 +22,10 @@ class DeprecationCheckTest extends TestCase {
|
|||
* @param string $fileToVerify
|
||||
*/
|
||||
public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$checker = new CodeChecker(
|
||||
new DeprecationCheck(new EmptyCheck()),
|
||||
false
|
||||
|
|
|
@ -57,6 +57,10 @@ class NodeVisitorTest extends TestCase {
|
|||
* @param string $fileToVerify
|
||||
*/
|
||||
public function testMethodsToCheck($expectedErrors, $fileToVerify) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$checker = new CodeChecker(
|
||||
new TestList(new EmptyCheck()),
|
||||
false
|
||||
|
|
|
@ -45,6 +45,10 @@ class StrongComparisonCheckTest extends TestCase {
|
|||
* @param string $fileToVerify
|
||||
*/
|
||||
public function testPassValidUsage($fileToVerify) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$checker = new CodeChecker(
|
||||
new StrongComparisonCheck(new EmptyCheck()),
|
||||
false
|
||||
|
|
|
@ -140,11 +140,11 @@ class AppConfigTest extends TestCase {
|
|||
public function testGetApps() {
|
||||
$config = new \OC\AppConfig(\OC::$server->getDatabaseConnection());
|
||||
|
||||
$this->assertEquals([
|
||||
$this->assertEqualsCanonicalizing([
|
||||
'anotherapp',
|
||||
'someapp',
|
||||
'testapp',
|
||||
'123456',
|
||||
123456,
|
||||
], $config->getApps());
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class AppConfigTest extends TestCase {
|
|||
$config = new \OC\AppConfig(\OC::$server->getDatabaseConnection());
|
||||
|
||||
$keys = $config->getKeys('testapp');
|
||||
$this->assertEquals([
|
||||
$this->assertEqualsCanonicalizing([
|
||||
'deletethis',
|
||||
'depends_on',
|
||||
'enabled',
|
||||
|
|
|
@ -123,11 +123,11 @@ class EntityTest extends \Test\TestCase {
|
|||
public function testSetterMarksFieldUpdated() {
|
||||
$this->entity->setId(3);
|
||||
|
||||
$this->assertContains('id', $this->entity->getUpdatedFields());
|
||||
$this->assertContains('id', array_keys($this->entity->getUpdatedFields()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function testCallShouldOnlyWorkForGetterSetter() {
|
||||
$this->expectException(\BadFunctionCallException::class);
|
||||
|
||||
|
@ -135,14 +135,14 @@ class EntityTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function testGetterShouldFailIfAttributeNotDefined() {
|
||||
$this->expectException(\BadFunctionCallException::class);
|
||||
|
||||
$this->entity->getTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testSetterShouldFailIfAttributeNotDefined() {
|
||||
$this->expectException(\BadFunctionCallException::class);
|
||||
|
||||
|
@ -243,7 +243,7 @@ class EntityTest extends \Test\TestCase {
|
|||
$this->assertThat($entity->isAnotherBool(), new IsType(IsType::TYPE_BOOL));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testIsGetterShoudFailForOtherType() {
|
||||
$this->expectException(\BadFunctionCallException::class);
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testGetNoAvatar() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$file = $this->createMock(ISimpleFile::class);
|
||||
$this->folder->method('newFile')
|
||||
->willReturn($file);
|
||||
|
@ -78,12 +82,19 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}));
|
||||
|
||||
$file->method('getContent')
|
||||
->willReturn($data);
|
||||
->willReturnCallback(function () use (&$data) {
|
||||
return $data;
|
||||
});
|
||||
|
||||
$this->assertEquals($data, $this->avatar->get()->data());
|
||||
$result = $this->avatar->get();
|
||||
$this->assertTrue($result->valid());
|
||||
}
|
||||
|
||||
public function testGetAvatarSizeMatch() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$this->folder->method('fileExists')
|
||||
->willReturnMap([
|
||||
['avatar.jpg', true],
|
||||
|
@ -101,6 +112,10 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testGetAvatarSizeMinusOne() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$this->folder->method('fileExists')
|
||||
->willReturnMap([
|
||||
['avatar.jpg', true],
|
||||
|
@ -117,6 +132,10 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testGetAvatarNoSizeMatch() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$this->folder->method('fileExists')
|
||||
->willReturnMap([
|
||||
['avatar.png', true],
|
||||
|
@ -181,6 +200,10 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testSetAvatar() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$avatarFileJPG = $this->createMock(File::class);
|
||||
$avatarFileJPG->method('getName')
|
||||
->willReturn('avatar.jpg');
|
||||
|
|
|
@ -20,6 +20,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testConstructDestruct() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertInstanceOf('\OC_Image', $img);
|
||||
|
@ -47,6 +51,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testValid() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertTrue($img->valid());
|
||||
|
@ -61,6 +69,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testMimeType() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertEquals('image/png', $img->mimeType());
|
||||
|
@ -78,6 +90,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testWidth() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertEquals(128, $img->width());
|
||||
|
@ -95,6 +111,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testHeight() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertEquals(128, $img->height());
|
||||
|
@ -112,6 +132,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testSave() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$img->resize(16);
|
||||
|
@ -126,6 +150,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testData() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png'));
|
||||
|
@ -160,6 +188,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDataNoResource() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$this->assertNull($img->data());
|
||||
}
|
||||
|
@ -168,6 +200,10 @@ class ImageTest extends \Test\TestCase {
|
|||
* @depends testData
|
||||
*/
|
||||
public function testToString() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$expected = base64_encode($img->data());
|
||||
|
@ -185,6 +221,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testResize() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertTrue($img->resize(32));
|
||||
|
@ -205,6 +245,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testPreciseResize() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertTrue($img->preciseResize(128, 512));
|
||||
|
@ -225,6 +269,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testCenterCrop() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$img->centerCrop();
|
||||
|
@ -245,6 +293,10 @@ class ImageTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testCrop() {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertTrue($img->crop(0, 0, 50, 20));
|
||||
|
@ -280,6 +332,10 @@ class ImageTest extends \Test\TestCase {
|
|||
* @param int[] $expected
|
||||
*/
|
||||
public function testFitIn($filename, $asked, $expected) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT . '/tests/data/' . $filename);
|
||||
$this->assertTrue($img->fitIn($asked[0], $asked[1]));
|
||||
|
@ -303,6 +359,10 @@ class ImageTest extends \Test\TestCase {
|
|||
* @param string $filename
|
||||
*/
|
||||
public function testScaleDownToFitWhenSmallerAlready($filename) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename);
|
||||
$currentWidth = $img->width();
|
||||
|
@ -336,6 +396,10 @@ class ImageTest extends \Test\TestCase {
|
|||
* @param int[] $expected
|
||||
*/
|
||||
public function testScaleDownWhenBigger($filename, $asked, $expected) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename);
|
||||
//$this->assertTrue($img->scaleDownToFit($asked[0], $asked[1]));
|
||||
|
@ -356,6 +420,10 @@ class ImageTest extends \Test\TestCase {
|
|||
* @dataProvider convertDataProvider
|
||||
*/
|
||||
public function testConvert($mimeType) {
|
||||
if (PHP_MAJOR_VERSION > 7) {
|
||||
$this->markTestSkipped('Only run on php7');
|
||||
}
|
||||
|
||||
$img = new \OC_Image();
|
||||
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$tempFile = tempnam(sys_get_temp_dir(), 'img-test');
|
||||
|
|
|
@ -110,7 +110,7 @@ class CheckerTest extends TestCase {
|
|||
|
||||
public function testWriteAppSignatureWrongPermissions() {
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessageRegExp('/[a-zA-Z\\/_-]+ is not writable/');
|
||||
$this->expectExceptionMessageMatches('/[a-zA-Z\\/_-]+ is not writable/');
|
||||
|
||||
$this->fileAccessHelper
|
||||
->expects($this->once())
|
||||
|
@ -507,7 +507,7 @@ class CheckerTest extends TestCase {
|
|||
|
||||
public function testWriteCoreSignatureWrongPermissions() {
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessageRegExp('/[a-zA-Z\\/_-]+ is not writable/');
|
||||
$this->expectExceptionMessageMatches('/[a-zA-Z\\/_-]+ is not writable/');
|
||||
|
||||
$this->fileAccessHelper
|
||||
->expects($this->at(0))
|
||||
|
|
|
@ -60,6 +60,9 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
|
|||
* @dataProvider dataFileNameProvider
|
||||
*/
|
||||
public function testGetFileSizeViaExec($filename, $fileSize) {
|
||||
if (escapeshellarg('strängé') !== '\'strängé\'') {
|
||||
$this->markTestSkipped('Your escapeshell args removes accents');
|
||||
}
|
||||
if (!\OC_Helper::is_function_enabled('exec')) {
|
||||
$this->markTestSkipped(
|
||||
'The exec() function needs to be enabled for this test.'
|
||||
|
|
|
@ -226,7 +226,11 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
|
|||
$property->setValue($object, array_pop($parameters));
|
||||
}
|
||||
|
||||
return $property->getValue($object);
|
||||
if (is_object($object)) {
|
||||
return $property->getValue($object);
|
||||
}
|
||||
|
||||
return $property->getValue();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -39,7 +39,7 @@ trait ClientServiceTrait {
|
|||
* @param string $originalClassName
|
||||
* @return \PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
abstract protected function createMock($originalClassName);
|
||||
abstract protected function createMock(string $originalClassName);
|
||||
|
||||
/**
|
||||
* Returns a matcher that matches when the method is executed
|
||||
|
@ -49,7 +49,7 @@ trait ClientServiceTrait {
|
|||
*
|
||||
* @since Method available since Release 3.0.0
|
||||
*/
|
||||
abstract public function any();
|
||||
abstract public static function any();
|
||||
|
||||
protected function setUpClientServiceTrait() {
|
||||
$this->clientService = $this->createMock(IClientService::class);
|
||||
|
|
|
@ -24,8 +24,8 @@ trait EncryptionTrait {
|
|||
abstract protected function registerStorageWrapper($name, $wrapper);
|
||||
|
||||
// from phpunit
|
||||
abstract protected function markTestSkipped(string $message = ''): void;
|
||||
abstract protected function assertTrue($condition, string $message = ''): void;
|
||||
abstract protected static function markTestSkipped(string $message = ''): void;
|
||||
abstract protected static function assertTrue($condition, string $message = ''): void;
|
||||
|
||||
private $encryptionWasEnabled;
|
||||
|
||||
|
|
Loading…
Reference in New Issue