Merge pull request #1690 from nextcloud/enh/php-cs

This commit is contained in:
John Molakvoæ 2020-07-09 17:34:33 +02:00 committed by GitHub
commit 093878aa88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 2225 additions and 1544 deletions

View File

@ -28,6 +28,30 @@ jobs:
- name: Lint
run: composer run lint
php-cs-fixer:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4']
name: cs php${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Install dependencies
run: composer i
- name: Run coding standards check
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
node:
runs-on: ubuntu-latest
@ -35,7 +59,7 @@ jobs:
matrix:
node-versions: [12.x]
name: node${{ matrix.node-versions }}
name: eslint node${{ matrix.node-versions }}
steps:
- uses: actions/checkout@v2
@ -49,3 +73,25 @@ jobs:
- name: Lint
run: npm run lint
stylelint:
runs-on: ubuntu-latest
strategy:
matrix:
node-versions: [12.x]
name: stylelint node${{ matrix.node-versions }}
steps:
- uses: actions/checkout@v2
- name: Set up node ${{ matrix.node-versions }}
uses: actions/setup-node@v1
with:
node-versions: ${{ matrix.node-versions }}
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run stylelint

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ js/
build/
coverage*
vendor/
/.php_cs.cache

17
.php_cs.dist Normal file
View File

@ -0,0 +1,17 @@
<?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')
->in(__DIR__);
return $config;

View File

@ -1,12 +1,15 @@
{
"require-dev": {
"christophwurst/nextcloud_testing": "^0.7.0"
"christophwurst/nextcloud_testing": "^0.7.0",
"nextcloud/coding-standard": "^0.3.0"
},
"config": {
"optimize-autoloader": true,
"classmap-authoritative": true
},
"scripts": {
"cs:fix": "php-cs-fixer fix",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"test:unit": "phpunit -c phpunit.xml --fail-on-warning",
"test:integration": "phpunit -c phpunit.integration.xml --fail-on-warning"

1626
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -21,14 +21,14 @@
*
*/
namespace OCA\Contacts\AppInfo;
use OCP\AppFramework\App;
use OCP\IURLGenerator;
use OCP\IL10N;
use OCP\INavigationManager;
class Application extends App {
const APP_ID = 'contacts';
public const APP_ID = 'contacts';
public function __construct() {
parent::__construct(self::APP_ID);
@ -65,6 +65,5 @@ class Application extends App {
// navigation or on the settings page of your app
'name' => $l10n->t('Contacts'),
]);
}
}

View File

@ -67,13 +67,13 @@ class DetailsProvider implements IProvider {
/**
* Return a list of the user's addressbooks unique uris
*
*
* @return array
* @since 16.0.0
*/
protected function getAddressBooksUris(): Array {
$result = array();
foreach($this->manager->getUserAddressbooks() as $addressBook) {
protected function getAddressBooksUris(): array {
$result = [];
foreach ($this->manager->getUserAddressbooks() as $addressBook) {
$result[$addressBook->getKey()] = $addressBook->getUri();
}
@ -114,7 +114,6 @@ class DetailsProvider implements IProvider {
// We need $this->manager->getAddressbooksUris() to add this function
$ncVersion = $this->config->getSystemValue('version', '0.0.0');
if (version_compare($ncVersion, '16.0.0', '>=')) {
$addressBookUri = $this->getAddressBookUri($entry->getProperty('addressbook-key'));
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/info.svg'));
@ -128,5 +127,4 @@ class DetailsProvider implements IProvider {
$entry->addAction($action);
}
}
}

View File

@ -32,11 +32,10 @@ use OCP\L10N\IFactory;
use OCP\Util;
class PageController extends Controller {
protected $appName;
/** @var IConfig */
private $config;
private $config;
/** @var IInitialStateService */
private $initialStateService;

1930
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,7 @@
"debounce": "^1.2.0",
"downloadjs": "^1.4.7",
"ical.js": "^1.4.0",
"moment": "^2.27.0",
"p-limit": "^2.3.0",
"p-queue": "^6.4.0",
"qr-image": "^3.2.0",

View File

@ -1,6 +1,6 @@
<?php
if (\OCP\Util::isIe()) {
?>
?>
<div id="app-content">
<div class="emptycontent">
<div class="icon-contacts-dark"></div>
@ -9,4 +9,5 @@ if (\OCP\Util::isIe()) {
</div>
</div>
<?php } ?>
<?php
} ?>

View File

@ -105,69 +105,69 @@ class DetailsProviderTest extends Base {
$this->config->expects($this->at(0))
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn($version);
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn($version);
$this->config->expects($this->at(1))
->method('getSystemValue')
->with('htaccess.IgnoreFrontController', false)
->willReturn($frontControllerActive);
->method('getSystemValue')
->with('htaccess.IgnoreFrontController', false)
->willReturn($frontControllerActive);
$entry->expects($this->exactly(3))
->method('getProperty')
->will($this->returnValueMap([
['UID', $uid],
['isLocalSystemBook', null],
['addressbook-key', 1]
]));
->method('getProperty')
->will($this->returnValueMap([
['UID', $uid],
['isLocalSystemBook', null],
['addressbook-key', 1]
]));
$addressbook->expects($this->once())
->method('getKey')
->willReturn(1);
->method('getKey')
->willReturn(1);
$addressbook->expects($this->once())
->method('getUri')
->willReturn($abUri);
->method('getUri')
->willReturn($abUri);
$this->manager->expects($this->once())
->method('getUserAddressbooks')
->willReturn([1 => $addressbook]);
->method('getUserAddressbooks')
->willReturn([1 => $addressbook]);
// Action icon
$this->urlGenerator->expects($this->once())
->method('imagePath')
->with('core', 'actions/info.svg')
->willReturn($iconUrl);
->method('imagePath')
->with('core', 'actions/info.svg')
->willReturn($iconUrl);
// Action icon and contact absolute urls
$this->urlGenerator->expects($this->exactly(2))
->method('getAbsoluteURL')
->will($this->returnValueMap([
[$iconUrl, "$domain/$iconUrl"],
["$index/apps/contacts/$defaultGroup/$uid~$abUri", "$domain$index/apps/contacts/$defaultGroup/$uid~$abUri"]
]));
->method('getAbsoluteURL')
->will($this->returnValueMap([
[$iconUrl, "$domain/$iconUrl"],
["$index/apps/contacts/$defaultGroup/$uid~$abUri", "$domain$index/apps/contacts/$defaultGroup/$uid~$abUri"]
]));
// Translations
$this->l10n->expects($this->at(0))
->method('t')
->with($defaultGroup)
->willReturn($defaultGroup);
->method('t')
->with($defaultGroup)
->willReturn($defaultGroup);
$this->l10n->expects($this->at(1))
->method('t')
->with('Details')
->method('t')
->with('Details')
->willReturnArgument(0);
$this->actionFactory->expects($this->once())
->method('newLinkAction')
->with($this->equalTo("$domain/$iconUrl"), $this->equalTo('Details'), $this->equalTo($resultUri))
->willReturn($action);
->method('newLinkAction')
->with($this->equalTo("$domain/$iconUrl"), $this->equalTo('Details'), $this->equalTo($resultUri))
->willReturn($action);
$action->expects($this->once())
->method('setPriority')
->with($this->equalTo(0));
->method('setPriority')
->with($this->equalTo(0));
$entry->expects($this->once())
->method('addAction')
->with($action);
->method('addAction')
->with($action);
$this->provider->process($entry);
}
@ -178,17 +178,17 @@ class DetailsProviderTest extends Base {
*/
public function testProcessNC15() {
$this->config->expects($this->once())
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn('15.0.0.0');
->method('getSystemValue')
->with('version', '0.0.0')
->willReturn('15.0.0.0');
$entry = $this->createMock(IEntry::class);
$entry->expects($this->exactly(2))
->method('getProperty')
->will($this->returnValueMap([
['UID', 'e3a71614-c602-4eb5-9994-47eec551542b'],
['isLocalSystemBook', null]
]));
->method('getProperty')
->will($this->returnValueMap([
['UID', 'e3a71614-c602-4eb5-9994-47eec551542b'],
['isLocalSystemBook', null]
]));
$this->assertNull($this->provider->process($entry));
}
@ -196,11 +196,11 @@ class DetailsProviderTest extends Base {
public function testProcessNoUID() {
$entry = $this->createMock(IEntry::class);
$entry->expects($this->once())
->method('getProperty')
->with($this->equalTo('UID'))
->willReturn(null);
->method('getProperty')
->with($this->equalTo('UID'))
->willReturn(null);
$entry->expects($this->never())
->method('addAction');
->method('addAction');
$this->provider->process($entry);
}
@ -208,15 +208,14 @@ class DetailsProviderTest extends Base {
public function testProcessSystemContact() {
$entry = $this->createMock(IEntry::class);
$entry->expects($this->exactly(2))
->method('getProperty')
->will($this->returnValueMap([
['UID', 1234],
['isLocalSystemBook', true]
]));
->method('getProperty')
->will($this->returnValueMap([
['UID', 1234],
['isLocalSystemBook', true]
]));
$entry->expects($this->never())
->method('addAction');
->method('addAction');
$this->provider->process($entry);
}
}

View File

@ -31,9 +31,7 @@ use OCP\IRequest;
use OCP\L10N\IFactory;
use ChristophWurst\Nextcloud\Testing\TestCase;
class PageControllerTest extends TestCase {
private $controller;
/** @var IRequest|MockObject */
@ -46,7 +44,7 @@ class PageControllerTest extends TestCase {
private $languageFactory;
/** @var IConfig|MockObject*/
private $config;
private $config;
public function setUp() {