1. Go to this page and download the library: Download drevops/phpcs-standard library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
function processOrder($order_id, $user_data) { // ✓ Valid
function processOrder($orderId, $userData) { // ✗ Error: NotSnakeCase
function processOrder($orderId, $userData) { // ✓ Valid
function processOrder($order_id, $user_data) { // ✗ Error: NotCamelCase
// phpcs:ignore DrevOps.NamingConventions.ParameterNaming.NotSnakeCase
function process($legacyParam) {}
class MyTest extends TestCase {
/**
* @dataProvider dataProviderUserLogin
*/
public function testUserLogin($data) {}
public function dataProviderUserLogin() { // ✓ Valid
return [];
}
public function providerUserLogin() { // ✗ Error: InvalidPrefix
return [];
}
}
// phpcs:ignore DrevOps.TestingPractices.DataProviderPrefix.InvalidPrefix
public function providerCustom() {}
class MyTest extends TestCase {
/**
* @dataProvider dataProviderUserLogin
*/
public function testUserLogin($data) {}
public function dataProviderUserLogin() { // ✓ Valid - ends with "UserLogin"
return [];
}
public function dataProviderLogin() { // ✗ Error: InvalidProviderName
return []; // Expected: ends with "UserLogin"
}
}
// phpcs:ignore DrevOps.TestingPractices.DataProviderMatchesTestName.InvalidProviderName
public function dataProviderCustomName() {}
class MyTest extends TestCase {
// ✓ Valid - provider after test (default)
/**
* @dataProvider dataProviderUserLogin
*/
public function testUserLogin($data) {}
public function dataProviderUserLogin() {
return [];
}
}
class MyTest extends TestCase {
/**
* @dataProvider dataProviderUserLogin
*/
public function testUserLogin($data) {}
private function helperMethod() {} // ✓ Allowed
public function dataProviderUserLogin() {
return [];
}
}
// phpcs:ignore DrevOps.TestingPractices.DataProviderOrder.ProviderBeforeTest
public function dataProviderUserLogin() {}
xml
<rule ref="DrevOps.TestingPractices.DataProviderPrefix">
<properties>
<property name="prefix" value="dataProvider"/>
</properties>
</rule>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.