Skip to content

Conversation

@actionm
Copy link

@actionm actionm commented Sep 4, 2019

The problem is coming from php-graphql-client FieldTrait.php constructSelectionSet() where we use a \n character to build the query.

I fixed it and other Windows specified problems in the tests for php-graphql-oqm.

  1. The problem is with the PHP_EOL constant depending on a platform

A new line on Windows is \r\n , linux \n

  1. testUnwritableDirInConstructor(), testUnwritableDir() - we need to skip these tests, because windows don't have chmod().

  2. DIRECTORY_SEPARATOR - depending on a platform/or \

The test results on win7 x64 PHP 7.3.9 MINGW64

git clone https://github.com/mghoneimy/php-graphql-oqm/

composer install 
vendor/phpunit/phpunit/phpunit tests/ --whitelist src/ --coverage-clover build/coverage/xml

PHPUnit 8.3.4 by Sebastian Bergmann and contributors.

Error:         No code coverage driver is available

PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
.E.E.FSPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
FFFFFFPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
..PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
......FS.FS.SPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
F.......PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
FSSPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
FFFFFFFPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
...PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
FFFSFSPHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
F.FFPHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
F...FF 65 / 89 ( 73%)
FFFFFFFF.PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31

Warning: mkdir(): File exists in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 31
.F.F.SFSSS...SS                                          89 / 89 (100%)PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated/unwritable-constructor): Permission denied in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58
PHP Warning:  rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58

Warning: rmdir(X:\php-graphql-oqm\tests/files_generated): Directory not empty in X:\php-graphql-oqm\tests\CodeFileTestCase.php on line 58


Time: 380 ms, Memory: 8.00 MB

There were 2 errors:

1) GraphQL\Tests\AbstractCodeFileTest::testUnwritableDirInConstructor
mkdir(): File exists

X:\php-graphql-oqm\tests\AbstractCodeFileTest.php:70

2) GraphQL\Tests\AbstractCodeFileTest::testUnwritableDir
mkdir(): File exists

X:\php-graphql-oqm\tests\AbstractCodeFileTest.php:102

--

There were 39 failures:

1) GraphQL\Tests\AbstractCodeFileTest::testFileWritingWorks
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<?php\r\n
+'<?php\n
 '

X:\php-graphql-oqm\tests\AbstractCodeFileTest.php:127

2) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddScalarArgument
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithScalarArgArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $scalarProperty;\r\n
+    protected $scalarProperty;\n
 \r\n
     public function setScalarProperty($scalarProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:43

3) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddMultipleScalarArguments
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleScalarArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $scalarProperty;\r\n
-    protected $another_scalar_property;\r\n
+    protected $scalarProperty;\n
+    protected $another_scalar_property;\n
 \r\n
     public function setScalarProperty($scalarProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:66

4) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddListArgument
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithListArgArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $listProperty;\r\n
+    protected $listProperty;\n
 \r\n
     public function setListProperty(array $listProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:88

5) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddMultipleListArguments
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleListArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $listProperty;\r\n
-    protected $another_list_property;\r\n
+    protected $listProperty;\n
+    protected $another_list_property;\n
 \r\n
     public function setListProperty(array $listProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:111

6) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddInputObjectArgument
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithInputObjectArgArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $objectProperty;\r\n
+    protected $objectProperty;\n
 \r\n
     public function setObjectProperty(SomeInputObject $someInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:133

7) GraphQL\Tests\ArgumentsObjectClassBuilderTest::testAddMultipleInputObjectArguments
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleInputObjectArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $objectProperty;\r\n
-    protected $another_object_property;\r\n
+    protected $objectProperty;\n
+    protected $another_object_property;\n
 \r\n
     public function setObjectProperty(SomeInputObject $someInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\ArgumentsObjectClassBuilderTest.php:156

8) GraphQL\Tests\ClassFileTest::testUseTraits
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 \r\n
 class ClassWithTrait\r\n
 {\r\n
-    use TraitOne;\r\n
+    use TraitOne;\n
 }'

X:\php-graphql-oqm\tests\ClassFileTest.php:138

9) GraphQL\Tests\ClassFileTest::testClassWithConstants
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 \r\n
 class ClassWithConstant\r\n
 {\r\n
-    const CONST_ONE = "ONE";\r\n
+    const CONST_ONE = "ONE";\n
 }'

