Adopt Laravel coding style

Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
This commit is contained in:
Laravel Shift
2021-06-10 20:15:52 +00:00
parent 54cb6c050a
commit 934afa036f
4549 changed files with 35238 additions and 38391 deletions
+17 -16
View File
@@ -28,7 +28,7 @@
* \Helper\HTMLValidator:
* javaPath: /usr/bin/java
* vnuPath: /usr/local/bin/vnu.jar
*
*
*
*
* Usage:
@@ -46,7 +46,6 @@
* @author Tobias Hößl <tobias@hoessl.eu>
*/
namespace Helper;
use Codeception\TestCase;
@@ -61,25 +60,25 @@ class HTMLValidator extends \Codeception\Module
private function validateByVNU($html)
{
$javaPath = $this->_getConfig('javaPath');
if (!$javaPath) {
if (! $javaPath) {
$javaPath = 'java';
}
$vnuPath = $this->_getConfig('vnuPath');
if (!$vnuPath) {
if (! $vnuPath) {
$vnuPath = '/usr/local/bin/vnu.jar';
}
$filename = DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . uniqid('html-validate') . '.html';
$filename = DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.uniqid('html-validate').'.html';
file_put_contents($filename, $html);
exec($javaPath . " -Xss1024k -jar " . $vnuPath . " --format json " . $filename . " 2>&1", $return);
exec($javaPath.' -Xss1024k -jar '.$vnuPath.' --format json '.$filename.' 2>&1', $return);
$data = json_decode($return[0], true);
if (!$data || !isset($data['messages']) || !is_array($data['messages'])) {
throw new \Exception('Invalid data returned from validation service: ' . $return);
if (! $data || ! isset($data['messages']) || ! is_array($data['messages'])) {
throw new \Exception('Invalid data returned from validation service: '.$return);
}
return $data['messages'];
}
/**
* @return string
* @throws \Codeception\Exception\ModuleException
@@ -87,12 +86,13 @@ class HTMLValidator extends \Codeception\Module
*/
private function getPageSource()
{
if (!$this->hasModule('WebDriver')) {
if (! $this->hasModule('WebDriver')) {
throw new \Exception('This validator needs WebDriver to work');
}
/** @var \Codeception\Module\WebDriver $webdriver */
$webdriver = $this->getModule('WebDriver');
return $webdriver->webDriver->getPageSource();
}
@@ -106,27 +106,28 @@ class HTMLValidator extends \Codeception\Module
$messages = $this->validateByVNU($source);
} catch (\Exception $e) {
$this->fail($e->getMessage());
return;
}
$failMessages = [];
$lines = explode("\n", $source);
$lines = explode("\n", $source);
foreach ($messages as $message) {
if ($message['type'] == 'error') {
$formattedMsg = '- Line ' . $message['lastLine'] . ', column ' . $message['lastColumn'] . ': ' .
$message['message'] . "\n > " . $lines[$message['lastLine'] - 1];
$ignoring = false;
$formattedMsg = '- Line '.$message['lastLine'].', column '.$message['lastColumn'].': '.
$message['message']."\n > ".$lines[$message['lastLine'] - 1];
$ignoring = false;
foreach ($ignoreMessages as $ignoreMessage) {
if (mb_stripos($formattedMsg, $ignoreMessage) !== false) {
$ignoring = true;
}
}
if (!$ignoring) {
if (! $ignoring) {
$failMessages[] = $formattedMsg;
}
}
}
if (count($failMessages) > 0) {
\PHPUnit_Framework_Assert::fail('Invalid HTML: ' . "\n" . implode("\n", $failMessages));
\PHPUnit_Framework_Assert::fail('Invalid HTML: '."\n".implode("\n", $failMessages));
}
}
}