diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-09-30 11:12:10 +0300 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-09-30 11:12:10 +0300 |
commit | 9591958a97e61066ae9616417184467ef1cabc42 (patch) | |
tree | 25ba081b6ee4206cfd6f94f864a4c3a02fe753b1 | |
parent | 3d6d10cb7d3241a93dd513c46f49c8b7e6421750 (diff) |
Add configuration for php-cs-fixer and run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .php-cs-fixer.dist.php | 18 | ||||
-rw-r--r-- | lib/Controller/FileHandlingController.php | 2 | ||||
-rw-r--r-- | lib/Controller/PublicFileHandlingController.php | 1 | ||||
-rw-r--r-- | tests/Controller/FileHandlingControllerTest.php | 8 | ||||
-rw-r--r-- | tests/SyntaxModeTest.php | 37 | ||||
-rw-r--r-- | tests/bootstrap.php | 2 |
7 files changed, 41 insertions, 29 deletions
@@ -7,3 +7,5 @@ node_modules build /vendor/ + +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..a68d640 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +require_once './vendor/autoload.php'; + +use Nextcloud\CodingStandard\Config; + +$config = new Config(); +$config + ->getFinder() + ->notPath('build') + ->notPath('l10n') + ->notPath('src') + ->notPath('vendor') + ->notPath('node_modules') + ->in(__DIR__); +return $config; diff --git a/lib/Controller/FileHandlingController.php b/lib/Controller/FileHandlingController.php index d72994b..2681a67 100644 --- a/lib/Controller/FileHandlingController.php +++ b/lib/Controller/FileHandlingController.php @@ -36,7 +36,6 @@ use OCP\IRequest; use OCP\Lock\LockedException; class FileHandlingController extends Controller { - /** @var IL10N */ private $l; @@ -145,7 +144,6 @@ class FileHandlingController extends Controller { public function save($path, $filecontents, $mtime) { try { if ($path !== '' && (is_int($mtime) && $mtime > 0)) { - /** @var File $file */ $file = $this->userFolder->get($path); diff --git a/lib/Controller/PublicFileHandlingController.php b/lib/Controller/PublicFileHandlingController.php index e81187e..5253166 100644 --- a/lib/Controller/PublicFileHandlingController.php +++ b/lib/Controller/PublicFileHandlingController.php @@ -34,7 +34,6 @@ use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; class PublicFileHandlingController extends Controller { - /** @var IL10N */ private $l; diff --git a/tests/Controller/FileHandlingControllerTest.php b/tests/Controller/FileHandlingControllerTest.php index 8480728..38fabdd 100644 --- a/tests/Controller/FileHandlingControllerTest.php +++ b/tests/Controller/FileHandlingControllerTest.php @@ -22,7 +22,6 @@ namespace OCA\FilesTextEditor\Tests\Controller; - use OC\HintException; use OCA\FilesTextEditor\Controller\FileHandlingController; use OCP\Files\File; @@ -35,7 +34,6 @@ use OCP\Lock\LockedException; use Test\TestCase; class FileHandlingControllerTest extends TestCase { - /** @var FileHandlingController */ protected $controller; @@ -63,7 +61,7 @@ class FileHandlingControllerTest extends TestCase { $this->userFolderMock = $this->createMock(Folder::class); $this->l10nMock->expects($this->any())->method('t')->willReturnCallback( - function($message) { + function ($message) { return $message; } ); @@ -211,7 +209,6 @@ class FileHandlingControllerTest extends TestCase { $this->assertArrayHasKey('message', $data); $this->assertSame($expectedMessage, $data['message']); } - } public function testFileTooBig() { @@ -230,7 +227,7 @@ class FileHandlingControllerTest extends TestCase { } public function dataTestSave() { - return array ( + return array( array('/test.txt', 'file content', 65638643, 65638643, true, 200, ''), array('', 'file content', 65638643, 65638643, true, 400, 'File path not supplied'), array('/test.txt', 'file content', '', 65638643, true, 400, 'File mtime not supplied'), @@ -239,5 +236,4 @@ class FileHandlingControllerTest extends TestCase { array('/test.txt', 'file content', 65638643, 65638643, false, 400, 'Insufficient permissions'), ); } - } diff --git a/tests/SyntaxModeTest.php b/tests/SyntaxModeTest.php index 4c9bc1f..d92876c 100644 --- a/tests/SyntaxModeTest.php +++ b/tests/SyntaxModeTest.php @@ -24,25 +24,24 @@ namespace OCA\FilesTextEditor\Tests; use Test\TestCase; -class SyntaxModeTest extends TestCase -{ - protected function setUp(): void { - parent::setUp(); - } +class SyntaxModeTest extends TestCase { + protected function setUp(): void { + parent::setUp(); + } - public function testJsSyntax() { - /* - * Make sure that the SyntaxMode.js file - * has a loader for every defined filetype. - * filetype["bat"] = "batchfile"; -> loaders["batchfile"] = ... - */ - $jsContent = file_get_contents('../js/SyntaxMode.js'); - preg_match_all('/^(?!\/\/.*$)filetype\[.*?\].*?=.*?"(.*?)"/m', $jsContent, $matches); + public function testJsSyntax() { + /* + * Make sure that the SyntaxMode.js file + * has a loader for every defined filetype. + * filetype["bat"] = "batchfile"; -> loaders["batchfile"] = ... + */ + $jsContent = file_get_contents('../js/SyntaxMode.js'); + preg_match_all('/^(?!\/\/.*$)filetype\[.*?\].*?=.*?"(.*?)"/m', $jsContent, $matches); - $fileTypes = $matches[1]; - foreach ($fileTypes as $fileType) { - $loaderDefined = preg_match('/loaders\["' . $fileType . '"\]/', $jsContent); - $this->assertSame($loaderDefined, 1); - } - } + $fileTypes = $matches[1]; + foreach ($fileTypes as $fileType) { + $loaderDefined = preg_match('/loaders\["' . $fileType . '"\]/', $jsContent); + $this->assertSame($loaderDefined, 1); + } + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9b157e3..5081dd1 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,7 +6,7 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../lib/base.php'; -if(!class_exists('\PHPUnit\Framework\TestCase')) { +if (!class_exists('\PHPUnit\Framework\TestCase')) { require_once('PHPUnit/Autoload.php'); } |