style(PHP): adapt to coding-style bump
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Родитель
76895b5b2c
Коммит
638ae9dcb3
|
@ -49,7 +49,7 @@ class Client {
|
||||||
Storage::SP_PROPERTY_SIZE,
|
Storage::SP_PROPERTY_SIZE,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var ClientContext */
|
/** @var ClientContext */
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
|
@ -57,7 +57,7 @@ class Client {
|
||||||
/** @var ContextsFactory */
|
/** @var ContextsFactory */
|
||||||
private $contextsFactory;
|
private $contextsFactory;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $sharePointUrl;
|
private $sharePointUrl;
|
||||||
|
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
|
@ -76,7 +76,7 @@ class Client {
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
string $sharePointUrl,
|
string $sharePointUrl,
|
||||||
array $credentials,
|
array $credentials,
|
||||||
array $options
|
array $options,
|
||||||
) {
|
) {
|
||||||
$this->contextsFactory = $contextsFactory;
|
$this->contextsFactory = $contextsFactory;
|
||||||
$this->sharePointUrl = $sharePointUrl;
|
$this->sharePointUrl = $sharePointUrl;
|
||||||
|
@ -95,7 +95,7 @@ class Client {
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function fetchFileOrFolder($path, array $properties = null) {
|
public function fetchFileOrFolder($path, ?array $properties = null) {
|
||||||
$fetchFileFunc = function ($path, $props) {
|
$fetchFileFunc = function ($path, $props) {
|
||||||
return $this->fetchFile($path, $props);
|
return $this->fetchFile($path, $props);
|
||||||
};
|
};
|
||||||
|
@ -145,7 +145,7 @@ class Client {
|
||||||
* @param array|null $properties
|
* @param array|null $properties
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public function fetchFile($relativeServerPath, array $properties = null): File {
|
public function fetchFile($relativeServerPath, ?array $properties = null): File {
|
||||||
$this->ensureConnection();
|
$this->ensureConnection();
|
||||||
$file = $this->context->getWeb()->getFileByServerRelativeUrl($relativeServerPath);
|
$file = $this->context->getWeb()->getFileByServerRelativeUrl($relativeServerPath);
|
||||||
$this->loadAndExecute($file, $properties);
|
$this->loadAndExecute($file, $properties);
|
||||||
|
@ -159,7 +159,7 @@ class Client {
|
||||||
* @param array|null $properties
|
* @param array|null $properties
|
||||||
* @return Folder
|
* @return Folder
|
||||||
*/
|
*/
|
||||||
public function fetchFolder($relativeServerPath, array $properties = null) {
|
public function fetchFolder($relativeServerPath, ?array $properties = null) {
|
||||||
$this->ensureConnection();
|
$this->ensureConnection();
|
||||||
$folder = $this->context->getWeb()->getFolderByServerRelativeUrl($relativeServerPath);
|
$folder = $this->context->getWeb()->getFolderByServerRelativeUrl($relativeServerPath);
|
||||||
$allFields = $folder->getListItemAllFields();
|
$allFields = $folder->getListItemAllFields();
|
||||||
|
@ -230,7 +230,7 @@ class Client {
|
||||||
$request->ensureHeader('X-HTTP-Method', 'PUT'); // yes, PUT
|
$request->ensureHeader('X-HTTP-Method', 'PUT'); // yes, PUT
|
||||||
$this->context->ensureFormDigest($request);
|
$this->context->ensureFormDigest($request);
|
||||||
$request->StreamHandle = $fp;
|
$request->StreamHandle = $fp;
|
||||||
$request->ensureHeader("Content-Length", (string)filesize($localPath));
|
$request->ensureHeader('Content-Length', (string)filesize($localPath));
|
||||||
|
|
||||||
$this->context->executeQueryDirect($request);
|
$this->context->executeQueryDirect($request);
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ class Client {
|
||||||
* @param ClientObject $object
|
* @param ClientObject $object
|
||||||
* @param array|null $properties
|
* @param array|null $properties
|
||||||
*/
|
*/
|
||||||
public function loadAndExecute(ClientObject $object, array $properties = null) {
|
public function loadAndExecute(ClientObject $object, ?array $properties = null) {
|
||||||
$this->context->load($object, $properties);
|
$this->context->load($object, $properties);
|
||||||
$this->context->executeQuery();
|
$this->context->executeQuery();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ClientFactory {
|
||||||
ContextsFactory $contextsFactory,
|
ContextsFactory $contextsFactory,
|
||||||
string $sharePointUrl,
|
string $sharePointUrl,
|
||||||
array $credentials,
|
array $credentials,
|
||||||
array $options = []
|
array $options = [],
|
||||||
): Client {
|
): Client {
|
||||||
return new Client(
|
return new Client(
|
||||||
$contextsFactory,
|
$contextsFactory,
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ContextsFactory {
|
||||||
string $url,
|
string $url,
|
||||||
string $user,
|
string $user,
|
||||||
string $password,
|
string $password,
|
||||||
bool $useNtlm = false
|
bool $useNtlm = false,
|
||||||
): ClientContext {
|
): ClientContext {
|
||||||
$clientContext = new ClientContext($url);
|
$clientContext = new ClientContext($url);
|
||||||
$credentials = new UserCredentials($user, $password);
|
$credentials = new UserCredentials($user, $password);
|
||||||
|
@ -50,14 +50,14 @@ class ContextsFactory {
|
||||||
*/
|
*/
|
||||||
protected function withCredentials(
|
protected function withCredentials(
|
||||||
ClientContext $clientContext,
|
ClientContext $clientContext,
|
||||||
UserCredentials $userCredentials
|
UserCredentials $userCredentials,
|
||||||
): ClientContext {
|
): ClientContext {
|
||||||
return $clientContext->withCredentials($userCredentials);
|
return $clientContext->withCredentials($userCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getWithNtlm(
|
protected function getWithNtlm(
|
||||||
ClientContext $clientContext,
|
ClientContext $clientContext,
|
||||||
UserCredentials $userCredentials
|
UserCredentials $userCredentials,
|
||||||
) {
|
) {
|
||||||
return $clientContext->withNtlm($userCredentials);
|
return $clientContext->withNtlm($userCredentials);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ExternalStoragesRegistrationListener implements IEventListener {
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private BackendService $backendService,
|
private BackendService $backendService,
|
||||||
private BackendProvider $backendProvider
|
private BackendProvider $backendProvider,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,22 +53,22 @@ class Storage extends Common {
|
||||||
public const SP_PERMISSION_UPDATE = 3;
|
public const SP_PERMISSION_UPDATE = 3;
|
||||||
public const SP_PERMISSION_DELETE = 4;
|
public const SP_PERMISSION_DELETE = 4;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $server;
|
protected $server;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $documentLibrary;
|
protected $documentLibrary;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $authUser;
|
protected $authUser;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $authPwd;
|
protected $authPwd;
|
||||||
|
|
||||||
/** @var Client */
|
/** @var Client */
|
||||||
protected $spClient;
|
protected $spClient;
|
||||||
|
|
||||||
/** @var CappedMemoryCache */
|
/** @var CappedMemoryCache */
|
||||||
protected $fileCache;
|
protected $fileCache;
|
||||||
/** @var false|mixed */
|
/** @var false|mixed */
|
||||||
protected $forceNtlm;
|
protected $forceNtlm;
|
||||||
|
@ -589,7 +589,7 @@ class Storage extends Common {
|
||||||
// cache children instances
|
// cache children instances
|
||||||
foreach ($contents as $collection) {
|
foreach ($contents as $collection) {
|
||||||
foreach ($collection->getData() as $item) {
|
foreach ($collection->getData() as $item) {
|
||||||
/** @var File|Folder $item */
|
/** @var File|Folder $item */
|
||||||
$url = $item->getProperty(self::SP_PROPERTY_URL);
|
$url = $item->getProperty(self::SP_PROPERTY_URL);
|
||||||
if (is_null($url)) {
|
if (is_null($url)) {
|
||||||
// at least on SP13 requesting self::SP_PROPERTY_URL against folders causes an exception
|
// at least on SP13 requesting self::SP_PROPERTY_URL against folders causes an exception
|
||||||
|
|
|
@ -41,7 +41,7 @@ use Psr\Log\LoggerInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SharePointClientTest extends TestCase {
|
class SharePointClientTest extends TestCase {
|
||||||
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $contextsFactory;
|
protected $contextsFactory;
|
||||||
|
|
||||||
protected string $documentLibraryTitle;
|
protected string $documentLibraryTitle;
|
||||||
|
@ -174,7 +174,7 @@ class SharePointClientTest extends TestCase {
|
||||||
static $cnt = 0;
|
static $cnt = 0;
|
||||||
$cnt++;
|
$cnt++;
|
||||||
if ($cnt === 1) {
|
if ($cnt === 1) {
|
||||||
$errorPayload = '{"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The file ' . $path . ' does not exist."}}}';
|
$errorPayload = '{"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The file ' . $path . ' does not exist."}}}';
|
||||||
throw new RequestException($errorPayload, 404);
|
throw new RequestException($errorPayload, 404);
|
||||||
} elseif ($cnt === 2) {
|
} elseif ($cnt === 2) {
|
||||||
$errorPayload = '{"error":{"code":"-2147024894, System.IO.FileNotFoundException","message":{"lang":"en-US","value":"File Not Found."}}}';
|
$errorPayload = '{"error":{"code":"-2147024894, System.IO.FileNotFoundException","message":{"lang":"en-US","value":"File Not Found."}}}';
|
||||||
|
@ -198,7 +198,7 @@ class SharePointClientTest extends TestCase {
|
||||||
public function testCreateFolderSuccess() {
|
public function testCreateFolderSuccess() {
|
||||||
$dirName = 'New Project Dir';
|
$dirName = 'New Project Dir';
|
||||||
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
|
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
|
||||||
$path = $parentPath . '/'. $dirName;
|
$path = $parentPath . '/' . $dirName;
|
||||||
|
|
||||||
$folderCollectionMock = $this->createMock(FolderCollection::class);
|
$folderCollectionMock = $this->createMock(FolderCollection::class);
|
||||||
$folderCollectionMock->expects($this->once())
|
$folderCollectionMock->expects($this->once())
|
||||||
|
@ -233,7 +233,7 @@ class SharePointClientTest extends TestCase {
|
||||||
public function testCreateFolderError() {
|
public function testCreateFolderError() {
|
||||||
$dirName = 'New Project Dir';
|
$dirName = 'New Project Dir';
|
||||||
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
|
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
|
||||||
$path = $parentPath . '/'. $dirName;
|
$path = $parentPath . '/' . $dirName;
|
||||||
|
|
||||||
$folderCollectionMock = $this->createMock(FolderCollection::class);
|
$folderCollectionMock = $this->createMock(FolderCollection::class);
|
||||||
$folderCollectionMock->expects($this->once())
|
$folderCollectionMock->expects($this->once())
|
||||||
|
|
|
@ -38,19 +38,19 @@ use OCP\Files\FileInfo;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class StorageTest extends TestCase {
|
class StorageTest extends TestCase {
|
||||||
/** @var Storage */
|
/** @var Storage */
|
||||||
protected $storage;
|
protected $storage;
|
||||||
|
|
||||||
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $factory;
|
protected $factory;
|
||||||
|
|
||||||
/** @var ClientContext|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var ClientContext|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $clientContextMock;
|
protected $clientContextMock;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $documentLibraryTitle = 'Fancy Documents';
|
protected $documentLibraryTitle = 'Fancy Documents';
|
||||||
|
|
||||||
/** @var SPList|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var SPList|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $sharePointList;
|
protected $sharePointList;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -62,13 +62,13 @@ class StorageTest extends TestCase {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $examplePwd = 'a123456';
|
protected $examplePwd = 'a123456';
|
||||||
|
|
||||||
/** @var ClientFactory|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var ClientFactory|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $clientFactory;
|
protected $clientFactory;
|
||||||
|
|
||||||
/** @var Client|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var Client|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
/** @var CappedMemoryCache|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var CappedMemoryCache|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
protected $fileCache;
|
protected $fileCache;
|
||||||
|
|
||||||
protected function setUp(): void {
|
protected function setUp(): void {
|
||||||
|
|
|
@ -4,7 +4,7 @@ if (!defined('PHPUNIT_RUN')) {
|
||||||
define('PHPUNIT_RUN', 1);
|
define('PHPUNIT_RUN', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once __DIR__.'/../../../lib/base.php';
|
require_once __DIR__ . '/../../../lib/base.php';
|
||||||
|
|
||||||
// Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
|
// Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
|
||||||
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
|
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
|
||||||
|
|
Загрузка…
Ссылка в новой задаче