From b097c19c0aa807f78d20bcc3b590fd8b4c27390b Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Tue, 27 Feb 2018 09:30:57 +0100 Subject: [PATCH] correct phpcs config Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/api/commands/class.Domains.php | 2 +- lib/classes/api/commands/class.Froxlor.php | 23 +++++++----- phpcs.xml | 11 +++--- tests/Customers/CustomersTest.php | 41 +++++++++++++--------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/lib/classes/api/commands/class.Domains.php b/lib/classes/api/commands/class.Domains.php index c9539d6d..b3e433e3 100644 --- a/lib/classes/api/commands/class.Domains.php +++ b/lib/classes/api/commands/class.Domains.php @@ -1555,7 +1555,7 @@ class Domains extends ApiCommand implements ResourceEntity // trigger when domain id for alias destination has changed: both for old and new destination triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); - } else if ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) { + } elseif ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) { // or when wwwserveralias or letsencrypt was changed triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); } diff --git a/lib/classes/api/commands/class.Froxlor.php b/lib/classes/api/commands/class.Froxlor.php index 2f61e20c..d10a96b5 100644 --- a/lib/classes/api/commands/class.Froxlor.php +++ b/lib/classes/api/commands/class.Froxlor.php @@ -83,20 +83,24 @@ class Froxlor extends ApiCommand /** * * @todo import settings - * + * * @access admin */ public function importSettings() - {} + { + throw new Exception("Not available yet.", 501); + } /** * * @todo export settings to file - * + * * @access admin */ public function exportSettings() - {} + { + throw new Exception("Not available yet.", 501); + } /** * return a list of all settings @@ -202,7 +206,7 @@ class Froxlor extends ApiCommand array_push($functions, array_merge(array( 'module' => $module, 'function' => $func->name - ), $this->_getParamListFromDoc($module, $func->name))); + ), $this->getParamListFromDoc($module, $func->name))); } } } else { @@ -234,7 +238,7 @@ class Froxlor extends ApiCommand array_push($functions, array_merge(array( 'module' => $matches[1], 'function' => $func->name - ), $this->_getParamListFromDoc($matches[1], $func->name))); + ), $this->getParamListFromDoc($matches[1], $func->name))); } } } @@ -259,7 +263,7 @@ class Froxlor extends ApiCommand * @throws Exception * @return array|bool */ - private function _getParamListFromDoc($module = null, $function = null) + private function getParamListFromDoc($module = null, $function = null) { try { // set the module @@ -307,7 +311,8 @@ class Froxlor extends ApiCommand 'type' => $r[1], 'desc' => (isset($r[2]) ? trim($r[2]) : '') ); - } else if (! empty($c) && strpos($c, '@throws') === false) { + } + elseif (! empty($c) && strpos($c, '@throws') === false) { if (substr($c, 0, 3) == "/**") { continue; } @@ -331,7 +336,7 @@ class Froxlor extends ApiCommand } } } - $result['head'] =trim($result['head']); + $result['head'] = trim($result['head']); return $result; } catch (\ReflectionException $e) { return array(); diff --git a/phpcs.xml b/phpcs.xml index 757d1e74..e2a1b208 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,15 +1,12 @@ PSR2 with tabs instead of spaces. + + - - - - - - - + + diff --git a/tests/Customers/CustomersTest.php b/tests/Customers/CustomersTest.php index 6e2c354c..c90dd6c4 100644 --- a/tests/Customers/CustomersTest.php +++ b/tests/Customers/CustomersTest.php @@ -37,7 +37,9 @@ class CustomersTest extends TestCase 'custom_notes' => 'secret', 'custom_notes_show' => 0, 'gender' => 5, - 'allowed_phpconfigs' => array(1) + 'allowed_phpconfigs' => array( + 1 + ) ]; $json_result = Customers::getLocal($admin_userdata, $data)->add(); @@ -67,7 +69,7 @@ class CustomersTest extends TestCase 'firstname' => 'Test2', 'name' => 'Testman2' ]; - + $this->expectExceptionMessage('Requested parameter "email" is empty where it should not be for "Customers:add"'); Customers::getLocal($admin_userdata, $data)->add(); } @@ -127,12 +129,11 @@ class CustomersTest extends TestCase 'id' => 1 ))->get(); $customer_userdata = json_decode($json_result, true)['data']; - + $this->expectExceptionCode(403); $this->expectExceptionMessage("Not allowed to execute given command."); - + $json_result = Customers::getLocal($customer_userdata)->list(); - } /** @@ -248,7 +249,7 @@ class CustomersTest extends TestCase 'id' => 1, 'deactivated' => 0 ))->update(); - + // get customer $json_result = Customers::getLocal($admin_userdata, array( 'id' => 1 @@ -283,7 +284,7 @@ class CustomersTest extends TestCase ))->get(); $reseller_userdata = json_decode($json_result, true)['data']; $reseller_userdata['adminsession'] = 1; - + $this->expectExceptionMessage("You cannot allocate more resources than you own for yourself."); // add new customer $data = [ @@ -292,12 +293,12 @@ class CustomersTest extends TestCase 'firstname' => 'Test', 'name' => 'Testman', 'customernumber' => 1338, - 'subdomains' => -1, + 'subdomains' => - 1, 'new_customer_password' => 'h0lYmo1y' ]; Customers::getLocal($reseller_userdata, $data)->add(); } - + public function testCustomerCustomersDelete() { global $admin_userdata; @@ -308,7 +309,9 @@ class CustomersTest extends TestCase $customer_userdata = json_decode($json_result, true)['data']; $this->expectExceptionCode(403); $this->expectExceptionMessage("Not allowed to execute given command."); - Customers::getLocal($customer_userdata, array('loginname' => 'test1'))->delete(); + Customers::getLocal($customer_userdata, array( + 'loginname' => 'test1' + ))->delete(); } public function testResellerCustomersDeleteNotOwned() @@ -321,7 +324,9 @@ class CustomersTest extends TestCase $reseller_userdata = json_decode($json_result, true)['data']; $reseller_userdata['adminsession'] = 1; $this->expectExceptionCode(404); - Customers::getLocal($reseller_userdata, array('loginname' => 'test1'))->delete(); + Customers::getLocal($reseller_userdata, array( + 'loginname' => 'test1' + ))->delete(); } public function testAdminCustomersDelete() @@ -337,11 +342,13 @@ class CustomersTest extends TestCase 'new_customer_password' => 'h0lYmo1y' ]; Customers::getLocal($admin_userdata, $data)->add(); - $json_result = Customers::getLocal($admin_userdata, array('loginname' => 'test2'))->delete(); + $json_result = Customers::getLocal($admin_userdata, array( + 'loginname' => 'test2' + ))->delete(); $result = json_decode($json_result, true)['data']; $this->assertEquals('test2', $result['loginname']); } - + public function testAdminCustomersUnlock() { global $admin_userdata; @@ -353,7 +360,7 @@ class CustomersTest extends TestCase $result = json_decode($json_result, true)['data']; $this->assertEquals(0, $result['loginfail_count']); } - + public function testAdminCustomersUnlockNotAllowed() { global $admin_userdata; @@ -366,7 +373,7 @@ class CustomersTest extends TestCase 'loginname' => 'test1' ))->unlock(); } - + public function testAdminCustomersMoveNotAllowed() { global $admin_userdata; @@ -380,7 +387,7 @@ class CustomersTest extends TestCase 'adminid' => 1 ))->move(); } - + public function testAdminCustomersMoveTargetIsSource() { global $admin_userdata; @@ -403,5 +410,5 @@ class CustomersTest extends TestCase $this->assertEquals(2, $result['adminid']); } - } +