Skip to content

Commit 4f6042f

Browse files
committed
ENGCOM-6317: Bump coding standard version
1 parent 29335aa commit 4f6042f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

dev/tests/static/phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<testsuite name="PHP Coding Standard Verification">
2525
<file>testsuite/Magento/Test/Php/LiveCodeTest.php</file>
2626
</testsuite>
27+
<testsuite name="GraphQL Static Code Analysis">
28+
<file>testsuite/Magento/Test/GraphQl/LiveCodeTest.php</file>
29+
</testsuite>
2730
<testsuite name="Code Integrity Tests">
2831
<directory>testsuite/Magento/Test/Integrity</directory>
2932
</testsuite>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Test\GraphQl;
9+
10+
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer;
11+
use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper;
12+
use Magento\Test\Php\LiveCodeTest as PHPCodeTest;
13+
use PHPUnit\Framework\TestCase;
14+
15+
/**
16+
* Set of tests for static code style
17+
*/
18+
class LiveCodeTest extends TestCase
19+
{
20+
/**
21+
* @var string
22+
*/
23+
private static $reportDir = '';
24+
25+
/**
26+
* Setup basics for all tests
27+
*/
28+
public static function setUpBeforeClass(): void
29+
{
30+
self::$reportDir = BP . '/dev/tests/static/report';
31+
if (!is_dir(self::$reportDir)) {
32+
mkdir(self::$reportDir, 0770);
33+
}
34+
}
35+
36+
/**
37+
* Test GraphQL schema files code style using phpcs
38+
*/
39+
public function testCodeStyle(): void
40+
{
41+
$reportFile = self::$reportDir . '/graphql_phpcs_report.txt';
42+
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
43+
$result = $codeSniffer->run(PHPCodeTest::getWhitelist(['graphqls']));
44+
$report = file_exists($reportFile) ? file_get_contents($reportFile) : '';
45+
$this->assertEquals(
46+
0,
47+
$result,
48+
"PHP Code Sniffer detected {$result} violation(s): " . PHP_EOL . $report
49+
);
50+
}
51+
}

0 commit comments

Comments
 (0)