X:\php-graphql-oqm\tests\ClassFileTest.php:197

10) GraphQL\Tests\ClientTest::testConstructClient
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'{"query":"query_string"}'
+'{"query":"query_string","variables":{}}'

X:\php-graphql-oqm\tests\ClientTest.php:66

11) GraphQL\Tests\EnumObjectBuilderTest::testBuildEmptyEnum
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\EnumObject;\r\n
+use GraphQL\SchemaObject\EnumObject;\n
 \r\n
 class EmptyEnumObject extends EnumObject\r\n
 {}'

X:\php-graphql-oqm\tests\EnumObjectBuilderTest.php:39

12) GraphQL\Tests\InputObjectClassBuilderTest::testAddScalarValue
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithScalarValueInputObject extends InputObject\r\n
 {\r\n
-    protected $valOne;\r\n
+    protected $valOne;\n
 \r\n
     public function setValOne($valOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:40

13) GraphQL\Tests\InputObjectClassBuilderTest::testAddMultipleScalarValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleScalarValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $valOne;\r\n
-    protected $val_two;\r\n
+    protected $valOne;\n
+    protected $val_two;\n
 \r\n
     public function setValOne($valOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:63

14) GraphQL\Tests\InputObjectClassBuilderTest::testAddListValue
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithListValueInputObject extends InputObject\r\n
 {\r\n
-    protected $listOne;\r\n
+    protected $listOne;\n
 \r\n
     public function setListOne(array $listOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:85

15) GraphQL\Tests\InputObjectClassBuilderTest::testAddMultipleListValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleListValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $listOne;\r\n
-    protected $list_two;\r\n
+    protected $listOne;\n
+    protected $list_two;\n
 \r\n
     public function setListOne(array $listOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:108

16) GraphQL\Tests\InputObjectClassBuilderTest::testAddInputObjectValue
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithInputObjectValueInputObject extends InputObject\r\n
 {\r\n
-    protected $inputObject;\r\n
+    protected $inputObject;\n
 \r\n
     public function setInputObject(WithListValueInputObject $withListValueInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:130

17) GraphQL\Tests\InputObjectClassBuilderTest::testAddMultipleInputObjectValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleInputObjectValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $inputObject;\r\n
-    protected $inputObjectTwo;\r\n
+    protected $inputObject;\n
+    protected $inputObjectTwo;\n
 \r\n
     public function setInputObject(WithListValueInputObject $withListValueInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:153

18) GraphQL\Tests\InputObjectClassBuilderTest::testInputObjectIntegration
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class _TestFilterInputObject extends InputObject\r\n
 {\r\n
-    protected $first_name;\r\n
-    protected $lastName;\r\n
-    protected $ids;\r\n
-    protected $testFilter;\r\n
+    protected $first_name;\n
+    protected $lastName;\n
+    protected $ids;\n
+    protected $testFilter;\n
 \r\n
     public function setFirstName($firstName)\r\n
     {\r\n

X:\php-graphql-oqm\tests\InputObjectClassBuilderTest.php:174

19) GraphQL\Tests\QueryObjectClassBuilderTest::testBuildEmptyQueryObject
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class EmptyQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "Empty";\r\n
+    const OBJECT_NAME = "Empty";\n
 }'

X:\php-graphql-oqm\tests\QueryObjectClassBuilderTest.php:33

20) GraphQL\Tests\QueryObjectClassBuilderTest::testBuildRootQueryObject
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class RootQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "query";\r\n
+    const OBJECT_NAME = "query";\n
 }'

X:\php-graphql-oqm\tests\QueryObjectClassBuilderTest.php:50

21) GraphQL\Tests\QueryObjectClassBuilderTest::testAddSimpleSelector
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class SimpleSelectorQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "SimpleSelector";\r\n
+    const OBJECT_NAME = "SimpleSelector";\n
 \r\n
     public function selectName()\r\n
     {\r\n

X:\php-graphql-oqm\tests\QueryObjectClassBuilderTest.php:68

22) GraphQL\Tests\QueryObjectClassBuilderTest::testAddObjectSelector
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class ObjectSelectorQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "ObjectSelector";\r\n
+    const OBJECT_NAME = "ObjectSelector";\n
 \r\n
     public function selectOthers(RootOthersArgumentsObject $argsObject = null)\r\n
     {\r\n

X:\php-graphql-oqm\tests\QueryObjectClassBuilderTest.php:107

23) GraphQL\Tests\QueryObjectTest::testConstruct
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'query {\r\n
-Simple {\r\n
-scalar\r\n
-}\r\n
+'query {\n
+Simple {\n
+scalar\n
+}\n
 }'

X:\php-graphql-oqm\tests\QueryObjectTest.php:45

24) GraphQL\Tests\QueryObjectTest::testSelectFields
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'query {\r\n
-simples {\r\n
-scalar\r\n
-}\r\n
+'query {\n
+simples {\n
+scalar\n
+}\n
 }'

X:\php-graphql-oqm\tests\QueryObjectTest.php:81

25) GraphQL\Tests\QueryObjectTest::testSelectSubFieldsWithArguments
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'query {\r\n
-simples {\r\n
-siblings(first: 5 ids: [1, 2]) {\r\n
-scalar\r\n
-}\r\n
-}\r\n
+'query {\n
+simples {\n
+siblings(first: 5 ids: [1, 2]) {\n
+scalar\n
+}\n
+}\n
 }'

X:\php-graphql-oqm\tests\QueryObjectTest.php:125

26) GraphQL\Tests\SchemaClassGeneratorTest::testSetWriteDirectory
Failed asserting that 'X:\php-graphql-oqm/schema_object' ends with "/php-graphql-oqm/schema_object".

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:47

27) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateEnumObject
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\EnumObject;\r\n
+use GraphQL\SchemaObject\EnumObject;\n
 \r\n
 class WithMultipleConstantsEnumObject extends EnumObject\r\n
 {\r\n
-    const SOME_VALUE = "some_value";\r\n
-    const ANOTHER_VALUE = "another_value";\r\n
-    const ONEMOREVALUE = "oneMoreValue";\r\n
+    const SOME_VALUE = "some_value";\n
+    const ANOTHER_VALUE = "another_value";\n
+    const ONEMOREVALUE = "oneMoreValue";\n
 }'

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:172

28) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateInputObjectWithScalarValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleScalarValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $valOne;\r\n
-    protected $val_two;\r\n
+    protected $valOne;\n
+    protected $val_two;\n
 \r\n
     public function setValOne($valOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:220

29) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateInputObjectWithListValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleListValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $listOne;\r\n
-    protected $list_two;\r\n
+    protected $listOne;\n
+    protected $list_two;\n
 \r\n
     public function setListOne(array $listOne)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:283

30) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateInputObjectWithNestedObjectValues
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\InputObject;\r\n
+use GraphQL\SchemaObject\InputObject;\n
 \r\n
 class WithMultipleInputObjectValuesInputObject extends InputObject\r\n
 {\r\n
-    protected $inputObject;\r\n
-    protected $inputObjectTwo;\r\n
+    protected $inputObject;\n
+    protected $inputObjectTwo;\n
 \r\n
     public function setInputObject(WithListValueInputObject $withListValueInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:349

31) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateArgumentsObjectWithScalarArgs
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleScalarArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $scalarProperty;\r\n
-    protected $another_scalar_property;\r\n
+    protected $scalarProperty;\n
+    protected $another_scalar_property;\n
 \r\n
     public function setScalarProperty($scalarProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:388

32) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateArgumentsObjectWithListArgs
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleListArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $listProperty;\r\n
-    protected $another_list_property;\r\n
+    protected $listProperty;\n
+    protected $another_list_property;\n
 \r\n
     public function setListProperty(array $listProperty)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:457

33) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateArgumentsObjectWithInputObjectArgs
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\ArgumentsObject;\r\n
+use GraphQL\SchemaObject\ArgumentsObject;\n
 \r\n
 class WithMultipleInputObjectArgsArgumentsObject extends ArgumentsObject\r\n
 {\r\n
-    protected $objectProperty;\r\n
-    protected $another_object_property;\r\n
+    protected $objectProperty;\n
+    protected $another_object_property;\n
 \r\n
     public function setObjectProperty(SomeInputObject $someInputObject)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:516

34) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateQueryObjectWithScalarFields
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class MultipleSimpleSelectorsQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "MultipleSimpleSelectors";\r\n
+    const OBJECT_NAME = "MultipleSimpleSelectors";\n
 \r\n
     public function selectFirstName()\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:565

35) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateQueryObjectWithObjectFields
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class MultipleObjectSelectorsQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "MultipleObjectSelectors";\r\n
+    const OBJECT_NAME = "MultipleObjectSelectors";\n
 \r\n
     public function selectRightObjects(MultipleObjectSelectorsRightObjectsArgumentsObject $argsObject = null)\r\n
     {\r\n

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:642

36) GraphQL\Tests\SchemaClassGeneratorTest::testGenerateRootObject
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Tests\SchemaObject;\r\n
+namespace GraphQL\Tests\SchemaObject;\n
 \r\n
-use GraphQL\SchemaObject\QueryObject;\r\n
+use GraphQL\SchemaObject\QueryObject;\n
 \r\n
 class RootQueryObject extends QueryObject\r\n
 {\r\n
-    const OBJECT_NAME = "query";\r\n
+    const OBJECT_NAME = "query";\n
 }'

X:\php-graphql-oqm\tests\SchemaClassGeneratorTest.php:668

37) GraphQL\Tests\TraitFileTest::testTraitWithNamespace
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-namespace GraphQL\Test;\r\n
+namespace GraphQL\Test;\n
 \r\n
 trait TraitWithNamespace\r\n
 {}'

X:\php-graphql-oqm\tests\TraitFileTest.php:49

38) GraphQL\Tests\TraitFileTest::testTraitWithImports
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<?php\r\n
 \r\n
-use GraphQL\Query;\r\n
-use GraphQL\Client;\r\n
+use GraphQL\Query;\n
+use GraphQL\Client;\n
 \r\n
 trait TraitWithImports\r\n
 {}'

X:\php-graphql-oqm\tests\TraitFileTest.php:86

39) GraphQL\Tests\TraitFileTest::testTraitWithProperties
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 \r\n
 trait TraitWithProperties\r\n
 {\r\n
-    protected $property1;\r\n
-    protected $propertyTwo;\r\n
-    protected $property_three;\r\n
+    protected $property1;\n
+    protected $propertyTwo;\n
+    protected $property_three;\n
 }'

X:\php-graphql-oqm\tests\TraitFileTest.php:146

ERRORS!
Tests: 89, Assertions: 181, Errors: 2, Failures: 39, Skipped: 14.

Tests with this PR on win7 x64 PHP 7.3.9 MINGW64

vendor/phpunit/phpunit/phpunit tests/ --whitelist src/ --coverage-clover build/coverage/xml
PHPUnit 7.5.15 by Sebastian Bergmann and contributors.

Error:         No code coverage driver is available

.S.S............................................................. 65 / 89 ( 73%)
........................                                          89 / 89 (100%)

Time: 709 ms, Memory: 6.00 MB

OK, but incomplete, skipped, or risky tests!
Tests: 89, Assertions: 106, Skipped: 2.

@actionm actionm marked this pull request as ready for review September 4, 2019 19:22
@actionm actionm requested a review from mghoneimy September 8, 2019 13:31
Copy link
Owner

@mghoneimy mghoneimy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complete my review. Please respond to the comments so that we can merge the PR 😄

* @param $filename
* @return string
*/
private function readFileContent($filename) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think renaming this to readFileContentWithoutWhitespaces makes more sense

return false;
}

if (strcmp($expected, $generated) !== 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should assert that one string is not empty then that the 2 strings are equal instead of returning values. The method should call an assertion internally rather than returning a value that we would call an assertion against later.


$expected = $this->readFileContent($expectedFile);

if (empty($expected)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove this IMO


$generated = $this->readFileContent($actualFile);

if (empty($generated)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

$this->codeFile->writeFile();

$this->assertFileEquals(static::getExpectedFilesDir() . "/$this->fileName.php", $this->codeFile->getWritePath());
$this->assertTrue(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we should just call the assertion method. Not call an assertion inside an assertion.

$this->assertFileEquals(
static::getExpectedFilesDir() . "/$objectName.php",
static::getGeneratedFilesDir() . "/$objectName.php"
$this->assertTrue(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same in all instances that have the same issue, we should remove the assertTrue

$this->queryObject = new SimpleQueryObject('simples');
}

private function replaceWhitespace(string $string) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if you replace the method with an assertion, something like assertStringsEqualWithoutWhitespaces and apply that assertion to all assertions in this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants