File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
testsuite/Magento/Test/GraphQl Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 24
24
<testsuite name =" PHP Coding Standard Verification" >
25
25
<file >testsuite/Magento/Test/Php/LiveCodeTest.php</file >
26
26
</testsuite >
27
+ <testsuite name =" GraphQL Static Code Analysis" >
28
+ <file >testsuite/Magento/Test/GraphQl/LiveCodeTest.php</file >
29
+ </testsuite >
27
30
<testsuite name =" Code Integrity Tests" >
28
31
<directory >testsuite/Magento/Test/Integrity</directory >
29
32
</testsuite >
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments