From ad821e7d9ca6475482b324b45a72095e14a1d62e Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 10 Jan 2020 15:15:15 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02651=20rollback=20gitignore=20for=20lib?= =?UTF-8?q?=20tests=20dirs=20Too=20dangerous=20!=20We'll=20work=20properly?= =?UTF-8?q?=20on=20this=20but=20for=202.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 - lib/composer/autoload_classmap.php | 12 + lib/composer/autoload_static.php | 12 + .../test/PhpParser/AutoloaderTest.php | 15 + .../test/PhpParser/Builder/ClassTest.php | 161 ++ .../test/PhpParser/Builder/FunctionTest.php | 106 + .../test/PhpParser/Builder/InterfaceTest.php | 105 + .../test/PhpParser/Builder/MethodTest.php | 163 ++ .../test/PhpParser/Builder/NamespaceTest.php | 46 + .../test/PhpParser/Builder/ParamTest.php | 171 ++ .../test/PhpParser/Builder/PropertyTest.php | 147 + .../test/PhpParser/Builder/TraitTest.php | 48 + .../test/PhpParser/Builder/UseTest.php | 35 + .../test/PhpParser/BuilderFactoryTest.php | 108 + .../test/PhpParser/CodeParsingTest.php | 70 + .../test/PhpParser/CodeTestAbstract.php | 61 + .../php-parser/test/PhpParser/CommentTest.php | 73 + .../PhpParser/ErrorHandler/CollectingTest.php | 22 + .../PhpParser/ErrorHandler/ThrowingTest.php | 16 + .../php-parser/test/PhpParser/ErrorTest.php | 106 + .../test/PhpParser/Lexer/EmulativeTest.php | 133 + .../php-parser/test/PhpParser/LexerTest.php | 265 ++ .../test/PhpParser/Node/NameTest.php | 134 + .../PhpParser/Node/Scalar/MagicConstTest.php | 25 + .../test/PhpParser/Node/Scalar/StringTest.php | 61 + .../PhpParser/Node/Stmt/ClassConstTest.php | 35 + .../PhpParser/Node/Stmt/ClassMethodTest.php | 63 + .../test/PhpParser/Node/Stmt/ClassTest.php | 66 + .../PhpParser/Node/Stmt/InterfaceTest.php | 26 + .../test/PhpParser/Node/Stmt/PropertyTest.php | 44 + .../test/PhpParser/NodeAbstractTest.php | 274 ++ .../test/PhpParser/NodeDumperTest.php | 105 + .../test/PhpParser/NodeTraverserTest.php | 267 ++ .../NodeVisitor/NameResolverTest.php | 468 +++ .../test/PhpParser/Parser/MultipleTest.php | 94 + .../test/PhpParser/Parser/Php5Test.php | 14 + .../test/PhpParser/Parser/Php7Test.php | 14 + .../test/PhpParser/ParserFactoryTest.php | 34 + .../php-parser/test/PhpParser/ParserTest.php | 184 ++ .../test/PhpParser/PrettyPrinterTest.php | 207 ++ .../test/PhpParser/Serializer/XMLTest.php | 172 ++ .../test/PhpParser/Unserializer/XMLTest.php | 150 + lib/nikic/php-parser/test/bootstrap.php | 20 + .../test/code/parser/blockComments.test | 31 + .../php-parser/test/code/parser/comments.test | 100 + .../code/parser/errorHandling/eofError.test | 32 + .../parser/errorHandling/lexerErrors.test | 124 + .../code/parser/errorHandling/recovery.test | 866 ++++++ .../test/code/parser/expr/arrayDef.test | 142 + .../code/parser/expr/arrayDestructuring.test | 144 + .../test/code/parser/expr/assign.test | 301 ++ .../test/code/parser/expr/assignNewByRef.test | 39 + .../test/code/parser/expr/cast.test | 72 + .../test/code/parser/expr/clone.test | 13 + .../test/code/parser/expr/closure.test | 142 + .../test/code/parser/expr/comparison.test | 107 + .../test/code/parser/expr/constant_expr.test | 621 ++++ .../test/code/parser/expr/errorSuppress.test | 12 + .../test/code/parser/expr/exit.test | 34 + .../code/parser/expr/fetchAndCall/args.test | 99 + .../parser/expr/fetchAndCall/constFetch.test | 33 + .../expr/fetchAndCall/constantDeref.test | 231 ++ .../parser/expr/fetchAndCall/funcCall.test | 132 + .../parser/expr/fetchAndCall/newDeref.test | 70 + .../expr/fetchAndCall/objectAccess.test | 145 + .../expr/fetchAndCall/simpleArrayAccess.test | 62 + .../parser/expr/fetchAndCall/staticCall.test | 173 ++ .../fetchAndCall/staticPropertyFetch.test | 91 + .../test/code/parser/expr/includeAndEval.test | 40 + .../test/code/parser/expr/issetAndEmpty.test | 75 + .../test/code/parser/expr/listWithKeys.test | 75 + .../test/code/parser/expr/logic.test | 159 + .../test/code/parser/expr/math.test | 256 ++ .../php-parser/test/code/parser/expr/new.test | 146 + .../code/parser/expr/newWithoutClass.test | 23 + .../test/code/parser/expr/print.test | 12 + .../test/code/parser/expr/shellExec.test | 46 + .../code/parser/expr/ternaryAndCoalesce.test | 149 + .../expr/uvs/globalNonSimpleVarError.test | 25 + .../code/parser/expr/uvs/indirectCall.test | 481 ++++ .../test/code/parser/expr/uvs/isset.test | 74 + .../test/code/parser/expr/uvs/misc.test | 109 + .../test/code/parser/expr/uvs/new.test | 95 + .../code/parser/expr/uvs/staticProperty.test | 93 + .../test/code/parser/expr/variable.test | 55 + .../code/parser/scalar/constantString.test | 60 + .../test/code/parser/scalar/docString.test | 90 + .../code/parser/scalar/docStringNewlines.test | 61 + .../parser/scalar/encapsedNegVarOffset.test | 72 + .../code/parser/scalar/encapsedString.test | 294 ++ .../test/code/parser/scalar/float.test | 74 + .../test/code/parser/scalar/int.test | 43 + .../test/code/parser/scalar/invalidOctal.test | 22 + .../test/code/parser/scalar/magicConst.test | 31 + .../code/parser/scalar/unicodeEscape.test | 20 + .../test/code/parser/semiReserved.test | 382 +++ .../code/parser/stmt/blocklessStatement.test | 112 + .../test/code/parser/stmt/class/abstract.test | 39 + .../code/parser/stmt/class/anonymous.test | 195 ++ .../code/parser/stmt/class/conditional.test | 33 + .../stmt/class/constModifierErrors.test | 121 + .../parser/stmt/class/constModifiers.test | 67 + .../test/code/parser/stmt/class/final.test | 17 + .../parser/stmt/class/implicitPublic.test | 92 + .../code/parser/stmt/class/interface.test | 36 + .../test/code/parser/stmt/class/modifier.test | 215 ++ .../test/code/parser/stmt/class/name.test | 240 ++ .../code/parser/stmt/class/php4Style.test | 50 + .../test/code/parser/stmt/class/simple.test | 156 + .../code/parser/stmt/class/staticMethod.test | 151 + .../test/code/parser/stmt/class/trait.test | 160 ++ .../test/code/parser/stmt/const.test | 40 + .../test/code/parser/stmt/controlFlow.test | 55 + .../test/code/parser/stmt/declare.test | 60 + .../test/code/parser/stmt/echo.test | 32 + .../function/builtinTypeDeclarations.test | 59 + .../test/code/parser/stmt/function/byRef.test | 41 + .../parser/stmt/function/conditional.test | 33 + .../parser/stmt/function/defaultValues.test | 148 + .../parser/stmt/function/nullableTypes.test | 47 + .../parser/stmt/function/returnTypes.test | 52 + .../parser/stmt/function/specialVars.test | 51 + .../stmt/function/typeDeclarations.test | 49 + .../code/parser/stmt/function/variadic.test | 110 + .../stmt/function/variadicDefaultValue.test | 27 + .../code/parser/stmt/generator/basic.test | 280 ++ .../stmt/generator/yieldPrecedence.test | 230 ++ .../stmt/generator/yieldUnaryPrecedence.test | 48 + .../test/code/parser/stmt/haltCompiler.test | 55 + .../stmt/haltCompilerInvalidSyntax.test | 6 + .../code/parser/stmt/haltCompilerOffset.test | 34 + .../stmt/haltCompilerOutermostScope.test | 8 + .../test/code/parser/stmt/hashbang.test | 26 + .../php-parser/test/code/parser/stmt/if.test | 103 + .../test/code/parser/stmt/inlineHTML.test | 27 + .../test/code/parser/stmt/loop/do.test | 17 + .../test/code/parser/stmt/loop/for.test | 110 + .../test/code/parser/stmt/loop/foreach.test | 164 ++ .../test/code/parser/stmt/loop/while.test | 25 + .../test/code/parser/stmt/multiCatch.test | 65 + .../code/parser/stmt/namespace/alias.test | 168 ++ .../code/parser/stmt/namespace/braced.test | 42 + .../stmt/namespace/commentAfterNamespace.test | 22 + .../code/parser/stmt/namespace/groupUse.test | 188 ++ .../parser/stmt/namespace/groupUseErrors.test | 107 + .../stmt/namespace/groupUsePositions.test | 28 + .../stmt/namespace/groupUseTrailingComma.test | 47 + .../parser/stmt/namespace/invalidName.test | 83 + .../test/code/parser/stmt/namespace/mix.test | 103 + .../test/code/parser/stmt/namespace/name.test | 42 + .../code/parser/stmt/namespace/nested.test | 30 + .../code/parser/stmt/namespace/notBraced.test | 45 + .../stmt/namespace/nsAfterHashbang.test | 22 + .../parser/stmt/namespace/outsideStmt.test | 58 + .../stmt/namespace/outsideStmtInvalid.test | 105 + .../test/code/parser/stmt/switch.test | 81 + .../test/code/parser/stmt/tryCatch.test | 130 + .../code/parser/stmt/tryWithoutCatch.test | 27 + .../test/code/parser/stmt/unset.test | 26 + .../test/code/prettyPrinter/comments.test | 67 + .../prettyPrinter/commentsInCommaList.test | 53 + .../prettyPrinter/expr/anonymousClass.test | 27 + .../expr/arrayDestructuring.test | 14 + .../test/code/prettyPrinter/expr/call.test | 13 + .../test/code/prettyPrinter/expr/closure.test | 18 + .../prettyPrinter/expr/constant_deref.test | 13 + .../code/prettyPrinter/expr/docStrings.test | 86 + .../test/code/prettyPrinter/expr/include.test | 7 + .../code/prettyPrinter/expr/intrinsics.test | 29 + .../test/code/prettyPrinter/expr/list.test | 19 + .../code/prettyPrinter/expr/literals.test | 154 + .../test/code/prettyPrinter/expr/numbers.test | 35 + .../code/prettyPrinter/expr/operators.test | 144 + .../code/prettyPrinter/expr/parentheses.test | 86 + .../prettyPrinter/expr/shortArraySyntax.test | 11 + .../prettyPrinter/expr/stringEscaping.test | 23 + .../test/code/prettyPrinter/expr/uvs.test | 23 + .../code/prettyPrinter/expr/variables.test | 73 + .../test/code/prettyPrinter/expr/yield.test | 46 + .../inlineHTMLandPHPtest.file-test | 58 + .../prettyPrinter/onlyInlineHTML.file-test | 19 + .../test/code/prettyPrinter/onlyPHP.file-test | 16 + .../test/code/prettyPrinter/stmt/alias.test | 20 + .../prettyPrinter/stmt/break_continue.test | 13 + .../test/code/prettyPrinter/stmt/class.test | 53 + .../code/prettyPrinter/stmt/class_const.test | 20 + .../test/code/prettyPrinter/stmt/const.test | 11 + .../test/code/prettyPrinter/stmt/declare.test | 17 + .../code/prettyPrinter/stmt/do_while.test | 10 + .../test/code/prettyPrinter/stmt/for.test | 28 + .../test/code/prettyPrinter/stmt/foreach.test | 28 + .../stmt/function_signatures.test | 43 + .../stmt/global_static_variables.test | 11 + .../test/code/prettyPrinter/stmt/goto.test | 9 + .../code/prettyPrinter/stmt/groupUse.test | 16 + .../prettyPrinter/stmt/haltCompiler.file-test | 27 + .../test/code/prettyPrinter/stmt/if.test | 16 + .../code/prettyPrinter/stmt/multiCatch.test | 19 + .../code/prettyPrinter/stmt/namespaces.test | 50 + .../prettyPrinter/stmt/nullable_types.test | 11 + .../test/code/prettyPrinter/stmt/switch.test | 37 + .../test/code/prettyPrinter/stmt/throw.test | 7 + .../code/prettyPrinter/stmt/traitUse.test | 25 + .../code/prettyPrinter/stmt/tryCatch.test | 24 + .../test/code/prettyPrinter/stmt/while.test | 10 + .../tests/PEAR/ExceptionTest.php | 78 + .../log/Psr/Log/Test/LoggerInterfaceTest.php | 146 + lib/psr/log/Psr/Log/Test/TestLogger.php | 147 + .../Adapter/AbstractRedisAdapterTest.php | 46 + .../cache/Tests/Adapter/AdapterTestCase.php | 175 ++ .../cache/Tests/Adapter/ApcuAdapterTest.php | 124 + .../cache/Tests/Adapter/ArrayAdapterTest.php | 56 + .../cache/Tests/Adapter/ChainAdapterTest.php | 115 + .../Tests/Adapter/DoctrineAdapterTest.php | 32 + .../Tests/Adapter/FilesystemAdapterTest.php | 61 + .../Tests/Adapter/MaxIdLengthAdapterTest.php | 87 + .../Tests/Adapter/MemcachedAdapterTest.php | 198 ++ .../Adapter/NamespacedProxyAdapterTest.php | 26 + .../cache/Tests/Adapter/NullAdapterTest.php | 128 + .../cache/Tests/Adapter/PdoAdapterTest.php | 73 + .../Tests/Adapter/PdoDbalAdapterTest.php | 48 + .../Tests/Adapter/PhpArrayAdapterTest.php | 133 + .../PhpArrayAdapterWithFallbackTest.php | 49 + .../Tests/Adapter/PhpFilesAdapterTest.php | 47 + .../cache/Tests/Adapter/PredisAdapterTest.php | 53 + .../Adapter/PredisClusterAdapterTest.php | 26 + .../Adapter/PredisRedisClusterAdapterTest.php | 28 + .../cache/Tests/Adapter/ProxyAdapterTest.php | 69 + .../cache/Tests/Adapter/RedisAdapterTest.php | 92 + .../Tests/Adapter/RedisArrayAdapterTest.php | 24 + .../Tests/Adapter/RedisClusterAdapterTest.php | 27 + .../Tests/Adapter/SimpleCacheAdapterTest.php | 41 + .../Tests/Adapter/TagAwareAdapterTest.php | 318 ++ ...TagAwareAndProxyAdapterIntegrationTest.php | 38 + .../Tests/Adapter/TraceableAdapterTest.php | 191 ++ .../Adapter/TraceableTagAwareAdapterTest.php | 37 + lib/symfony/cache/Tests/CacheItemTest.php | 77 + .../cache/Tests/DoctrineProviderTest.php | 45 + .../cache/Tests/Fixtures/ArrayCache.php | 52 + .../cache/Tests/Fixtures/ExternalAdapter.php | 76 + .../Tests/Simple/AbstractRedisCacheTest.php | 46 + .../cache/Tests/Simple/ApcuCacheTest.php | 35 + .../cache/Tests/Simple/ArrayCacheTest.php | 25 + .../cache/Tests/Simple/CacheTestCase.php | 150 + .../cache/Tests/Simple/ChainCacheTest.php | 113 + .../cache/Tests/Simple/DoctrineCacheTest.php | 31 + .../Tests/Simple/FilesystemCacheTest.php | 34 + .../cache/Tests/Simple/MemcachedCacheTest.php | 172 ++ .../Simple/MemcachedCacheTextModeTest.php | 25 + .../cache/Tests/Simple/NullCacheTest.php | 96 + .../cache/Tests/Simple/PdoCacheTest.php | 47 + .../cache/Tests/Simple/PdoDbalCacheTest.php | 48 + .../cache/Tests/Simple/PhpArrayCacheTest.php | 143 + .../Simple/PhpArrayCacheWithFallbackTest.php | 55 + .../cache/Tests/Simple/PhpFilesCacheTest.php | 42 + .../cache/Tests/Simple/Psr6CacheTest.php | 30 + .../Tests/Simple/RedisArrayCacheTest.php | 24 + .../cache/Tests/Simple/RedisCacheTest.php | 82 + .../Tests/Simple/RedisClusterCacheTest.php | 27 + .../cache/Tests/Simple/TraceableCacheTest.php | 171 ++ .../cache/Tests/Traits/PdoPruneableTrait.php | 34 + .../class-loader/Tests/ApcClassLoaderTest.php | 200 ++ .../Tests/ClassCollectionLoaderTest.php | 317 ++ .../class-loader/Tests/ClassLoaderTest.php | 238 ++ .../Tests/ClassMapGeneratorTest.php | 151 + .../Tests/Fixtures/Apc/Namespaced/Bar.php | 17 + .../Tests/Fixtures/Apc/Namespaced/Baz.php | 17 + .../Tests/Fixtures/Apc/Namespaced/Foo.php | 17 + .../Tests/Fixtures/Apc/Namespaced/FooBar.php | 17 + .../Tests/Fixtures/Apc/Pearlike/Bar.php | 6 + .../Tests/Fixtures/Apc/Pearlike/Baz.php | 6 + .../Tests/Fixtures/Apc/Pearlike/Foo.php | 6 + .../alpha/Apc/ApcPrefixCollision/A/Bar.php | 6 + .../alpha/Apc/ApcPrefixCollision/A/Foo.php | 6 + .../alpha/Apc/NamespaceCollision/A/Bar.php | 17 + .../alpha/Apc/NamespaceCollision/A/Foo.php | 17 + .../beta/Apc/ApcPrefixCollision/A/B/Bar.php | 6 + .../beta/Apc/ApcPrefixCollision/A/B/Foo.php | 6 + .../beta/Apc/NamespaceCollision/A/B/Bar.php | 17 + .../beta/Apc/NamespaceCollision/A/B/Foo.php | 17 + .../Apc/fallback/Apc/Pearlike/FooBar.php | 6 + .../Apc/fallback/Namespaced/FooBar.php | 17 + .../Tests/Fixtures/ClassesWithParents/A.php | 7 + .../Fixtures/ClassesWithParents/ATrait.php | 7 + .../Tests/Fixtures/ClassesWithParents/B.php | 7 + .../Fixtures/ClassesWithParents/BTrait.php | 8 + .../ClassesWithParents/CInterface.php | 7 + .../Fixtures/ClassesWithParents/CTrait.php | 7 + .../Tests/Fixtures/ClassesWithParents/D.php | 8 + .../Tests/Fixtures/ClassesWithParents/E.php | 8 + .../Tests/Fixtures/ClassesWithParents/F.php | 8 + .../Tests/Fixtures/ClassesWithParents/G.php | 8 + .../ClassesWithParents/GInterface.php | 7 + .../Tests/Fixtures/DeclaredClass.php | 7 + .../Tests/Fixtures/DeclaredInterface.php | 7 + .../Tests/Fixtures/Namespaced/Bar.php | 17 + .../Tests/Fixtures/Namespaced/Baz.php | 17 + .../Tests/Fixtures/Namespaced/Foo.php | 17 + .../Fixtures/Namespaced/WithComments.php | 37 + .../Fixtures/Namespaced/WithDirMagic.php | 15 + .../Fixtures/Namespaced/WithFileMagic.php | 15 + .../Fixtures/Namespaced/WithHaltCompiler.php | 18 + .../Fixtures/Namespaced/WithStrictTypes.php | 13 + .../Tests/Fixtures/Namespaced2/Bar.php | 8 + .../Tests/Fixtures/Namespaced2/Baz.php | 8 + .../Tests/Fixtures/Namespaced2/Foo.php | 8 + .../Tests/Fixtures/Pearlike/Bar.php | 6 + .../Tests/Fixtures/Pearlike/Baz.php | 6 + .../Tests/Fixtures/Pearlike/Foo.php | 6 + .../Tests/Fixtures/Pearlike/WithComments.php | 16 + .../Tests/Fixtures/Pearlike2/Bar.php | 6 + .../Tests/Fixtures/Pearlike2/Baz.php | 6 + .../Tests/Fixtures/Pearlike2/Foo.php | 6 + .../Tests/Fixtures/WarmedClass.php | 7 + .../Tests/Fixtures/WarmedInterface.php | 7 + .../alpha/NamespaceCollision/A/Bar.php | 17 + .../alpha/NamespaceCollision/A/Foo.php | 17 + .../alpha/NamespaceCollision/C/Bar.php | 8 + .../alpha/NamespaceCollision/C/Foo.php | 8 + .../Fixtures/alpha/PrefixCollision/A/Bar.php | 6 + .../Fixtures/alpha/PrefixCollision/A/Foo.php | 6 + .../Fixtures/alpha/PrefixCollision/C/Bar.php | 6 + .../Fixtures/alpha/PrefixCollision/C/Foo.php | 6 + .../beta/NamespaceCollision/A/B/Bar.php | 17 + .../beta/NamespaceCollision/A/B/Foo.php | 17 + .../beta/NamespaceCollision/C/B/Bar.php | 8 + .../beta/NamespaceCollision/C/B/Foo.php | 8 + .../Fixtures/beta/PrefixCollision/A/B/Bar.php | 6 + .../Fixtures/beta/PrefixCollision/A/B/Foo.php | 6 + .../Fixtures/beta/PrefixCollision/C/B/Bar.php | 6 + .../Fixtures/beta/PrefixCollision/C/B/Foo.php | 6 + .../Tests/Fixtures/classmap/SomeClass.php | 16 + .../Tests/Fixtures/classmap/SomeInterface.php | 16 + .../Tests/Fixtures/classmap/SomeParent.php | 16 + .../Tests/Fixtures/classmap/multipleNs.php | 25 + .../Tests/Fixtures/classmap/notAClass.php | 3 + .../Tests/Fixtures/classmap/notPhpFile.md | 1 + .../classmap/sameNsMultipleClasses.php | 19 + .../Tests/Fixtures/deps/traits.php | 37 + .../Fixtures/fallback/Namespaced/FooBar.php | 17 + .../Fixtures/fallback/Namespaced2/FooBar.php | 8 + .../Fixtures/fallback/Pearlike/FooBar.php | 6 + .../Fixtures/fallback/Pearlike2/FooBar.php | 6 + .../Tests/Fixtures/includepath/Foo.php | 5 + .../Tests/Fixtures/php5.4/traits.php | 32 + .../Tests/Fixtures/php5.5/class_cons.php | 11 + .../Fixtures/psr-4/Class_With_Underscores.php | 7 + .../class-loader/Tests/Fixtures/psr-4/Foo.php | 7 + .../Lets/Go/Deeper/Class_With_Underscores.php | 7 + .../Fixtures/psr-4/Lets/Go/Deeper/Foo.php | 7 + .../Tests/Psr4ClassLoaderTest.php | 75 + .../config/Tests/ConfigCacheFactoryTest.php | 27 + lib/symfony/config/Tests/ConfigCacheTest.php | 99 + .../config/Tests/Definition/ArrayNodeTest.php | 237 ++ .../Tests/Definition/BooleanNodeTest.php | 74 + .../Builder/ArrayNodeDefinitionTest.php | 362 +++ .../Builder/BooleanNodeDefinitionTest.php | 37 + .../Builder/EnumNodeDefinitionTest.php | 73 + .../Definition/Builder/ExprBuilderTest.php | 264 ++ .../Definition/Builder/NodeBuilderTest.php | 91 + .../Builder/NumericNodeDefinitionTest.php | 89 + .../Definition/Builder/TreeBuilderTest.php | 134 + .../Dumper/XmlReferenceDumperTest.php | 114 + .../Dumper/YamlReferenceDumperTest.php | 143 + .../config/Tests/Definition/EnumNodeTest.php | 51 + .../Tests/Definition/FinalizationTest.php | 74 + .../config/Tests/Definition/FloatNodeTest.php | 78 + .../Tests/Definition/IntegerNodeTest.php | 75 + .../config/Tests/Definition/MergeTest.php | 192 ++ .../Tests/Definition/NormalizationTest.php | 228 ++ .../Definition/PrototypedArrayNodeTest.php | 341 +++ .../Tests/Definition/ScalarNodeTest.php | 161 ++ .../ConfigCachePassTest.php | 59 + .../Exception/FileLoaderLoadExceptionTest.php | 98 + lib/symfony/config/Tests/FileLocatorTest.php | 114 + .../config/Tests/Fixtures/Again/foo.xml | 0 .../config/Tests/Fixtures/BadParent.php | 7 + lib/symfony/config/Tests/Fixtures/BarNode.php | 18 + .../Fixtures/Builder/BarNodeDefinition.php | 23 + .../Tests/Fixtures/Builder/NodeBuilder.php | 34 + .../Builder/VariableNodeDefinition.php | 18 + .../Configuration/ExampleConfiguration.php | 102 + .../Tests/Fixtures/Resource/.hiddenFile | 0 .../Fixtures/Resource/ConditionalClass.php | 9 + .../Tests/Fixtures/Util/document_type.xml | 3 + .../config/Tests/Fixtures/Util/invalid.xml | 2 + .../Tests/Fixtures/Util/invalid_schema.xml | 2 + .../config/Tests/Fixtures/Util/schema.xsd | 9 + .../config/Tests/Fixtures/Util/valid.xml | 3 + lib/symfony/config/Tests/Fixtures/foo.xml | 0 .../Tests/Loader/DelegatingLoaderTest.php | 69 + .../config/Tests/Loader/FileLoaderTest.php | 128 + .../Tests/Loader/LoaderResolverTest.php | 47 + .../config/Tests/Loader/LoaderTest.php | 116 + .../Resource/ClassExistenceResourceTest.php | 99 + .../Tests/Resource/ComposerResourceTest.php | 47 + .../Tests/Resource/DirectoryResourceTest.php | 181 ++ .../Resource/FileExistenceResourceTest.php | 71 + .../Tests/Resource/FileResourceTest.php | 83 + .../Tests/Resource/GlobResourceTest.php | 114 + .../Resource/ReflectionClassResourceTest.php | 223 ++ .../config/Tests/Resource/ResourceStub.php | 34 + .../Tests/ResourceCheckerConfigCacheTest.php | 150 + .../config/Tests/Util/XmlUtilsTest.php | 211 ++ lib/symfony/console/Tests/ApplicationTest.php | 1744 +++++++++++ .../console/Tests/Command/CommandTest.php | 430 +++ .../console/Tests/Command/HelpCommandTest.php | 71 + .../console/Tests/Command/ListCommandTest.php | 113 + .../Tests/Command/LockableTraitTest.php | 67 + .../ContainerCommandLoaderTest.php | 59 + .../FactoryCommandLoaderTest.php | 58 + .../AddConsoleCommandPassTest.php | 256 ++ .../Descriptor/AbstractDescriptorTest.php | 107 + .../Descriptor/ApplicationDescriptionTest.php | 53 + .../Tests/Descriptor/JsonDescriptorTest.php | 35 + .../Descriptor/MarkdownDescriptorTest.php | 45 + .../Tests/Descriptor/ObjectsProvider.php | 82 + .../Tests/Descriptor/TextDescriptorTest.php | 53 + .../Tests/Descriptor/XmlDescriptorTest.php | 27 + .../Tests/EventListener/ErrorListenerTest.php | 156 + .../console/Tests/Fixtures/BarBucCommand.php | 11 + .../Tests/Fixtures/DescriptorApplication1.php | 18 + .../Tests/Fixtures/DescriptorApplication2.php | 26 + .../DescriptorApplicationMbString.php | 24 + .../Tests/Fixtures/DescriptorCommand1.php | 27 + .../Tests/Fixtures/DescriptorCommand2.php | 32 + .../Tests/Fixtures/DescriptorCommand3.php | 27 + .../Tests/Fixtures/DescriptorCommand4.php | 25 + .../Fixtures/DescriptorCommandMbString.php | 32 + .../console/Tests/Fixtures/DummyOutput.php | 36 + .../console/Tests/Fixtures/Foo1Command.php | 26 + .../console/Tests/Fixtures/Foo2Command.php | 21 + .../console/Tests/Fixtures/Foo3Command.php | 29 + .../console/Tests/Fixtures/Foo4Command.php | 11 + .../console/Tests/Fixtures/Foo5Command.php | 10 + .../console/Tests/Fixtures/Foo6Command.php | 11 + .../console/Tests/Fixtures/FooCommand.php | 33 + .../Tests/Fixtures/FooHiddenCommand.php | 21 + .../Tests/Fixtures/FooLock2Command.php | 28 + .../console/Tests/Fixtures/FooLockCommand.php | 27 + .../console/Tests/Fixtures/FooOptCommand.php | 36 + .../Fixtures/FooSameCaseLowercaseCommand.php | 11 + .../Fixtures/FooSameCaseUppercaseCommand.php | 11 + .../Fixtures/FooSubnamespaced1Command.php | 26 + .../Fixtures/FooSubnamespaced2Command.php | 26 + .../console/Tests/Fixtures/FoobarCommand.php | 25 + .../Style/SymfonyStyle/command/command_0.php | 11 + .../Style/SymfonyStyle/command/command_1.php | 13 + .../Style/SymfonyStyle/command/command_10.php | 17 + .../Style/SymfonyStyle/command/command_11.php | 12 + .../Style/SymfonyStyle/command/command_12.php | 13 + .../Style/SymfonyStyle/command/command_13.php | 14 + .../Style/SymfonyStyle/command/command_14.php | 17 + .../Style/SymfonyStyle/command/command_15.php | 14 + .../Style/SymfonyStyle/command/command_16.php | 15 + .../Style/SymfonyStyle/command/command_17.php | 13 + .../Style/SymfonyStyle/command/command_2.php | 16 + .../Style/SymfonyStyle/command/command_3.php | 12 + .../Style/SymfonyStyle/command/command_4.php | 34 + .../Style/SymfonyStyle/command/command_5.php | 37 + .../Style/SymfonyStyle/command/command_6.php | 16 + .../Style/SymfonyStyle/command/command_7.php | 15 + .../Style/SymfonyStyle/command/command_8.php | 26 + .../Style/SymfonyStyle/command/command_9.php | 11 + .../command/interactive_command_1.php | 19 + .../output/interactive_output_1.txt | 7 + .../Style/SymfonyStyle/output/output_0.txt | 3 + .../Style/SymfonyStyle/output/output_1.txt | 9 + .../Style/SymfonyStyle/output/output_10.txt | 7 + .../Style/SymfonyStyle/output/output_11.txt | 4 + .../Style/SymfonyStyle/output/output_12.txt | 6 + .../Style/SymfonyStyle/output/output_13.txt | 7 + .../Style/SymfonyStyle/output/output_14.txt | 6 + .../Style/SymfonyStyle/output/output_15.txt | 7 + .../Style/SymfonyStyle/output/output_16.txt | 8 + .../Style/SymfonyStyle/output/output_17.txt | 7 + .../Style/SymfonyStyle/output/output_2.txt | 13 + .../Style/SymfonyStyle/output/output_3.txt | 7 + .../Style/SymfonyStyle/output/output_4.txt | 32 + .../Style/SymfonyStyle/output/output_5.txt | 18 + .../Style/SymfonyStyle/output/output_6.txt | 6 + .../Style/SymfonyStyle/output/output_7.txt | 5 + .../Style/SymfonyStyle/output/output_8.txt | 9 + .../Style/SymfonyStyle/output/output_9.txt | 5 + .../TestAmbiguousCommandRegistering.php | 22 + .../TestAmbiguousCommandRegistering2.php | 21 + .../console/Tests/Fixtures/TestCommand.php | 28 + .../console/Tests/Fixtures/application_1.json | 156 + .../console/Tests/Fixtures/application_1.md | 172 ++ .../console/Tests/Fixtures/application_1.txt | 17 + .../console/Tests/Fixtures/application_1.xml | 104 + .../console/Tests/Fixtures/application_2.json | 509 ++++ .../console/Tests/Fixtures/application_2.md | 431 +++ .../console/Tests/Fixtures/application_2.txt | 21 + .../console/Tests/Fixtures/application_2.xml | 254 ++ .../application_filtered_namespace.txt | 16 + .../Tests/Fixtures/application_gethelp.txt | 1 + .../Tests/Fixtures/application_mbstring.md | 269 ++ .../Tests/Fixtures/application_mbstring.txt | 19 + .../Fixtures/application_renderexception1.txt | 5 + .../Fixtures/application_renderexception2.txt | 7 + .../Fixtures/application_renderexception3.txt | 18 + .../application_renderexception3decorated.txt | 18 + .../Fixtures/application_renderexception4.txt | 6 + ...plication_renderexception_doublewidth1.txt | 8 + ..._renderexception_doublewidth1decorated.txt | 8 + ...plication_renderexception_doublewidth2.txt | 9 + ...plication_renderexception_escapeslines.txt | 9 + ...application_renderexception_linebreaks.txt | 11 + .../Tests/Fixtures/application_run1.txt | 17 + .../Tests/Fixtures/application_run2.txt | 26 + .../Tests/Fixtures/application_run3.txt | 26 + .../Tests/Fixtures/application_run4.txt | 1 + .../console/Tests/Fixtures/command_1.json | 15 + .../console/Tests/Fixtures/command_1.md | 12 + .../console/Tests/Fixtures/command_1.txt | 7 + .../console/Tests/Fixtures/command_1.xml | 12 + .../console/Tests/Fixtures/command_2.json | 33 + .../console/Tests/Fixtures/command_2.md | 29 + .../console/Tests/Fixtures/command_2.txt | 13 + .../console/Tests/Fixtures/command_2.xml | 21 + .../Tests/Fixtures/command_mbstring.md | 29 + .../Tests/Fixtures/command_mbstring.txt | 13 + .../Tests/Fixtures/input_argument_1.json | 7 + .../Tests/Fixtures/input_argument_1.md | 5 + .../Tests/Fixtures/input_argument_1.txt | 1 + .../Tests/Fixtures/input_argument_1.xml | 5 + .../Tests/Fixtures/input_argument_2.json | 7 + .../Tests/Fixtures/input_argument_2.md | 7 + .../Tests/Fixtures/input_argument_2.txt | 1 + .../Tests/Fixtures/input_argument_2.xml | 5 + .../Tests/Fixtures/input_argument_3.json | 7 + .../Tests/Fixtures/input_argument_3.md | 7 + .../Tests/Fixtures/input_argument_3.txt | 1 + .../Tests/Fixtures/input_argument_3.xml | 7 + .../Tests/Fixtures/input_argument_4.json | 7 + .../Tests/Fixtures/input_argument_4.md | 8 + .../Tests/Fixtures/input_argument_4.txt | 2 + .../Tests/Fixtures/input_argument_4.xml | 6 + ...input_argument_with_default_inf_value.json | 7 + .../input_argument_with_default_inf_value.md | 7 + .../input_argument_with_default_inf_value.txt | 1 + .../input_argument_with_default_inf_value.xml | 7 + .../Fixtures/input_argument_with_style.json | 7 + .../Fixtures/input_argument_with_style.md | 7 + .../Fixtures/input_argument_with_style.txt | 1 + .../Fixtures/input_argument_with_style.xml | 7 + .../Tests/Fixtures/input_definition_1.json | 4 + .../Tests/Fixtures/input_definition_1.md | 0 .../Tests/Fixtures/input_definition_1.txt | 0 .../Tests/Fixtures/input_definition_1.xml | 5 + .../Tests/Fixtures/input_definition_2.json | 12 + .../Tests/Fixtures/input_definition_2.md | 7 + .../Tests/Fixtures/input_definition_2.txt | 2 + .../Tests/Fixtures/input_definition_2.xml | 10 + .../Tests/Fixtures/input_definition_3.json | 14 + .../Tests/Fixtures/input_definition_3.md | 8 + .../Tests/Fixtures/input_definition_3.txt | 2 + .../Tests/Fixtures/input_definition_3.xml | 9 + .../Tests/Fixtures/input_definition_4.json | 22 + .../Tests/Fixtures/input_definition_4.md | 16 + .../Tests/Fixtures/input_definition_4.txt | 5 + .../Tests/Fixtures/input_definition_4.xml | 14 + .../Tests/Fixtures/input_option_1.json | 9 + .../console/Tests/Fixtures/input_option_1.md | 6 + .../console/Tests/Fixtures/input_option_1.txt | 1 + .../console/Tests/Fixtures/input_option_1.xml | 4 + .../Tests/Fixtures/input_option_2.json | 9 + .../console/Tests/Fixtures/input_option_2.md | 8 + .../console/Tests/Fixtures/input_option_2.txt | 1 + .../console/Tests/Fixtures/input_option_2.xml | 7 + .../Tests/Fixtures/input_option_3.json | 9 + .../console/Tests/Fixtures/input_option_3.md | 8 + .../console/Tests/Fixtures/input_option_3.txt | 1 + .../console/Tests/Fixtures/input_option_3.xml | 5 + .../Tests/Fixtures/input_option_4.json | 9 + .../console/Tests/Fixtures/input_option_4.md | 8 + .../console/Tests/Fixtures/input_option_4.txt | 1 + .../console/Tests/Fixtures/input_option_4.xml | 5 + .../Tests/Fixtures/input_option_5.json | 9 + .../console/Tests/Fixtures/input_option_5.md | 9 + .../console/Tests/Fixtures/input_option_5.txt | 2 + .../console/Tests/Fixtures/input_option_5.xml | 6 + .../Tests/Fixtures/input_option_6.json | 9 + .../console/Tests/Fixtures/input_option_6.md | 8 + .../console/Tests/Fixtures/input_option_6.txt | 1 + .../console/Tests/Fixtures/input_option_6.xml | 5 + .../input_option_with_default_inf_value.json | 9 + .../input_option_with_default_inf_value.md | 8 + .../input_option_with_default_inf_value.txt | 1 + .../input_option_with_default_inf_value.xml | 7 + .../Fixtures/input_option_with_style.json | 9 + .../Tests/Fixtures/input_option_with_style.md | 8 + .../Fixtures/input_option_with_style.txt | 1 + .../Fixtures/input_option_with_style.xml | 7 + .../input_option_with_style_array.json | 12 + .../Fixtures/input_option_with_style_array.md | 8 + .../input_option_with_style_array.txt | 1 + .../input_option_with_style_array.xml | 8 + .../OutputFormatterStyleStackTest.php | 69 + .../Formatter/OutputFormatterStyleTest.php | 100 + .../Tests/Formatter/OutputFormatterTest.php | 344 +++ .../Helper/AbstractQuestionHelperTest.php | 34 + .../Tests/Helper/FormatterHelperTest.php | 129 + .../console/Tests/Helper/HelperSetTest.php | 127 + .../console/Tests/Helper/HelperTest.php | 55 + .../Tests/Helper/ProcessHelperTest.php | 118 + .../console/Tests/Helper/ProgressBarTest.php | 805 ++++++ .../Tests/Helper/ProgressIndicatorTest.php | 175 ++ .../Tests/Helper/QuestionHelperTest.php | 1085 +++++++ .../Helper/SymfonyQuestionHelperTest.php | 166 ++ .../console/Tests/Helper/TableStyleTest.php | 26 + .../console/Tests/Helper/TableTest.php | 868 ++++++ .../console/Tests/Input/ArgvInputTest.php | 462 +++ .../console/Tests/Input/ArrayInputTest.php | 173 ++ .../console/Tests/Input/InputArgumentTest.php | 109 + .../Tests/Input/InputDefinitionTest.php | 389 +++ .../console/Tests/Input/InputOptionTest.php | 194 ++ lib/symfony/console/Tests/Input/InputTest.php | 137 + .../console/Tests/Input/StringInputTest.php | 87 + .../Tests/Logger/ConsoleLoggerTest.php | 213 ++ .../Tests/Output/ConsoleOutputTest.php | 42 + .../console/Tests/Output/NullOutputTest.php | 88 + .../console/Tests/Output/OutputTest.php | 176 ++ .../console/Tests/Output/StreamOutputTest.php | 59 + .../Tests/Question/ChoiceQuestionTest.php | 64 + .../Question/ConfirmationQuestionTest.php | 62 + .../console/Tests/Style/SymfonyStyleTest.php | 118 + lib/symfony/console/Tests/TerminalTest.php | 97 + .../Tests/Tester/ApplicationTesterTest.php | 70 + .../Tests/Tester/CommandTesterTest.php | 212 ++ .../Tests/CssSelectorConverterTest.php | 74 + .../Tests/Node/AbstractNodeTest.php | 34 + .../Tests/Node/AttributeNodeTest.php | 37 + .../css-selector/Tests/Node/ClassNodeTest.php | 33 + .../Tests/Node/CombinedSelectorNodeTest.php | 35 + .../Tests/Node/ElementNodeTest.php | 35 + .../Tests/Node/FunctionNodeTest.php | 47 + .../css-selector/Tests/Node/HashNodeTest.php | 33 + .../Tests/Node/NegationNodeTest.php | 33 + .../Tests/Node/PseudoNodeTest.php | 32 + .../Tests/Node/SelectorNodeTest.php | 34 + .../Tests/Node/SpecificityTest.php | 63 + .../Parser/Handler/AbstractHandlerTest.php | 70 + .../Parser/Handler/CommentHandlerTest.php | 55 + .../Tests/Parser/Handler/HashHandlerTest.php | 49 + .../Parser/Handler/IdentifierHandlerTest.php | 49 + .../Parser/Handler/NumberHandlerTest.php | 50 + .../Parser/Handler/StringHandlerTest.php | 50 + .../Parser/Handler/WhitespaceHandlerTest.php | 44 + .../css-selector/Tests/Parser/ParserTest.php | 253 ++ .../css-selector/Tests/Parser/ReaderTest.php | 102 + .../Tests/Parser/Shortcut/ClassParserTest.php | 45 + .../Parser/Shortcut/ElementParserTest.php | 44 + .../Parser/Shortcut/EmptyStringParserTest.php | 36 + .../Tests/Parser/Shortcut/HashParserTest.php | 45 + .../Tests/Parser/TokenStreamTest.php | 96 + .../Tests/XPath/Fixtures/ids.html | 48 + .../Tests/XPath/Fixtures/lang.xml | 11 + .../Tests/XPath/Fixtures/shakespear.html | 308 ++ .../Tests/XPath/TranslatorTest.php | 413 +++ .../debug/Resources/ext/tests/001.phpt | 155 + .../debug/Resources/ext/tests/002.phpt | 65 + .../debug/Resources/ext/tests/002_1.phpt | 48 + .../debug/Resources/ext/tests/003.phpt | 87 + .../debug/Tests/DebugClassLoaderTest.php | 445 +++ lib/symfony/debug/Tests/ErrorHandlerTest.php | 646 +++++ .../Tests/Exception/FlattenExceptionTest.php | 302 ++ .../debug/Tests/ExceptionHandlerTest.php | 163 ++ .../ClassNotFoundFatalErrorHandlerTest.php | 180 ++ ...UndefinedFunctionFatalErrorHandlerTest.php | 81 + .../UndefinedMethodFatalErrorHandlerTest.php | 76 + .../debug/Tests/Fixtures/AnnotatedClass.php | 13 + .../debug/Tests/Fixtures/ClassAlias.php | 3 + .../Fixtures/DefinitionInEvaluatedCode.php | 11 + .../debug/Tests/Fixtures/DeprecatedClass.php | 12 + .../Tests/Fixtures/DeprecatedInterface.php | 12 + .../ErrorHandlerThatUsesThePreviousOne.php | 22 + .../Tests/Fixtures/ExtendedFinalMethod.php | 19 + .../debug/Tests/Fixtures/FinalClasses.php | 85 + .../debug/Tests/Fixtures/FinalMethod.php | 26 + .../Tests/Fixtures/FinalMethod2Trait.php | 10 + .../debug/Tests/Fixtures/InternalClass.php | 15 + .../Tests/Fixtures/InternalInterface.php | 10 + .../debug/Tests/Fixtures/InternalTrait.php | 10 + .../debug/Tests/Fixtures/InternalTrait2.php | 23 + .../Fixtures/LoggerThatSetAnErrorHandler.php | 15 + .../Tests/Fixtures/NonDeprecatedInterface.php | 7 + .../debug/Tests/Fixtures/PEARClass.php | 5 + lib/symfony/debug/Tests/Fixtures/Throwing.php | 3 + .../debug/Tests/Fixtures/ToStringThrower.php | 24 + .../Fixtures/TraitWithInternalMethod.php | 13 + .../debug/Tests/Fixtures/casemismatch.php | 7 + .../debug/Tests/Fixtures/notPsr0Bis.php | 7 + .../Tests/Fixtures/psr4/Psr4CaseMismatch.php | 7 + .../debug/Tests/Fixtures/reallyNotPsr0.php | 7 + .../debug/Tests/Fixtures2/RequiredTwice.php | 7 + lib/symfony/debug/Tests/HeaderMock.php | 38 + .../debug/Tests/phpt/debug_class_loader.phpt | 27 + .../Tests/phpt/decorate_exception_hander.phpt | 47 + .../debug/Tests/phpt/exception_rethrown.phpt | 35 + .../phpt/fatal_with_nested_handlers.phpt | 42 + .../Argument/RewindableGeneratorTest.php | 53 + .../Tests/ChildDefinitionTest.php | 149 + .../AnalyzeServiceReferencesPassTest.php | 215 ++ .../Compiler/AutoAliasServicePassTest.php | 108 + .../Compiler/AutowireExceptionPassTest.php | 145 + .../Tests/Compiler/AutowirePassTest.php | 916 ++++++ .../AutowireRequiredMethodsPassTest.php | 80 + .../CheckArgumentsValidityPassTest.php | 78 + .../CheckCircularReferencesPassTest.php | 146 + .../CheckDefinitionValidityPassTest.php | 110 + ...tionOnInvalidReferenceBehaviorPassTest.php | 86 + .../CheckReferenceValidityPassTest.php | 48 + .../Compiler/DecoratorServicePassTest.php | 199 ++ .../DefinitionErrorExceptionPassTest.php | 51 + .../Compiler/ExtensionCompilerPassTest.php | 81 + .../Compiler/FactoryReturnTypePassTest.php | 123 + .../InlineServiceDefinitionsPassTest.php | 358 +++ .../Tests/Compiler/IntegrationTest.php | 252 ++ .../MergeExtensionConfigurationPassTest.php | 197 ++ .../Tests/Compiler/OptionalServiceClass.php | 18 + .../Tests/Compiler/PassConfigTest.php | 38 + .../PriorityTaggedServiceTraitTest.php | 91 + .../RegisterEnvVarProcessorsPassTest.php | 86 + .../RegisterServiceSubscribersPassTest.php | 133 + .../RemoveUnusedDefinitionsPassTest.php | 137 + ...ReplaceAliasByActualDefinitionPassTest.php | 69 + .../Compiler/ResolveBindingsPassTest.php | 152 + .../ResolveChildDefinitionsPassTest.php | 449 +++ .../Tests/Compiler/ResolveClassPassTest.php | 95 + .../ResolveDefinitionTemplatesPassTest.php | 407 +++ .../Compiler/ResolveFactoryClassPassTest.php | 86 + .../Tests/Compiler/ResolveHotPathPassTest.php | 57 + .../ResolveInstanceofConditionalsPassTest.php | 262 ++ .../ResolveInvalidReferencesPassTest.php | 135 + .../ResolveNamedArgumentsPassTest.php | 173 ++ .../ResolveParameterPlaceHoldersPassTest.php | 100 + .../Compiler/ResolvePrivatesPassTest.php | 39 + .../ResolveReferencesToAliasesPassTest.php | 89 + .../ResolveTaggedIteratorArgumentPassTest.php | 40 + .../Compiler/ServiceLocatorTagPassTest.php | 145 + .../Config/AutowireServiceResourceTest.php | 124 + ...ContainerParametersResourceCheckerTest.php | 78 + .../ContainerParametersResourceTest.php | 43 + .../Tests/ContainerBuilderTest.php | 1536 ++++++++++ .../Tests/ContainerTest.php | 692 +++++ .../Tests/CrossCheckTest.php | 95 + .../Tests/DefinitionDecoratorTest.php | 128 + .../Tests/DefinitionTest.php | 387 +++ .../Tests/Dumper/GraphvizDumperTest.php | 88 + .../Tests/Dumper/PhpDumperTest.php | 1184 ++++++++ .../Tests/Dumper/XmlDumperTest.php | 210 ++ .../Tests/Dumper/YamlDumperTest.php | 104 + .../Tests/EnvVarProcessorTest.php | 300 ++ .../Tests/Extension/ExtensionTest.php | 57 + .../Tests/Fixtures/Bar.php | 26 + .../Tests/Fixtures/BarInterface.php | 16 + .../Tests/Fixtures/CaseSensitiveClass.php | 22 + ...tructorWithMandatoryArgumentsContainer.php | 10 + ...structorWithOptionalArgumentsContainer.php | 10 + .../ConstructorWithoutArgumentsContainer.php | 10 + .../Container/NoConstructorContainer.php | 9 + .../Tests/Fixtures/CustomDefinition.php | 18 + .../Tests/Fixtures/DeprecatedClass.php | 18 + .../Tests/Fixtures/FactoryDummy.php | 44 + .../FactoryDummyWithoutReturnTypes.php | 19 + .../Fixtures/FooForCircularWithAddCalls.php | 19 + .../Tests/Fixtures/NamedArgumentsDummy.php | 21 + .../Tests/Fixtures/ParentNotExists.php | 7 + .../Prototype/BadClasses/MissingParent.php | 7 + .../Tests/Fixtures/Prototype/Foo.php | 14 + .../Tests/Fixtures/Prototype/FooInterface.php | 7 + .../OtherDir/AnotherSub/DeeperBaz.php | 7 + .../Tests/Fixtures/Prototype/OtherDir/Baz.php | 7 + .../OtherDir/Component1/Dir1/Service1.php | 7 + .../OtherDir/Component1/Dir2/Service2.php | 7 + .../OtherDir/Component2/Dir1/Service4.php | 7 + .../OtherDir/Component2/Dir2/Service5.php | 7 + .../Tests/Fixtures/Prototype/Sub/Bar.php | 7 + .../Fixtures/Prototype/Sub/BarInterface.php | 7 + .../Tests/Fixtures/ScalarFactory.php | 14 + .../Tests/Fixtures/SimilarArgumentsDummy.php | 24 + .../Tests/Fixtures/StubbedTranslator.php | 28 + .../Tests/Fixtures/TestDefinition1.php | 18 + .../Tests/Fixtures/TestDefinition2.php | 9 + .../Tests/Fixtures/TestServiceSubscriber.php | 22 + .../Tests/Fixtures/array.json | 1 + .../Tests/Fixtures/config/basic.expected.yml | 10 + .../Tests/Fixtures/config/basic.php | 11 + .../Tests/Fixtures/config/child.expected.yml | 15 + .../Tests/Fixtures/config/child.php | 22 + .../Fixtures/config/defaults.expected.yml | 27 + .../Tests/Fixtures/config/defaults.php | 21 + .../config/factory_short_notation.php | 9 + .../Fixtures/config/instanceof.expected.yml | 21 + .../Tests/Fixtures/config/instanceof.php | 22 + .../Tests/Fixtures/config/php7.expected.yml | 19 + .../Tests/Fixtures/config/php7.php | 19 + .../Fixtures/config/prototype.expected.yml | 25 + .../Tests/Fixtures/config/prototype.php | 22 + .../Tests/Fixtures/config/services9.php | 128 + .../services_autoconfigure_with_parent.php | 9 + .../Fixtures/containers/CustomContainer.php | 17 + .../Tests/Fixtures/containers/container10.php | 15 + .../Tests/Fixtures/containers/container11.php | 13 + .../Tests/Fixtures/containers/container12.php | 13 + .../Tests/Fixtures/containers/container13.php | 18 + .../Tests/Fixtures/containers/container14.php | 17 + .../Tests/Fixtures/containers/container15.php | 12 + .../Tests/Fixtures/containers/container16.php | 12 + .../Tests/Fixtures/containers/container17.php | 11 + .../Tests/Fixtures/containers/container19.php | 27 + .../Tests/Fixtures/containers/container21.php | 21 + .../Tests/Fixtures/containers/container24.php | 13 + .../Tests/Fixtures/containers/container33.php | 12 + .../Tests/Fixtures/containers/container8.php | 25 + .../Tests/Fixtures/containers/container9.php | 176 ++ .../containers/container_abstract.php | 13 + .../containers/container_almost_circular.php | 176 ++ .../containers/container_env_in_id.php | 22 + .../containers/container_inline_requires.php | 19 + .../container_uninitialized_ref.php | 49 + .../Fixtures/directory/import/import.yml | 2 + .../Fixtures/directory/recurse/simple.ini | 2 + .../Fixtures/directory/recurse/simple.yml | 2 + .../Tests/Fixtures/directory/simple.php | 3 + .../Tests/Fixtures/graphviz/services1.dot | 7 + .../Tests/Fixtures/graphviz/services10-1.dot | 10 + .../Tests/Fixtures/graphviz/services10.dot | 10 + .../Tests/Fixtures/graphviz/services13.dot | 10 + .../Tests/Fixtures/graphviz/services14.dot | 7 + .../Tests/Fixtures/graphviz/services17.dot | 8 + .../Tests/Fixtures/graphviz/services18.dot | 8 + .../Tests/Fixtures/graphviz/services9.dot | 56 + .../Fixtures/graphviz/services_inline.dot | 10 + .../Tests/Fixtures/includes/FooVariadic.php | 16 + .../Tests/Fixtures/includes/HotPath/C1.php | 8 + .../Tests/Fixtures/includes/HotPath/C2.php | 7 + .../Tests/Fixtures/includes/HotPath/C3.php | 7 + .../Tests/Fixtures/includes/HotPath/I1.php | 7 + .../Tests/Fixtures/includes/HotPath/P1.php | 7 + .../Tests/Fixtures/includes/HotPath/T1.php | 7 + .../Fixtures/includes/ProjectExtension.php | 47 + .../includes/ProjectWithXsdExtension.php | 19 + .../ProjectWithXsdExtensionInPhar.phar | Bin 0 -> 1161 bytes .../Fixtures/includes/autowiring_classes.php | 336 +++ .../Tests/Fixtures/includes/classes.php | 136 + .../Tests/Fixtures/includes/createphar.php | 47 + .../Tests/Fixtures/includes/foo.php | 43 + .../Fixtures/includes/schema/project-1.0.xsd | 13 + .../Tests/Fixtures/ini/almostvalid.ini | 2 + .../Tests/Fixtures/ini/ini_with_wrong_ext.xml | 2 + .../Tests/Fixtures/ini/nonvalid.ini | 2 + .../Tests/Fixtures/ini/parameters.ini | 3 + .../Tests/Fixtures/ini/parameters1.ini | 3 + .../Tests/Fixtures/ini/parameters2.ini | 2 + .../Tests/Fixtures/ini/types.ini | 28 + ...er_class_constructor_without_arguments.php | 58 + ...s_with_mandatory_constructor_arguments.php | 55 + ...ss_with_optional_constructor_arguments.php | 58 + ...om_container_class_without_constructor.php | 55 + .../Tests/Fixtures/php/php_with_wrong_ext.yml | 3 + .../Tests/Fixtures/php/services1-1.php | 55 + .../Tests/Fixtures/php/services1.php | 53 + .../Tests/Fixtures/php/services10.php | 157 + .../Tests/Fixtures/php/services12.php | 171 ++ .../Tests/Fixtures/php/services13.php | 70 + .../Tests/Fixtures/php/services19.php | 181 ++ .../Tests/Fixtures/php/services24.php | 66 + .../Tests/Fixtures/php/services26.php | 194 ++ .../Tests/Fixtures/php/services33.php | 81 + .../Tests/Fixtures/php/services8.php | 167 ++ .../Tests/Fixtures/php/services9.php | 443 +++ .../Tests/Fixtures/php/services9_as_files.txt | 508 ++++ .../Tests/Fixtures/php/services9_compiled.php | 475 +++ .../Tests/Fixtures/php/services_adawson.php | 190 ++ .../php/services_almost_circular_private.php | 514 ++++ .../php/services_almost_circular_public.php | 640 +++++ .../Fixtures/php/services_array_params.php | 176 ++ .../Fixtures/php/services_base64_env.php | 151 + .../php/services_dedup_lazy_proxy.php | 88 + .../Fixtures/php/services_deep_graph.php | 93 + .../Tests/Fixtures/php/services_env_in_id.php | 188 ++ .../Fixtures/php/services_inline_requires.php | 215 ++ .../Fixtures/php/services_inline_self_ref.php | 78 + .../Fixtures/php/services_legacy_privates.php | 193 ++ .../Tests/Fixtures/php/services_locator.php | 184 ++ .../Fixtures/php/services_non_shared_lazy.php | 92 + .../Fixtures/php/services_private_frozen.php | 92 + .../php/services_private_in_expression.php | 82 + .../Tests/Fixtures/php/services_rot13_env.php | 180 ++ .../Fixtures/php/services_subscriber.php | 106 + .../Tests/Fixtures/php/services_tsantos.php | 87 + .../php/services_uninitialized_ref.php | 134 + .../php/services_unsupported_characters.php | 178 ++ .../Tests/Fixtures/php/simple.php | 3 + .../Tests/Fixtures/xml/class_from_id.xml | 6 + .../Tests/Fixtures/xml/defaults_bindings.xml | 15 + .../Tests/Fixtures/xml/defaults_bindings2.xml | 10 + .../Fixtures/xml/extension1/services.xml | 14 + .../Fixtures/xml/extension2/services.xml | 14 + .../Fixtures/xml/extensions/services1.xml | 19 + .../Fixtures/xml/extensions/services2.xml | 19 + .../Fixtures/xml/extensions/services3.xml | 19 + .../Fixtures/xml/extensions/services4.xml | 6 + .../Fixtures/xml/extensions/services5.xml | 11 + .../Fixtures/xml/extensions/services6.xml | 11 + .../Fixtures/xml/extensions/services7.xml | 11 + .../xml/legacy_invalid_alias_definition.xml | 11 + .../Tests/Fixtures/xml/namespaces.xml | 17 + .../xml/nested_service_without_id.xml | 10 + .../Tests/Fixtures/xml/nonvalid.xml | 3 + .../Tests/Fixtures/xml/services1.xml | 8 + .../Tests/Fixtures/xml/services10.xml | 16 + .../Tests/Fixtures/xml/services13.xml | 9 + .../Tests/Fixtures/xml/services14.xml | 19 + .../Tests/Fixtures/xml/services2.xml | 31 + .../Tests/Fixtures/xml/services21.xml | 24 + .../Tests/Fixtures/xml/services22.xml | 9 + .../Tests/Fixtures/xml/services23.xml | 6 + .../Tests/Fixtures/xml/services24.xml | 9 + .../Tests/Fixtures/xml/services28.xml | 13 + .../Tests/Fixtures/xml/services3.xml | 13 + .../Tests/Fixtures/xml/services4.xml | 14 + .../Fixtures/xml/services4_bad_import.xml | 9 + .../Tests/Fixtures/xml/services5.xml | 25 + .../Tests/Fixtures/xml/services6.xml | 69 + .../Tests/Fixtures/xml/services7.xml | 9 + .../Tests/Fixtures/xml/services8.xml | 38 + .../Tests/Fixtures/xml/services9.xml | 147 + .../Tests/Fixtures/xml/services_abstract.xml | 9 + .../Fixtures/xml/services_autoconfigure.xml | 9 + .../services_autoconfigure_with_parent.xml | 7 + .../Tests/Fixtures/xml/services_bindings.xml | 21 + .../xml/services_defaults_with_parent.xml | 9 + .../Fixtures/xml/services_deprecated.xml | 11 + .../Tests/Fixtures/xml/services_dump_load.xml | 11 + .../xml/services_inline_not_candidate.xml | 11 + .../Fixtures/xml/services_instanceof.xml | 12 + .../xml/services_instanceof_with_parent.xml | 9 + .../Fixtures/xml/services_named_args.xml | 12 + .../Tests/Fixtures/xml/services_prototype.xml | 6 + .../Tests/Fixtures/xml/services_tsantos.xml | 65 + .../Fixtures/xml/services_without_id.xml | 12 + .../Fixtures/xml/tag_with_empty_name.xml | 11 + .../Tests/Fixtures/xml/tag_without_name.xml | 11 + .../xml/with_key_outside_collection.xml | 9 + .../Tests/Fixtures/xml/withdoctype.xml | 3 + .../Tests/Fixtures/xml/xml_with_wrong_ext.php | 9 + .../Fixtures/yaml/anonymous_services.yml | 14 + .../yaml/anonymous_services_alias.yml | 7 + .../yaml/anonymous_services_in_instanceof.yml | 15 + .../yaml/anonymous_services_in_parameters.yml | 2 + .../Tests/Fixtures/yaml/bad_calls.yml | 4 + .../Tests/Fixtures/yaml/bad_decorates.yml | 7 + .../Fixtures/yaml/bad_empty_defaults.yml | 2 + .../Fixtures/yaml/bad_empty_instanceof.yml | 2 + .../Tests/Fixtures/yaml/bad_format.yml | 2 + .../Tests/Fixtures/yaml/bad_import.yml | 2 + .../Tests/Fixtures/yaml/bad_imports.yml | 2 + .../Tests/Fixtures/yaml/bad_parameters.yml | 2 + .../Tests/Fixtures/yaml/bad_service.yml | 2 + .../Tests/Fixtures/yaml/bad_services.yml | 1 + .../Tests/Fixtures/yaml/bad_types1.yml | 5 + .../Tests/Fixtures/yaml/bad_types2.yml | 5 + .../Tests/Fixtures/yaml/badtag1.yml | 5 + .../Tests/Fixtures/yaml/badtag2.yml | 6 + .../Tests/Fixtures/yaml/badtag3.yml | 6 + .../Tests/Fixtures/yaml/bar/services.yml | 4 + .../Tests/Fixtures/yaml/class_from_id.yml | 3 + .../Tests/Fixtures/yaml/defaults_bindings.yml | 11 + .../Fixtures/yaml/defaults_bindings2.yml | 7 + .../Tests/Fixtures/yaml/foo/services.yml | 4 + .../_child.yml | 4 + .../expected.yml | 10 + .../autoconfigure_child_not_applied/main.yml | 7 + .../autoconfigure_parent_child/_child.yml | 3 + .../autoconfigure_parent_child/expected.yml | 5 + .../autoconfigure_parent_child/main.yml | 7 + .../_child.yml | 3 + .../expected.yml | 6 + .../autoconfigure_parent_child_tags/main.yml | 7 + .../integration/child_parent/expected.yml | 9 + .../yaml/integration/child_parent/main.yml | 13 + .../defaults_child_tags/expected.yml | 8 + .../integration/defaults_child_tags/main.yml | 18 + .../expected.yml | 26 + .../defaults_instanceof_importance/main.yml | 30 + .../defaults_parent_child/_child.yml | 4 + .../defaults_parent_child/expected.yml | 6 + .../defaults_parent_child/main.yml | 9 + .../instanceof_parent_child/_child.yml | 4 + .../instanceof_parent_child/expected.yml | 7 + .../instanceof_parent_child/main.yml | 11 + .../yaml/legacy_invalid_alias_definition.yml | 5 + .../yaml/legacy_invalid_definition.yml | 10 + .../Tests/Fixtures/yaml/nonvalid1.yml | 2 + .../Tests/Fixtures/yaml/nonvalid2.yml | 1 + .../Tests/Fixtures/yaml/null_config.yml | 1 + .../Tests/Fixtures/yaml/services1.yml | 11 + .../Tests/Fixtures/yaml/services10.yml | 9 + .../Tests/Fixtures/yaml/services11.yml | 1 + .../Tests/Fixtures/yaml/services13.yml | 3 + .../Tests/Fixtures/yaml/services14.yml | 3 + .../Tests/Fixtures/yaml/services2.yml | 13 + .../Tests/Fixtures/yaml/services21.yml | 15 + .../Tests/Fixtures/yaml/services22.yml | 8 + .../Tests/Fixtures/yaml/services23.yml | 4 + .../Tests/Fixtures/yaml/services24.yml | 16 + .../Tests/Fixtures/yaml/services26.yml | 22 + .../Tests/Fixtures/yaml/services28.yml | 34 + .../Tests/Fixtures/yaml/services3.yml | 5 + .../Fixtures/yaml/services31_invalid_tags.yml | 6 + .../Tests/Fixtures/yaml/services4.yml | 8 + .../Fixtures/yaml/services4_bad_import.yml | 2 + .../Tests/Fixtures/yaml/services6.yml | 43 + .../Tests/Fixtures/yaml/services7.yml | 2 + .../Tests/Fixtures/yaml/services8.yml | 29 + .../Tests/Fixtures/yaml/services9.yml | 163 ++ .../Tests/Fixtures/yaml/services_adawson.yml | 28 + .../Fixtures/yaml/services_autoconfigure.yml | 9 + .../services_autoconfigure_with_parent.yml | 8 + .../Tests/Fixtures/yaml/services_bindings.yml | 16 + .../services_configurator_short_syntax.yml | 8 + .../Fixtures/yaml/services_deep_graph.yml | 24 + .../yaml/services_defaults_with_parent.yml | 10 + .../Fixtures/yaml/services_dump_load.yml | 15 + .../Tests/Fixtures/yaml/services_inline.yml | 16 + .../Fixtures/yaml/services_instanceof.yml | 11 + .../yaml/services_instanceof_with_parent.yml | 11 + .../yaml/services_legacy_privates.yml | 27 + .../Fixtures/yaml/services_named_args.yml | 10 + .../Fixtures/yaml/services_prototype.yml | 4 + .../yaml/services_prototype_namespace.yml | 10 + ...s_prototype_namespace_without_resource.yml | 4 + .../Fixtures/yaml/services_underscore.yml | 3 + .../Fixtures/yaml/tag_name_empty_string.yml | 6 + .../Fixtures/yaml/tag_name_no_string.yml | 6 + .../Tests/Fixtures/yaml/tag_name_only.yml | 5 + .../Fixtures/yaml/yaml_with_wrong_ext.ini | 2 + .../RealServiceInstantiatorTest.php | 36 + .../LazyProxy/PhpDumper/NullDumperTest.php | 34 + .../Tests/Loader/ClosureLoaderTest.php | 38 + .../Tests/Loader/DirectoryLoaderTest.php | 78 + .../Tests/Loader/FileLoaderTest.php | 239 ++ .../Tests/Loader/GlobFileLoaderTest.php | 44 + .../Tests/Loader/IniFileLoaderTest.php | 127 + .../Tests/Loader/LoaderResolverTest.php | 62 + .../Tests/Loader/PhpFileLoaderTest.php | 101 + .../Tests/Loader/XmlFileLoaderTest.php | 829 ++++++ .../Tests/Loader/YamlFileLoaderTest.php | 736 +++++ .../EnvPlaceholderParameterBagTest.php | 159 + .../ParameterBag/FrozenParameterBagTest.php | 56 + .../Tests/ParameterBag/ParameterBagTest.php | 264 ++ .../Tests/ParameterTest.php | 24 + .../Tests/ReferenceTest.php | 24 + .../Tests/ServiceLocatorTest.php | 148 + lib/symfony/dotenv/Tests/DotenvTest.php | 317 ++ .../Tests/AbstractEventDispatcherTest.php | 442 +++ .../ContainerAwareEventDispatcherTest.php | 210 ++ .../Debug/TraceableEventDispatcherTest.php | 269 ++ .../Tests/Debug/WrappedListenerTest.php | 64 + .../RegisterListenersPassTest.php | 143 + .../Tests/EventDispatcherTest.php | 22 + .../event-dispatcher/Tests/EventTest.php | 55 + .../Tests/GenericEventTest.php | 134 + .../Tests/ImmutableEventDispatcherTest.php | 100 + .../filesystem/Tests/ExceptionTest.php | 47 + .../filesystem/Tests/FilesystemTest.php | 1656 +++++++++++ .../filesystem/Tests/FilesystemTestCase.php | 165 ++ .../Tests/Fixtures/MockStream/MockStream.php | 46 + .../filesystem/Tests/LockHandlerTest.php | 144 + .../Tests/Comparator/ComparatorTest.php | 65 + .../Tests/Comparator/DateComparatorTest.php | 64 + .../Tests/Comparator/NumberComparatorTest.php | 108 + lib/symfony/finder/Tests/FinderTest.php | 752 +++++ lib/symfony/finder/Tests/Fixtures/.dot/a | 0 .../finder/Tests/Fixtures/.dot/b/c.neon | 0 .../finder/Tests/Fixtures/.dot/b/d.neon | 0 .../finder/Tests/Fixtures/A/B/C/abc.dat | 0 lib/symfony/finder/Tests/Fixtures/A/B/ab.dat | 0 lib/symfony/finder/Tests/Fixtures/A/a.dat | 0 .../Tests/Fixtures/copy/A/B/C/abc.dat.copy | 0 .../Tests/Fixtures/copy/A/B/ab.dat.copy | 0 .../finder/Tests/Fixtures/copy/A/a.dat.copy | 0 lib/symfony/finder/Tests/Fixtures/dolor.txt | 2 + lib/symfony/finder/Tests/Fixtures/ipsum.txt | 2 + lib/symfony/finder/Tests/Fixtures/lorem.txt | 2 + lib/symfony/finder/Tests/Fixtures/one/.dot | 1 + lib/symfony/finder/Tests/Fixtures/one/a | 0 .../finder/Tests/Fixtures/one/b/c.neon | 0 .../finder/Tests/Fixtures/one/b/d.neon | 0 .../Fixtures/r+e.gex[c]a(r)s/dir/bar.dat | 0 .../finder/Tests/Fixtures/with space/foo.txt | 0 lib/symfony/finder/Tests/GlobTest.php | 95 + .../Iterator/CustomFilterIteratorTest.php | 44 + .../Iterator/DateRangeFilterIteratorTest.php | 74 + .../Iterator/DepthRangeFilterIteratorTest.php | 83 + .../ExcludeDirectoryFilterIteratorTest.php | 80 + .../Iterator/FileTypeFilterIteratorTest.php | 73 + .../FilecontentFilterIteratorTest.php | 86 + .../Iterator/FilenameFilterIteratorTest.php | 54 + .../Tests/Iterator/FilterIteratorTest.php | 53 + .../finder/Tests/Iterator/Iterator.php | 55 + .../Tests/Iterator/IteratorTestCase.php | 93 + .../Tests/Iterator/MockFileListIterator.php | 21 + .../finder/Tests/Iterator/MockSplFileInfo.php | 132 + .../MultiplePcreFilterIteratorTest.php | 71 + .../Tests/Iterator/PathFilterIteratorTest.php | 82 + .../Tests/Iterator/RealIteratorTestCase.php | 119 + .../RecursiveDirectoryIteratorTest.php | 59 + .../Iterator/SizeRangeFilterIteratorTest.php | 69 + .../Tests/Iterator/SortableIteratorTest.php | 179 ++ .../Test/ForwardCompatTestTrait.php | 82 + .../framework-bundle/Test/KernelTestCase.php | 231 ++ .../framework-bundle/Test/WebTestCase.php | 49 + .../AnnotationsCacheWarmerTest.php | 152 + .../CacheWarmer/ClassCacheCacheWarmerTest.php | 51 + .../CacheWarmer/SerializerCacheWarmerTest.php | 134 + .../Tests/CacheWarmer/TemplateFinderTest.php | 57 + .../TemplatePathsCacheWarmerTest.php | 102 + .../CacheWarmer/ValidatorCacheWarmerTest.php | 155 + .../framework-bundle/Tests/ClientTest.php | 65 + .../CacheClearCommandTest.php | 92 + .../Fixture/TestAppKernel.php | 43 + .../CacheClearCommand/Fixture/config.yml | 2 + .../Tests/Command/CachePruneCommandTest.php | 110 + .../Tests/Command/RouterDebugCommandTest.php | 123 + .../Tests/Command/RouterMatchCommandTest.php | 123 + .../Command/TranslationDebugCommandTest.php | 256 ++ .../Command/TranslationUpdateCommandTest.php | 248 ++ .../Tests/Command/YamlLintCommandTest.php | 182 ++ .../Tests/Console/ApplicationTest.php | 261 ++ .../Descriptor/AbstractDescriptorTest.php | 252 ++ .../Console/Descriptor/JsonDescriptorTest.php | 27 + .../Descriptor/MarkdownDescriptorTest.php | 27 + .../Console/Descriptor/ObjectsProvider.php | 204 ++ .../Console/Descriptor/TextDescriptorTest.php | 37 + .../Console/Descriptor/XmlDescriptorTest.php | 27 + .../Controller/AbstractControllerTest.php | 63 + .../Controller/ControllerNameParserTest.php | 192 ++ .../Controller/ControllerResolverTest.php | 223 ++ .../Tests/Controller/ControllerTest.php | 27 + .../Tests/Controller/ControllerTraitTest.php | 551 ++++ .../Controller/RedirectControllerTest.php | 321 +++ .../Controller/TemplateControllerTest.php | 88 + .../Compiler/AddCacheWarmerPassTest.php | 66 + .../Compiler/AddConsoleCommandPassTest.php | 120 + .../AddConstraintValidatorsPassTest.php | 73 + ...AddExpressionLanguageProvidersPassTest.php | 97 + .../Compiler/CacheCollectorPassTest.php | 49 + .../Compiler/CachePoolClearerPassTest.php | 61 + .../Compiler/CachePoolPassTest.php | 115 + .../Compiler/CachePoolPrunerPassTest.php | 70 + .../Compiler/ConfigCachePassTest.php | 59 + ...ontrollerArgumentValueResolverPassTest.php | 70 + .../DataCollectorTranslatorPassTest.php | 126 + .../Compiler/FormPassTest.php | 213 ++ .../Compiler/LoggingTranslatorPassTest.php | 81 + .../Compiler/ProfilerPassTest.php | 57 + .../Compiler/PropertyInfoPassTest.php | 72 + .../Compiler/SerializerPassTest.php | 73 + .../Compiler/TranslatorPassTest.php | 53 + .../Compiler/UnusedTagsPassTest.php | 34 + .../WorkflowGuardListenerPassTest.php | 102 + .../DependencyInjection/ConfigurationTest.php | 496 ++++ .../Resources/config/validation.xml | 0 .../Resources/config/validation.yml | 0 .../CustomPathBundle/src/CustomPathBundle.php | 22 + .../Resources/config/serialization.xml | 0 .../Resources/config/serialization.yml | 0 .../config/serializer_mapping/files/foo.xml | 0 .../config/serializer_mapping/files/foo.yml | 0 .../serializer_mapping/serialization.yaml | 0 .../serializer_mapping/serialization.yml | 0 .../Resources/config/validation.xml | 0 .../Resources/config/validation.yml | 0 .../config/validation_mapping/files/foo.xml | 0 .../config/validation_mapping/files/foo.yml | 0 .../config/validation_mapping/validation.yaml | 0 .../config/validation_mapping/validation.yml | 0 .../Fixtures/TestBundle/TestBundle.php | 18 + .../Fixtures/php/assets.php | 32 + .../Fixtures/php/assets_disabled.php | 7 + .../assets_version_strategy_as_service.php | 8 + .../Fixtures/php/cache.php | 29 + .../Fixtures/php/cache_env_var.php | 9 + .../DependencyInjection/Fixtures/php/csrf.php | 9 + .../Fixtures/php/csrf_needs_session.php | 7 + .../Fixtures/php/default_config.php | 3 + .../php/esi_and_ssi_without_fragments.php | 13 + .../Fixtures/php/esi_disabled.php | 7 + .../Fixtures/php/form_no_csrf.php | 9 + .../DependencyInjection/Fixtures/php/full.php | 84 + .../Fixtures/php/php_errors_disabled.php | 8 + .../Fixtures/php/php_errors_enabled.php | 8 + .../Fixtures/php/profiler.php | 7 + .../Fixtures/php/property_accessor.php | 8 + .../Fixtures/php/property_info.php | 7 + .../Fixtures/php/request.php | 7 + .../Fixtures/php/serializer_disabled.php | 7 + .../Fixtures/php/serializer_enabled.php | 7 + .../Fixtures/php/serializer_legacy_cache.php | 8 + .../Fixtures/php/serializer_mapping.php | 15 + .../Fixtures/php/session.php | 7 + .../Fixtures/php/ssi_disabled.php | 7 + .../Fixtures/php/templating_disabled.php | 5 + .../Fixtures/php/templating_no_assets.php | 7 + .../php/templating_php_assets_disabled.php | 8 + .../templating_php_translator_disabled.php | 8 + .../php/templating_php_translator_enabled.php | 8 + .../Fixtures/php/translator_fallbacks.php | 7 + .../Fixtures/php/validation_annotations.php | 9 + .../Fixtures/php/validation_mapping.php | 13 + .../validation_multiple_static_methods.php | 9 + .../php/validation_no_static_method.php | 9 + .../Fixtures/php/validation_strict_email.php | 7 + .../php/validation_translation_domain.php | 7 + .../Fixtures/php/web_link.php | 5 + .../workflow_with_arguments_and_service.php | 31 + .../php/workflow_with_guard_expression.php | 51 + ...th_multiple_transitions_with_same_name.php | 49 + ...flow_with_support_and_support_strategy.php | 31 + .../php/workflow_with_type_and_service.php | 31 + ...w_without_support_and_support_strategy.php | 27 + .../Fixtures/php/workflows.php | 111 + .../Fixtures/php/workflows_enabled.php | 5 + .../php/workflows_explicitly_enabled.php | 19 + ...ows_explicitly_enabled_named_workflows.php | 19 + .../Fixtures/php/workflows_without_type.php | 26 + .../Fixtures/translations/test_paths.en.yml | 2 + .../Fixtures/xml/assets.xml | 27 + .../Fixtures/xml/assets_disabled.xml | 12 + .../assets_version_strategy_as_service.xml | 14 + .../Fixtures/xml/cache.xml | 17 + .../Fixtures/xml/cache_env_var.xml | 17 + .../DependencyInjection/Fixtures/xml/csrf.xml | 14 + .../Fixtures/xml/csrf_disabled.xml | 12 + .../Fixtures/xml/csrf_needs_session.xml | 12 + .../Fixtures/xml/default_config.xml | 9 + .../xml/esi_and_ssi_without_fragments.xml | 13 + .../Fixtures/xml/esi_disabled.xml | 11 + .../xml/form_csrf_sets_field_name.xml | 14 + .../form_csrf_under_form_sets_field_name.xml | 14 + .../Fixtures/xml/form_no_csrf.xml | 14 + .../DependencyInjection/Fixtures/xml/full.xml | 47 + .../DependencyInjection/Fixtures/xml/lock.xml | 11 + .../Fixtures/xml/lock_named.xml | 22 + .../Fixtures/xml/php_errors_disabled.xml | 11 + .../Fixtures/xml/php_errors_enabled.xml | 11 + .../Fixtures/xml/profiler.xml | 12 + .../Fixtures/xml/property_accessor.xml | 12 + .../Fixtures/xml/property_info.xml | 11 + .../Fixtures/xml/request.xml | 11 + .../Fixtures/xml/serializer_disabled.xml | 11 + .../Fixtures/xml/serializer_enabled.xml | 11 + .../Fixtures/xml/serializer_legacy_cache.xml | 11 + .../Fixtures/xml/serializer_mapping.xml | 17 + .../Fixtures/xml/session.xml | 12 + .../Fixtures/xml/ssi_disabled.xml | 11 + .../Fixtures/xml/templating_disabled.xml | 11 + .../Fixtures/xml/templating_no_assets.xml | 14 + .../templating_php_translator_disabled.xml | 14 + .../xml/templating_php_translator_enabled.xml | 14 + .../Fixtures/xml/translator_fallbacks.xml | 15 + .../Fixtures/xml/validation_annotations.xml | 12 + .../Fixtures/xml/validation_mapping.xml | 16 + .../validation_multiple_static_methods.xml | 15 + .../xml/validation_no_static_method.xml | 12 + .../Fixtures/xml/validation_strict_email.xml | 11 + .../xml/validation_translation_domain.xml | 11 + .../Fixtures/xml/web_link.xml | 12 + .../workflow_with_arguments_and_service.xml | 24 + .../xml/workflow_with_guard_expression.xml | 48 + ...th_multiple_transitions_with_same_name.xml | 46 + ...flow_with_support_and_support_strategy.xml | 21 + .../xml/workflow_with_type_and_service.xml | 21 + ...w_without_support_and_support_strategy.xml | 20 + .../Fixtures/xml/workflows.xml | 94 + .../Fixtures/xml/workflows_enabled.xml | 11 + .../xml/workflows_explicitly_enabled.xml | 19 + ...ows_explicitly_enabled_named_workflows.xml | 19 + .../Fixtures/xml/workflows_without_type.xml | 21 + .../Fixtures/yml/assets.yml | 21 + .../Fixtures/yml/assets_disabled.yml | 3 + .../assets_version_strategy_as_service.yml | 4 + .../Fixtures/yml/cache.yml | 19 + .../Fixtures/yml/cache_env_var.yml | 6 + .../DependencyInjection/Fixtures/yml/csrf.yml | 5 + .../Fixtures/yml/csrf_needs_session.yml | 2 + .../Fixtures/yml/default_config.yml | 1 + .../yml/esi_and_ssi_without_fragments.yml | 7 + .../Fixtures/yml/esi_disabled.yml | 3 + .../Fixtures/yml/form_no_csrf.yml | 4 + .../DependencyInjection/Fixtures/yml/full.yml | 63 + .../DependencyInjection/Fixtures/yml/lock.yml | 2 + .../Fixtures/yml/lock_named.yml | 9 + .../Fixtures/yml/php_errors_disabled.yml | 3 + .../Fixtures/yml/php_errors_enabled.yml | 4 + .../Fixtures/yml/profiler.yml | 3 + .../Fixtures/yml/property_accessor.yml | 4 + .../Fixtures/yml/property_info.yml | 3 + .../Fixtures/yml/request.yml | 3 + .../Fixtures/yml/serializer_disabled.yml | 3 + .../Fixtures/yml/serializer_enabled.yml | 3 + .../Fixtures/yml/serializer_legacy_cache.yml | 4 + .../Fixtures/yml/serializer_mapping.yml | 10 + .../Fixtures/yml/session.yml | 3 + .../Fixtures/yml/ssi_disabled.yml | 3 + .../Fixtures/yml/templating_disabled.yml | 2 + .../Fixtures/yml/templating_no_assets.yml | 3 + .../yml/templating_php_assets_disabled.yml | 4 + .../templating_php_translator_disabled.yml | 4 + .../yml/templating_php_translator_enabled.yml | 4 + .../Fixtures/yml/translator_fallbacks.yml | 3 + .../Fixtures/yml/validation_annotations.yml | 5 + .../Fixtures/yml/validation_mapping.yml | 7 + .../validation_multiple_static_methods.yml | 5 + .../yml/validation_no_static_method.yml | 5 + .../Fixtures/yml/validation_strict_email.yml | 3 + .../yml/validation_translation_domain.yml | 3 + .../Fixtures/yml/web_link.yml | 3 + .../workflow_with_arguments_and_service.yml | 19 + .../yml/workflow_with_guard_expression.yml | 35 + ...th_multiple_transitions_with_same_name.yml | 33 + ...flow_with_support_and_support_strategy.yml | 17 + .../yml/workflow_with_type_and_service.yml | 17 + ...w_without_support_and_support_strategy.yml | 14 + .../Fixtures/yml/workflows.yml | 80 + .../Fixtures/yml/workflows_enabled.yml | 2 + .../yml/workflows_explicitly_enabled.yml | 16 + ...ows_explicitly_enabled_named_workflows.yml | 15 + .../Fixtures/yml/workflows_without_type.yml | 7 + .../FrameworkExtensionTest.php | 1263 ++++++++ .../PhpFrameworkExtensionTest.php | 55 + .../XmlFrameworkExtensionTest.php | 30 + .../YamlFrameworkExtensionTest.php | 25 + .../config/serializer/foo.yml | 0 .../config/validator/foo.xml | 0 .../translations/test_default.en.xlf | 0 .../ResolveControllerNameSubscriberTest.php | 63 + .../Tests/Fixtures/BaseBundle/BaseBundle.php | 18 + .../Resources/views/base.format.engine | 0 .../views/controller/base.format.engine | 0 .../views/this.is.a.template.format.engine | 0 .../Tests/Fixtures/DeclaredClass.php | 7 + .../Tests/Fixtures/Descriptor/alias_1.json | 4 + .../Tests/Fixtures/Descriptor/alias_1.md | 2 + .../Tests/Fixtures/Descriptor/alias_1.txt | 3 + .../Tests/Fixtures/Descriptor/alias_1.xml | 2 + .../Tests/Fixtures/Descriptor/alias_2.json | 4 + .../Tests/Fixtures/Descriptor/alias_2.md | 2 + .../Tests/Fixtures/Descriptor/alias_2.txt | 3 + .../Tests/Fixtures/Descriptor/alias_2.xml | 2 + .../Descriptor/alias_with_definition_1.json | 20 + .../Descriptor/alias_with_definition_1.md | 17 + .../Descriptor/alias_with_definition_1.txt | 21 + .../Descriptor/alias_with_definition_1.xml | 5 + .../Descriptor/alias_with_definition_2.json | 41 + .../Descriptor/alias_with_definition_2.md | 25 + .../Descriptor/alias_with_definition_2.txt | 25 + .../Descriptor/alias_with_definition_2.xml | 18 + .../Fixtures/Descriptor/array_parameter.json | 3 + .../Fixtures/Descriptor/array_parameter.md | 4 + .../Fixtures/Descriptor/array_parameter.txt | 5 + .../Fixtures/Descriptor/array_parameter.xml | 2 + .../Descriptor/builder_1_arguments.json | 80 + .../Descriptor/builder_1_arguments.md | 34 + .../Descriptor/builder_1_arguments.txt | 12 + .../Descriptor/builder_1_arguments.xml | 27 + .../Fixtures/Descriptor/builder_1_public.json | 27 + .../Fixtures/Descriptor/builder_1_public.md | 33 + .../Fixtures/Descriptor/builder_1_public.txt | 12 + .../Fixtures/Descriptor/builder_1_public.xml | 8 + .../Descriptor/builder_1_services.json | 66 + .../Fixtures/Descriptor/builder_1_services.md | 59 + .../Descriptor/builder_1_services.txt | 14 + .../Descriptor/builder_1_services.xml | 25 + .../Fixtures/Descriptor/builder_1_tag1.json | 41 + .../Fixtures/Descriptor/builder_1_tag1.md | 26 + .../Fixtures/Descriptor/builder_1_tag1.txt | 11 + .../Fixtures/Descriptor/builder_1_tag1.xml | 19 + .../Fixtures/Descriptor/builder_1_tags.json | 38 + .../Fixtures/Descriptor/builder_1_tags.md | 39 + .../Fixtures/Descriptor/builder_1_tags.txt | 14 + .../Fixtures/Descriptor/builder_1_tags.xml | 19 + .../Tests/Fixtures/Descriptor/callable_1.json | 4 + .../Tests/Fixtures/Descriptor/callable_1.md | 3 + .../Tests/Fixtures/Descriptor/callable_1.txt | 1 + .../Tests/Fixtures/Descriptor/callable_1.xml | 2 + .../Tests/Fixtures/Descriptor/callable_2.json | 6 + .../Tests/Fixtures/Descriptor/callable_2.md | 5 + .../Tests/Fixtures/Descriptor/callable_2.txt | 1 + .../Tests/Fixtures/Descriptor/callable_2.xml | 2 + .../Tests/Fixtures/Descriptor/callable_3.json | 5 + .../Tests/Fixtures/Descriptor/callable_3.md | 4 + .../Tests/Fixtures/Descriptor/callable_3.txt | 1 + .../Tests/Fixtures/Descriptor/callable_3.xml | 2 + .../Tests/Fixtures/Descriptor/callable_4.json | 6 + .../Tests/Fixtures/Descriptor/callable_4.md | 5 + .../Tests/Fixtures/Descriptor/callable_4.txt | 1 + .../Tests/Fixtures/Descriptor/callable_4.xml | 2 + .../Tests/Fixtures/Descriptor/callable_5.json | 7 + .../Tests/Fixtures/Descriptor/callable_5.md | 6 + .../Tests/Fixtures/Descriptor/callable_5.txt | 1 + .../Tests/Fixtures/Descriptor/callable_5.xml | 2 + .../Tests/Fixtures/Descriptor/callable_6.json | 3 + .../Tests/Fixtures/Descriptor/callable_6.md | 2 + .../Tests/Fixtures/Descriptor/callable_6.txt | 1 + .../Tests/Fixtures/Descriptor/callable_6.xml | 2 + .../Tests/Fixtures/Descriptor/callable_7.json | 4 + .../Tests/Fixtures/Descriptor/callable_7.md | 3 + .../Tests/Fixtures/Descriptor/callable_7.txt | 1 + .../Tests/Fixtures/Descriptor/callable_7.xml | 2 + .../Descriptor/callable_from_callable.json | 5 + .../Descriptor/callable_from_callable.md | 4 + .../Descriptor/callable_from_callable.txt | 1 + .../Descriptor/callable_from_callable.xml | 2 + .../Fixtures/Descriptor/definition_1.json | 14 + .../Tests/Fixtures/Descriptor/definition_1.md | 10 + .../Fixtures/Descriptor/definition_1.txt | 17 + .../Fixtures/Descriptor/definition_1.xml | 4 + .../Fixtures/Descriptor/definition_2.json | 35 + .../Tests/Fixtures/Descriptor/definition_2.md | 18 + .../Fixtures/Descriptor/definition_2.txt | 21 + .../Fixtures/Descriptor/definition_2.xml | 17 + .../Descriptor/definition_arguments_1.json | 67 + .../Descriptor/definition_arguments_1.md | 11 + .../Descriptor/definition_arguments_1.txt | 22 + .../Descriptor/definition_arguments_1.xml | 23 + .../Descriptor/definition_arguments_2.json | 36 + .../Descriptor/definition_arguments_2.md | 19 + .../Descriptor/definition_arguments_2.txt | 21 + .../Descriptor/definition_arguments_2.xml | 17 + .../Descriptor/event_dispatcher_1_event1.json | 11 + .../Descriptor/event_dispatcher_1_event1.md | 12 + .../Descriptor/event_dispatcher_1_event1.txt | 11 + .../Descriptor/event_dispatcher_1_event1.xml | 5 + .../Descriptor/event_dispatcher_1_events.json | 20 + .../Descriptor/event_dispatcher_1_events.md | 22 + .../Descriptor/event_dispatcher_1_events.txt | 23 + .../Descriptor/event_dispatcher_1_events.xml | 10 + .../Tests/Fixtures/Descriptor/parameter.json | 3 + .../Tests/Fixtures/Descriptor/parameter.md | 4 + .../Tests/Fixtures/Descriptor/parameter.txt | 6 + .../Tests/Fixtures/Descriptor/parameter.xml | 2 + .../Fixtures/Descriptor/parameters_1.json | 10 + .../Tests/Fixtures/Descriptor/parameters_1.md | 7 + .../Fixtures/Descriptor/parameters_1.txt | 13 + .../Fixtures/Descriptor/parameters_1.xml | 7 + .../Tests/Fixtures/Descriptor/route_1.json | 20 + .../Tests/Fixtures/Descriptor/route_1.md | 15 + .../Tests/Fixtures/Descriptor/route_1.txt | 17 + .../Tests/Fixtures/Descriptor/route_1.xml | 20 + .../Tests/Fixtures/Descriptor/route_2.json | 16 + .../Tests/Fixtures/Descriptor/route_2.md | 13 + .../Tests/Fixtures/Descriptor/route_2.txt | 17 + .../Tests/Fixtures/Descriptor/route_2.xml | 14 + .../Descriptor/route_collection_1.json | 38 + .../Fixtures/Descriptor/route_collection_1.md | 37 + .../Descriptor/route_collection_1.txt | 7 + .../Descriptor/route_collection_1.xml | 35 + .../BaseBundle/views/base.format.engine | 0 .../views/controller/custom.format.engine | 0 .../Resources/translations/messages.fr.yml | 1 + .../Resources/views/resource.format.engine | 0 .../views/this.is.a.template.format.engine | 0 .../Resources/views/translation.html.php | 49 + .../Tests/Fixtures/Serialization/Author.php | 8 + .../Tests/Fixtures/Serialization/Person.php | 8 + .../Serialization/Resources/author.yml | 4 + .../Resources/does_not_exist.yaml | 1 + .../Serialization/Resources/person.xml | 13 + .../TemplatePathsCache/templates-empty.php | 2 + .../Fixtures/TemplatePathsCache/templates.php | 3 + .../Controller/DefaultController.php | 21 + .../Fabpot/FooBundle/FabpotFooBundle.php | 30 + .../Controller/DefaultController.php | 21 + .../Controller/Sub/DefaultController.php | 21 + .../Controller/Test/DefaultController.php | 21 + .../TestBundle/FooBundle/FooBundle.php | 23 + .../Controller/DefaultController.php | 21 + .../Cms/FooBundle/SensioCmsFooBundle.php | 23 + .../Controller/DefaultController.php | 21 + .../Sensio/FooBundle/SensioFooBundle.php | 23 + .../Tests/Fixtures/Validation/Article.php | 8 + .../Tests/Fixtures/Validation/Author.php | 8 + .../Tests/Fixtures/Validation/Category.php | 17 + .../Tests/Fixtures/Validation/Person.php | 8 + .../Fixtures/Validation/Resources/author.yml | 4 + .../Validation/Resources/categories.yml | 9 + .../Validation/Resources/does_not_exist.yaml | 1 + .../Fixtures/Validation/Resources/person.xml | 29 + .../Tests/Fixtures/Validation/SubCategory.php | 13 + .../Tests/Fixtures/WarmedClass.php | 7 + .../Tests/Fixtures/templates.php | 5 + .../Tests/Functional/AbstractWebTestCase.php | 73 + .../Functional/AnnotatedControllerTest.php | 39 + .../Tests/Functional/AutowiringTypesTest.php | 86 + .../AutowiringTypes/AutowiredServices.php | 61 + .../Controller/AnnotatedController.php | 51 + .../Controller/FragmentController.php | 57 + .../Controller/ProfilerController.php | 26 + .../Controller/SessionController.php | 81 + .../Controller/SubRequestController.php | 66 + .../SubRequestServiceResolutionController.php | 38 + .../AnnotationReaderPass.php | 24 + .../Config/CustomConfig.php | 31 + .../DependencyInjection/Configuration.php | 37 + .../DependencyInjection/TestExtension.php | 54 + .../TestBundle/Resources/config/routing.yml | 54 + .../Bundle/TestBundle/TestBundle.php | 33 + .../Functional/CachePoolClearCommandTest.php | 100 + .../Tests/Functional/CachePoolsTest.php | 103 + .../Functional/ConfigDebugCommandTest.php | 78 + .../ConfigDumpReferenceCommandTest.php | 85 + .../Functional/ContainerDebugCommandTest.php | 66 + .../Tests/Functional/ContainerDumpTest.php | 32 + .../Functional/DebugAutowiringCommandTest.php | 63 + .../Tests/Functional/FragmentTest.php | 38 + .../Tests/Functional/ProfilerTest.php | 46 + .../Tests/Functional/PropertyInfoTest.php | 35 + .../Tests/Functional/SerializerTest.php | 52 + .../Tests/Functional/SessionTest.php | 153 + .../Tests/Functional/SubRequestsTest.php | 31 + .../app/AnnotatedController/bundles.php | 18 + .../app/AnnotatedController/config.yml | 2 + .../app/AnnotatedController/routing.yml | 4 + .../Tests/Functional/app/AppKernel.php | 100 + .../app/AutowiringTypes/bundles.php | 18 + .../Functional/app/AutowiringTypes/config.yml | 11 + .../AutowiringTypes/no_annotations_cache.yml | 6 + .../Functional/app/CachePoolClear/bundles.php | 18 + .../Functional/app/CachePoolClear/config.yml | 22 + .../Functional/app/CachePools/bundles.php | 18 + .../Functional/app/CachePools/config.yml | 14 + .../app/CachePools/redis_config.yml | 17 + .../app/CachePools/redis_custom_config.yml | 28 + .../Functional/app/ConfigDump/bundles.php | 18 + .../Functional/app/ConfigDump/config.yml | 10 + .../Functional/app/ContainerDebug/bundles.php | 18 + .../Functional/app/ContainerDebug/config.yml | 10 + .../Functional/app/ContainerDump/bundles.php | 18 + .../Functional/app/ContainerDump/config.yml | 21 + .../ControllerServiceResolution/bundles.php | 18 + .../ControllerServiceResolution/config.yml | 10 + .../ControllerServiceResolution/routing.yml | 4 + .../Tests/Functional/app/Fragment/bundles.php | 18 + .../Tests/Functional/app/Fragment/config.yml | 7 + .../Tests/Functional/app/Fragment/routing.yml | 2 + .../Tests/Functional/app/Profiler/bundles.php | 18 + .../Tests/Functional/app/Profiler/config.yml | 7 + .../Tests/Functional/app/Profiler/routing.yml | 2 + .../app/Resources/views/fragment.html.php | 14 + .../Functional/app/Serializer/bundles.php | 16 + .../Functional/app/Serializer/config.yml | 10 + .../Tests/Functional/app/Session/bundles.php | 18 + .../Tests/Functional/app/Session/config.yml | 7 + .../Tests/Functional/app/Session/routing.yml | 2 + .../Tests/Functional/app/config/default.yml | 2 + .../Tests/Functional/app/config/framework.yml | 13 + .../Tests/Kernel/ConcreteMicroKernel.php | 113 + .../Tests/Kernel/MicroKernelTraitTest.php | 42 + .../Tests/Routing/DelegatingLoaderTest.php | 20 + .../Routing/RedirectableUrlMatcherTest.php | 61 + .../Tests/Routing/RouterTest.php | 275 ++ .../Tests/Templating/DelegatingEngineTest.php | 123 + .../Tests/Templating/GlobalVariablesTest.php | 106 + .../Templating/Helper/AssetsHelperTest.php | 45 + .../Fixtures/StubTemplateNameParser.php | 43 + .../Helper/Fixtures/StubTranslator.php | 35 + .../Helper/FormHelperDivLayoutTest.php | 157 + .../Helper/FormHelperTableLayoutTest.php | 132 + .../Templating/Helper/RequestHelperTest.php | 54 + .../Resources/Child/form_label.html.php | 1 + .../Custom/_name_c_entry_label.html.php | 2 + .../Custom/_names_entry_label.html.php | 4 + .../Resources/Custom/_text_id_widget.html.php | 3 + .../Resources/Parent/form_label.html.php | 1 + .../Parent/form_widget_simple.html.php | 2 + .../Templating/Helper/SessionHelperTest.php | 75 + .../Templating/Helper/StopwatchHelperTest.php | 39 + .../Templating/Loader/TemplateLocatorTest.php | 96 + .../Tests/Templating/PhpEngineTest.php | 74 + .../Templating/TemplateFilenameParserTest.php | 56 + .../Templating/TemplateNameParserTest.php | 107 + .../Templating/TemplateReferenceTest.php | 28 + .../Tests/Templating/TemplateTest.php | 36 + .../Tests/Templating/TimedPhpEngineTest.php | 116 + .../framework-bundle/Tests/TestCase.php | 18 + .../Tests/Translation/PhpExtractorTest.php | 98 + .../Tests/Translation/TranslatorTest.php | 492 ++++ .../ConstraintValidatorFactoryTest.php | 97 + .../Tests/AcceptHeaderItemTest.php | 113 + .../Tests/AcceptHeaderTest.php | 103 + .../Tests/ApacheRequestTest.php | 93 + .../Tests/BinaryFileResponseTest.php | 364 +++ .../http-foundation/Tests/CookieTest.php | 246 ++ .../Tests/ExpressionRequestMatcherTest.php | 67 + .../http-foundation/Tests/File/FakeFile.php | 45 + .../http-foundation/Tests/File/FileTest.php | 180 ++ .../http-foundation/Tests/File/Fixtures/-test | Bin 0 -> 35 bytes .../Tests/File/Fixtures/.unknownextension | 1 + .../Fixtures/case-sensitive-mime-type.xlsm | Bin 0 -> 4791 bytes .../Tests/File/Fixtures/directory/.empty | 0 .../Tests/File/Fixtures/other-file.example | 0 .../http-foundation/Tests/File/Fixtures/test | Bin 0 -> 35 bytes .../Tests/File/Fixtures/test.gif | Bin 0 -> 35 bytes .../Tests/File/MimeType/MimeTypeTest.php | 99 + .../Tests/File/UploadedFileTest.php | 298 ++ .../http-foundation/Tests/FileBagTest.php | 173 ++ .../Fixtures/response-functional/common.inc | 43 + .../cookie_max_age.expected | 11 + .../response-functional/cookie_max_age.php | 10 + .../cookie_raw_urlencode.expected | 10 + .../cookie_raw_urlencode.php | 12 + .../cookie_samesite_lax.expected | 9 + .../cookie_samesite_lax.php | 8 + .../cookie_samesite_strict.expected | 9 + .../cookie_samesite_strict.php | 8 + .../cookie_urlencode.expected | 11 + .../response-functional/cookie_urlencode.php | 15 + .../invalid_cookie_name.expected | 6 + .../invalid_cookie_name.php | 11 + .../http-foundation/Tests/HeaderBagTest.php | 213 ++ .../http-foundation/Tests/IpUtilsTest.php | 104 + .../Tests/JsonResponseTest.php | 262 ++ .../Tests/ParameterBagTest.php | 194 ++ .../Tests/RedirectResponseTest.php | 92 + .../Tests/RequestMatcherTest.php | 151 + .../Tests/RequestStackTest.php | 70 + .../http-foundation/Tests/RequestTest.php | 2451 ++++++++++++++++ .../Tests/ResponseFunctionalTest.php | 58 + .../Tests/ResponseHeaderBagTest.php | 359 +++ .../http-foundation/Tests/ResponseTest.php | 1008 +++++++ .../Tests/ResponseTestCase.php | 89 + .../http-foundation/Tests/ServerBagTest.php | 170 ++ .../Session/Attribute/AttributeBagTest.php | 186 ++ .../Attribute/NamespacedAttributeBagTest.php | 204 ++ .../Session/Flash/AutoExpireFlashBagTest.php | 161 ++ .../Tests/Session/Flash/FlashBagTest.php | 157 + .../Tests/Session/SessionTest.php | 288 ++ .../Handler/AbstractSessionHandlerTest.php | 61 + .../Storage/Handler/Fixtures/common.inc | 151 + .../Handler/Fixtures/empty_destroys.expected | 17 + .../Handler/Fixtures/empty_destroys.php | 8 + .../Handler/Fixtures/read_only.expected | 14 + .../Storage/Handler/Fixtures/read_only.php | 8 + .../Handler/Fixtures/regenerate.expected | 24 + .../Storage/Handler/Fixtures/regenerate.php | 10 + .../Storage/Handler/Fixtures/storage.expected | 20 + .../Storage/Handler/Fixtures/storage.php | 24 + .../Handler/Fixtures/with_cookie.expected | 15 + .../Storage/Handler/Fixtures/with_cookie.php | 8 + .../Fixtures/with_cookie_and_session.expected | 24 + .../Fixtures/with_cookie_and_session.php | 13 + .../Handler/MemcacheSessionHandlerTest.php | 135 + .../Handler/MemcachedSessionHandlerTest.php | 145 + .../Handler/MongoDbSessionHandlerTest.php | 330 +++ .../Handler/NativeFileSessionHandlerTest.php | 75 + .../Handler/NativeSessionHandlerTest.php | 38 + .../Handler/NullSessionHandlerTest.php | 59 + .../Storage/Handler/PdoSessionHandlerTest.php | 405 +++ .../Handler/StrictSessionHandlerTest.php | 189 ++ .../Handler/WriteCheckSessionHandlerTest.php | 97 + .../Tests/Session/Storage/MetadataBagTest.php | 139 + .../Storage/MockArraySessionStorageTest.php | 129 + .../Storage/MockFileSessionStorageTest.php | 125 + .../Storage/NativeSessionStorageTest.php | 288 ++ .../Storage/PhpBridgeSessionStorageTest.php | 96 + .../Storage/Proxy/AbstractProxyTest.php | 113 + .../Session/Storage/Proxy/NativeProxyTest.php | 38 + .../Storage/Proxy/SessionHandlerProxyTest.php | 158 + .../Tests/StreamedResponseTest.php | 140 + .../Tests/schema/http-status-codes.rng | 31 + .../Tests/schema/iana-registry.rng | 198 ++ .../http-kernel/Tests/Bundle/BundleTest.php | 105 + .../CacheClearer/ChainCacheClearerTest.php | 61 + .../CacheClearer/Psr6CacheClearerTest.php | 67 + .../CacheWarmer/CacheWarmerAggregateTest.php | 107 + .../Tests/CacheWarmer/CacheWarmerTest.php | 66 + lib/symfony/http-kernel/Tests/ClientTest.php | 179 ++ .../Config/EnvParametersResourceTest.php | 110 + .../Tests/Config/FileLocatorTest.php | 48 + .../ServiceValueResolverTest.php | 130 + .../Tests/Controller/ArgumentResolverTest.php | 341 +++ .../ContainerControllerResolverTest.php | 298 ++ .../Controller/ControllerResolverTest.php | 325 +++ .../ArgumentMetadataFactoryTest.php | 148 + .../ArgumentMetadataTest.php | 44 + .../Tests/DataCollector/Compiler.log | 4 + .../DataCollector/ConfigDataCollectorTest.php | 66 + .../Tests/DataCollector/DataCollectorTest.php | 38 + .../DataCollector/DumpDataCollectorTest.php | 135 + .../ExceptionDataCollectorTest.php | 59 + .../DataCollector/LoggerDataCollectorTest.php | 144 + .../DataCollector/MemoryDataCollectorTest.php | 59 + .../RequestDataCollectorTest.php | 334 +++ .../DataCollector/TimeDataCollectorTest.php | 57 + .../DataCollector/Util/ValueExporterTest.php | 51 + .../Tests/Debug/FileLinkFormatterTest.php | 66 + .../Debug/TraceableEventDispatcherTest.php | 119 + .../AddAnnotatedClassesToCachePassTest.php | 99 + ...ontrollerArgumentValueResolverPassTest.php | 67 + .../FragmentRendererPassTest.php | 70 + .../LazyLoadingFragmentHandlerTest.php | 66 + .../DependencyInjection/LoggerPassTest.php | 56 + .../MergeExtensionConfigurationPassTest.php | 50 + ...sterControllerArgumentLocatorsPassTest.php | 397 +++ ...mptyControllerArgumentLocatorsPassTest.php | 148 + .../ResettableServicePassTest.php | 76 + .../ServicesResetterTest.php | 42 + .../FilterControllerArgumentsEventTest.php | 17 + .../GetResponseForExceptionEventTest.php | 27 + .../AddRequestFormatsListenerTest.php | 84 + .../DebugHandlersListenerTest.php | 155 + .../Tests/EventListener/DumpListenerTest.php | 81 + .../EventListener/ExceptionListenerTest.php | 178 ++ .../EventListener/FragmentListenerTest.php | 118 + .../EventListener/LocaleListenerTest.php | 102 + .../EventListener/ProfilerListenerTest.php | 70 + .../EventListener/ResponseListenerTest.php | 95 + .../EventListener/RouterListenerTest.php | 222 ++ .../EventListener/SaveSessionListenerTest.php | 49 + .../EventListener/SessionListenerTest.php | 121 + .../EventListener/SurrogateListenerTest.php | 67 + .../EventListener/TestSessionListenerTest.php | 221 ++ .../EventListener/TranslatorListenerTest.php | 118 + .../ValidateRequestListenerTest.php | 46 + .../AccessDeniedHttpExceptionTest.php | 13 + .../Exception/BadRequestHttpExceptionTest.php | 13 + .../Exception/ConflictHttpExceptionTest.php | 13 + .../Tests/Exception/GoneHttpExceptionTest.php | 13 + .../Tests/Exception/HttpExceptionTest.php | 53 + .../LengthRequiredHttpExceptionTest.php | 13 + .../MethodNotAllowedHttpExceptionTest.php | 24 + .../NotAcceptableHttpExceptionTest.php | 13 + .../Exception/NotFoundHttpExceptionTest.php | 13 + .../PreconditionFailedHttpExceptionTest.php | 13 + .../PreconditionRequiredHttpExceptionTest.php | 13 + .../ServiceUnavailableHttpExceptionTest.php | 29 + .../TooManyRequestsHttpExceptionTest.php | 29 + .../UnauthorizedHttpExceptionTest.php | 24 + .../UnprocessableEntityHttpExceptionTest.php | 13 + .../UnsupportedMediaTypeHttpExceptionTest.php | 13 + .../Tests/Fixtures/123/Kernel123.php | 37 + .../Fixtures/BaseBundle/Resources/foo.txt | 0 .../Fixtures/BaseBundle/Resources/hide.txt | 0 .../Fixtures/Bundle1Bundle/Resources/foo.txt | 0 .../Tests/Fixtures/Bundle1Bundle/bar.txt | 0 .../Tests/Fixtures/Bundle1Bundle/foo.txt | 0 .../Tests/Fixtures/Bundle2Bundle/foo.txt | 0 .../Fixtures/ChildBundle/Resources/foo.txt | 0 .../Fixtures/ChildBundle/Resources/hide.txt | 0 .../Tests/Fixtures/ClearableService.php | 13 + .../Controller/BasicTypesController.php | 19 + .../Fixtures/Controller/ExtendingRequest.php | 18 + .../Fixtures/Controller/ExtendingSession.php | 18 + .../Controller/NullableController.php | 19 + .../Controller/VariadicController.php | 19 + .../DataCollector/CloneVarDataCollector.php | 46 + .../ExtensionAbsentBundle.php | 18 + .../ExtensionNotValidExtension.php | 20 + .../ExtensionNotValidBundle.php | 18 + .../Command/FooCommand.php | 22 + .../ExtensionPresentExtension.php | 22 + .../ExtensionPresentBundle.php | 18 + .../Tests/Fixtures/KernelForOverrideName.php | 28 + .../Tests/Fixtures/KernelForTest.php | 42 + .../Tests/Fixtures/KernelWithoutBundles.php | 33 + .../Tests/Fixtures/ResettableService.php | 13 + .../Fixtures/Resources/BaseBundle/hide.txt | 0 .../Fixtures/Resources/Bundle1Bundle/foo.txt | 0 .../Fixtures/Resources/ChildBundle/foo.txt | 0 .../Fixtures/Resources/FooBundle/foo.txt | 0 .../http-kernel/Tests/Fixtures/TestClient.php | 31 + .../Fragment/EsiFragmentRendererTest.php | 114 + .../Tests/Fragment/FragmentHandlerTest.php | 93 + .../Fragment/HIncludeFragmentRendererTest.php | 100 + .../Fragment/InlineFragmentRendererTest.php | 318 ++ .../Fragment/RoutableFragmentRendererTest.php | 94 + .../Fragment/SsiFragmentRendererTest.php | 93 + .../http-kernel/Tests/HttpCache/EsiTest.php | 244 ++ .../Tests/HttpCache/HttpCacheTest.php | 1526 ++++++++++ .../Tests/HttpCache/HttpCacheTestCase.php | 185 ++ .../HttpCache/ResponseCacheStrategyTest.php | 469 +++ .../http-kernel/Tests/HttpCache/SsiTest.php | 211 ++ .../http-kernel/Tests/HttpCache/StoreTest.php | 301 ++ .../Tests/HttpCache/SubRequestHandlerTest.php | 153 + .../Tests/HttpCache/TestHttpKernel.php | 102 + .../HttpCache/TestMultipleHttpKernel.php | 81 + .../http-kernel/Tests/HttpKernelTest.php | 395 +++ lib/symfony/http-kernel/Tests/KernelTest.php | 1073 +++++++ .../http-kernel/Tests/Log/LoggerTest.php | 206 ++ lib/symfony/http-kernel/Tests/Logger.php | 91 + .../Profiler/FileProfilerStorageTest.php | 350 +++ .../Tests/Profiler/ProfilerTest.php | 105 + .../http-kernel/Tests/TestHttpKernel.php | 42 + .../http-kernel/Tests/UriSignerTest.php | 76 + .../routing/Tests/Annotation/RouteTest.php | 48 + .../routing/Tests/CompiledRouteTest.php | 27 + .../RoutingResolverPassTest.php | 36 + .../AnnotatedClasses/AbstractClass.php | 21 + .../Fixtures/AnnotatedClasses/BarClass.php | 19 + .../Fixtures/AnnotatedClasses/BazClass.php | 19 + .../AnnotatedClasses/EncodingClass.php | 10 + .../Fixtures/AnnotatedClasses/FooClass.php | 16 + .../Fixtures/AnnotatedClasses/FooTrait.php | 13 + .../Tests/Fixtures/CustomCompiledRoute.php | 18 + .../Tests/Fixtures/CustomRouteCompiler.php | 26 + .../Tests/Fixtures/CustomXmlFileLoader.php | 26 + .../AnonymousClassInTrait.php | 24 + .../OtherAnnotatedClasses/NoStartTagClass.php | 3 + .../OtherAnnotatedClasses/VariadicClass.php | 19 + .../Tests/Fixtures/RedirectableUrlMatcher.php | 30 + .../routing/Tests/Fixtures/annotated.php | 0 .../routing/Tests/Fixtures/bad_format.yml | 3 + lib/symfony/routing/Tests/Fixtures/bar.xml | 0 .../controller/import__controller.xml | 10 + .../controller/import__controller.yml | 4 + .../Fixtures/controller/import_controller.xml | 8 + .../Fixtures/controller/import_controller.yml | 3 + .../controller/import_override_defaults.xml | 10 + .../controller/import_override_defaults.yml | 5 + .../Fixtures/controller/override_defaults.xml | 10 + .../Fixtures/controller/override_defaults.yml | 5 + .../Tests/Fixtures/controller/routing.xml | 14 + .../Tests/Fixtures/controller/routing.yml | 11 + .../Fixtures/directory/recurse/routes1.yml | 2 + .../Fixtures/directory/recurse/routes2.yml | 2 + .../Tests/Fixtures/directory/routes3.yml | 2 + .../Fixtures/directory_import/import.yml | 3 + .../Tests/Fixtures/dumper/url_matcher0.php | 37 + .../Tests/Fixtures/dumper/url_matcher1.php | 318 ++ .../Tests/Fixtures/dumper/url_matcher2.php | 380 +++ .../Tests/Fixtures/dumper/url_matcher3.php | 55 + .../Tests/Fixtures/dumper/url_matcher4.php | 112 + .../Tests/Fixtures/dumper/url_matcher5.php | 209 ++ .../Tests/Fixtures/dumper/url_matcher6.php | 213 ++ .../Tests/Fixtures/dumper/url_matcher7.php | 249 ++ lib/symfony/routing/Tests/Fixtures/empty.yml | 0 .../routing/Tests/Fixtures/file_resource.yml | 0 lib/symfony/routing/Tests/Fixtures/foo.xml | 0 lib/symfony/routing/Tests/Fixtures/foo1.xml | 0 .../routing/Tests/Fixtures/glob/bar.xml | 8 + .../routing/Tests/Fixtures/glob/bar.yml | 4 + .../routing/Tests/Fixtures/glob/baz.xml | 8 + .../routing/Tests/Fixtures/glob/baz.yml | 4 + .../Tests/Fixtures/glob/import_multiple.xml | 8 + .../Tests/Fixtures/glob/import_multiple.yml | 2 + .../Tests/Fixtures/glob/import_single.xml | 8 + .../Tests/Fixtures/glob/import_single.yml | 2 + .../routing/Tests/Fixtures/glob/php_dsl.php | 7 + .../Tests/Fixtures/glob/php_dsl_bar.php | 12 + .../Tests/Fixtures/glob/php_dsl_baz.php | 12 + .../routing/Tests/Fixtures/incomplete.yml | 2 + .../routing/Tests/Fixtures/list_defaults.xml | 20 + .../Tests/Fixtures/list_in_list_defaults.xml | 22 + .../Tests/Fixtures/list_in_map_defaults.xml | 22 + .../Tests/Fixtures/list_null_values.xml | 22 + .../routing/Tests/Fixtures/localized/utf8.xml | 13 + .../routing/Tests/Fixtures/map_defaults.xml | 20 + .../Tests/Fixtures/map_in_list_defaults.xml | 22 + .../Tests/Fixtures/map_in_map_defaults.xml | 22 + .../Tests/Fixtures/map_null_values.xml | 22 + .../routing/Tests/Fixtures/missing_id.xml | 8 + .../routing/Tests/Fixtures/missing_path.xml | 8 + .../Tests/Fixtures/namespaceprefix.xml | 16 + .../Fixtures/nonesense_resource_plus_path.yml | 3 + .../nonesense_type_without_resource.yml | 3 + .../routing/Tests/Fixtures/nonvalid.xml | 10 + .../routing/Tests/Fixtures/nonvalid.yml | 1 + .../routing/Tests/Fixtures/nonvalid2.yml | 1 + .../routing/Tests/Fixtures/nonvalidkeys.yml | 3 + .../routing/Tests/Fixtures/nonvalidnode.xml | 8 + .../routing/Tests/Fixtures/nonvalidroute.xml | 12 + .../routing/Tests/Fixtures/null_values.xml | 12 + .../routing/Tests/Fixtures/php_dsl.php | 22 + .../routing/Tests/Fixtures/php_dsl_sub.php | 14 + .../Tests/Fixtures/scalar_defaults.xml | 33 + .../Tests/Fixtures/special_route_name.yml | 2 + .../routing/Tests/Fixtures/validpattern.php | 18 + .../routing/Tests/Fixtures/validpattern.xml | 15 + .../routing/Tests/Fixtures/validpattern.yml | 13 + .../routing/Tests/Fixtures/validresource.php | 18 + .../routing/Tests/Fixtures/validresource.xml | 13 + .../routing/Tests/Fixtures/validresource.yml | 8 + .../Fixtures/with_define_path_variable.php | 5 + .../routing/Tests/Fixtures/withdoctype.xml | 3 + .../Dumper/PhpGeneratorDumperTest.php | 177 ++ .../Tests/Generator/UrlGeneratorTest.php | 747 +++++ .../Loader/AbstractAnnotationLoaderTest.php | 33 + .../Loader/AnnotationClassLoaderTest.php | 348 +++ .../Loader/AnnotationDirectoryLoaderTest.php | 110 + .../Tests/Loader/AnnotationFileLoaderTest.php | 94 + .../Tests/Loader/ClosureLoaderTest.php | 49 + .../Tests/Loader/DirectoryLoaderTest.php | 74 + .../Tests/Loader/GlobFileLoaderTest.php | 45 + .../Tests/Loader/ObjectRouteLoaderTest.php | 117 + .../Tests/Loader/PhpFileLoaderTest.php | 133 + .../Tests/Loader/XmlFileLoaderTest.php | 399 +++ .../Tests/Loader/YamlFileLoaderTest.php | 202 ++ .../DumpedRedirectableUrlMatcherTest.php | 43 + .../Tests/Matcher/DumpedUrlMatcherTest.php | 44 + .../Matcher/Dumper/DumperCollectionTest.php | 34 + .../Matcher/Dumper/PhpMatcherDumperTest.php | 454 +++ .../Dumper/StaticPrefixCollectionTest.php | 175 ++ .../Matcher/RedirectableUrlMatcherTest.php | 150 + .../Tests/Matcher/TraceableUrlMatcherTest.php | 126 + .../routing/Tests/Matcher/UrlMatcherTest.php | 616 ++++ .../routing/Tests/RequestContextTest.php | 160 ++ .../Tests/RouteCollectionBuilderTest.php | 362 +++ .../routing/Tests/RouteCollectionTest.php | 305 ++ .../routing/Tests/RouteCompilerTest.php | 379 +++ lib/symfony/routing/Tests/RouteTest.php | 258 ++ lib/symfony/routing/Tests/RouterTest.php | 157 + .../stopwatch/Tests/StopwatchEventTest.php | 210 ++ .../stopwatch/Tests/StopwatchPeriodTest.php | 67 + lib/symfony/stopwatch/Tests/StopwatchTest.php | 182 ++ .../twig-bridge/Tests/AppVariableTest.php | 264 ++ .../Tests/Command/DebugCommandTest.php | 125 + .../Tests/Command/LintCommandTest.php | 127 + ...AbstractBootstrap3HorizontalLayoutTest.php | 166 ++ .../AbstractBootstrap3LayoutTest.php | 2546 +++++++++++++++++ ...AbstractBootstrap4HorizontalLayoutTest.php | 217 ++ .../AbstractBootstrap4LayoutTest.php | 986 +++++++ .../Tests/Extension/CodeExtensionTest.php | 69 + .../Tests/Extension/DumpExtensionTest.php | 145 + .../Extension/ExpressionExtensionTest.php | 30 + .../Fixtures/StubFilesystemLoader.php | 25 + .../Extension/Fixtures/StubTranslator.php | 35 + .../templates/form/child_label.html.twig | 3 + .../templates/form/custom_widgets.html.twig | 19 + .../form/page_dynamic_extends.html.twig | 1 + .../templates/form/parent_label.html.twig | 3 + .../Fixtures/templates/form/theme.html.twig | 4 + .../templates/form/theme_extends.html.twig | 6 + .../templates/form/theme_use.html.twig | 6 + ...xtensionBootstrap3HorizontalLayoutTest.php | 106 + .../FormExtensionBootstrap3LayoutTest.php | 156 + ...xtensionBootstrap4HorizontalLayoutTest.php | 108 + .../FormExtensionBootstrap4LayoutTest.php | 160 ++ .../Extension/FormExtensionDivLayoutTest.php | 258 ++ .../FormExtensionTableLayoutTest.php | 130 + .../Tests/Extension/FormExtensionTest.php | 76 + .../Extension/HttpFoundationExtensionTest.php | 143 + .../Extension/HttpKernelExtensionTest.php | 86 + .../Tests/Extension/RoutingExtensionTest.php | 54 + .../Tests/Extension/RuntimeLoaderProvider.php | 27 + .../Extension/StopwatchExtensionTest.php | 74 + .../Extension/TranslationExtensionTest.php | 213 ++ .../Tests/Extension/WebLinkExtensionTest.php | 92 + .../Tests/Extension/WorkflowExtensionTest.php | 83 + .../Fixtures/extractor/syntax_error.twig | 1 + .../extractor/with_translations.html.twig | 1 + .../twig-bridge/Tests/Node/DumpNodeTest.php | 128 + .../twig-bridge/Tests/Node/FormThemeTest.php | 111 + .../Node/SearchAndRenderBlockNodeTest.php | 280 ++ .../twig-bridge/Tests/Node/TransNodeTest.php | 66 + .../Tests/NodeVisitor/ScopeTest.php | 25 + ...ranslationDefaultDomainNodeVisitorTest.php | 93 + .../TranslationNodeVisitorTest.php | 67 + .../Tests/NodeVisitor/TwigNodeProvider.php | 88 + .../TokenParser/FormThemeTokenParserTest.php | 123 + .../Tests/Translation/TwigExtractorTest.php | 140 + .../twig-bridge/Tests/TwigEngineTest.php | 79 + .../Tests/ContainerAwareRuntimeLoaderTest.php | 41 + .../Controller/ExceptionControllerTest.php | 92 + .../Controller/PreviewErrorControllerTest.php | 53 + .../Compiler/ExtensionPassTest.php | 46 + .../Compiler/TwigEnvironmentPassTest.php | 45 + .../Compiler/TwigLoaderPassTest.php | 95 + .../DependencyInjection/ConfigurationTest.php | 31 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../TwigBundle/views/layout.html.twig | 1 + .../Fixtures/Resources/views/layout.html.twig | 1 + .../php/customTemplateEscapingGuesser.php | 6 + .../Fixtures/php/empty.php | 3 + .../Fixtures/php/extra.php | 7 + .../Fixtures/php/formats.php | 14 + .../DependencyInjection/Fixtures/php/full.php | 27 + .../bundles/BarBundle/layout.html.twig | 1 + .../bundles/TwigBundle/layout.html.twig | 1 + .../Fixtures/templates/layout.html.twig | 1 + .../xml/customTemplateEscapingGuesser.xml | 10 + .../Fixtures/xml/empty.xml | 10 + .../Fixtures/xml/extra.xml | 12 + .../Fixtures/xml/formats.xml | 12 + .../DependencyInjection/Fixtures/xml/full.xml | 19 + .../yml/customTemplateEscapingGuesser.yml | 3 + .../Fixtures/yml/empty.yml | 1 + .../Fixtures/yml/extra.yml | 3 + .../Fixtures/yml/formats.yml | 9 + .../DependencyInjection/Fixtures/yml/full.yml | 21 + .../DependencyInjection/TwigExtensionTest.php | 355 +++ .../BarBundle/Resources/views/index.html.twig | 1 + .../Fixtures/templates/Foo/index.html.twig | 1 + .../Resources/BarBundle/views/base.html.twig | 0 .../Resources/views/layout.html.twig | 1 + .../Resources/views/sub/sub.html.twig | 1 + .../Tests/Functional/CacheWarmingTest.php | 124 + .../Tests/Functional/EmptyAppTest.php | 51 + .../Functional/NoTemplatingEntryTest.php | 80 + .../Resources/config/empty_routing.yml | 0 .../Resources/views/index.html.twig | 1 + .../Tests/Loader/FilesystemLoaderTest.php | 125 + .../Tests/TemplateIteratorTest.php | 44 + lib/symfony/twig-bundle/Tests/TestCase.php | 18 + .../var-dumper/Test/VarDumperTestTrait.php | 63 + .../var-dumper/Tests/Caster/CasterTest.php | 181 ++ .../Tests/Caster/DateCasterTest.php | 426 +++ .../Tests/Caster/ExceptionCasterTest.php | 227 ++ .../var-dumper/Tests/Caster/PdoCasterTest.php | 64 + .../Tests/Caster/RedisCasterTest.php | 84 + .../Tests/Caster/ReflectionCasterTest.php | 270 ++ .../var-dumper/Tests/Caster/SplCasterTest.php | 232 ++ .../Tests/Caster/StubCasterTest.php | 192 ++ .../Tests/Caster/XmlReaderCasterTest.php | 248 ++ .../var-dumper/Tests/Cloner/DataTest.php | 115 + .../var-dumper/Tests/Cloner/VarClonerTest.php | 505 ++++ .../var-dumper/Tests/Dumper/CliDumperTest.php | 591 ++++ .../var-dumper/Tests/Dumper/FunctionsTest.php | 57 + .../Tests/Dumper/HtmlDumperTest.php | 168 ++ .../Tests/Fixtures/FooInterface.php | 11 + .../Tests/Fixtures/GeneratorDemo.php | 21 + .../Tests/Fixtures/NotLoadableClass.php | 7 + .../var-dumper/Tests/Fixtures/Php74.php | 14 + .../var-dumper/Tests/Fixtures/Twig.php | 38 + .../var-dumper/Tests/Fixtures/dumb-var.php | 40 + .../var-dumper/Tests/Fixtures/xml_reader.xml | 10 + .../Tests/Test/VarDumperTestTraitTest.php | 41 + .../Controller/ProfilerControllerTest.php | 200 ++ .../Csp/ContentSecurityPolicyHandlerTest.php | 207 ++ .../DependencyInjection/ConfigurationTest.php | 64 + .../WebProfilerExtensionTest.php | 136 + .../WebDebugToolbarListenerTest.php | 341 +++ .../Tests/Fixtures/profile.data | 1 + .../Tests/Profiler/TemplateManagerTest.php | 171 ++ .../Tests/Resources/IconTest.php | 30 + .../web-profiler-bundle/Tests/TestCase.php | 18 + .../yaml/Tests/Command/LintCommandTest.php | 137 + lib/symfony/yaml/Tests/DumperTest.php | 606 ++++ .../yaml/Tests/Fixtures/YtsAnchorAlias.yml | 31 + .../yaml/Tests/Fixtures/YtsBasicTests.yml | 202 ++ .../yaml/Tests/Fixtures/YtsBlockMapping.yml | 51 + .../Tests/Fixtures/YtsDocumentSeparator.yml | 85 + .../yaml/Tests/Fixtures/YtsErrorTests.yml | 25 + .../Tests/Fixtures/YtsFlowCollections.yml | 60 + .../yaml/Tests/Fixtures/YtsFoldedScalars.yml | 176 ++ .../Tests/Fixtures/YtsNullsAndEmpties.yml | 45 + .../Fixtures/YtsSpecificationExamples.yml | 1701 +++++++++++ .../yaml/Tests/Fixtures/YtsTypeTransfers.yml | 266 ++ lib/symfony/yaml/Tests/Fixtures/arrow.gif | Bin 0 -> 185 bytes .../Tests/Fixtures/booleanMappingKeys.yml | 11 + .../yaml/Tests/Fixtures/embededPhp.yml | 1 + .../yaml/Tests/Fixtures/escapedCharacters.yml | 155 + lib/symfony/yaml/Tests/Fixtures/index.yml | 18 + .../Fixtures/legacyBooleanMappingKeys.yml | 23 + .../Tests/Fixtures/legacyNonStringKeys.yml | 2 + .../Tests/Fixtures/legacyNullMappingKey.yml | 9 + .../multiple_lines_as_literal_block.yml | 14 + ...eral_block_leading_space_in_first_line.yml | 4 + .../yaml/Tests/Fixtures/nonStringKeys.yml | 3 + .../yaml/Tests/Fixtures/not_readable.yml | 18 + .../yaml/Tests/Fixtures/nullMappingKey.yml | 9 + .../Tests/Fixtures/numericMappingKeys.yml | 23 + .../yaml/Tests/Fixtures/sfComments.yml | 76 + lib/symfony/yaml/Tests/Fixtures/sfCompact.yml | 159 + .../yaml/Tests/Fixtures/sfMergeKey.yml | 61 + lib/symfony/yaml/Tests/Fixtures/sfObjects.yml | 11 + lib/symfony/yaml/Tests/Fixtures/sfQuotes.yml | 33 + lib/symfony/yaml/Tests/Fixtures/sfTests.yml | 140 + .../Tests/Fixtures/unindentedCollections.yml | 82 + lib/symfony/yaml/Tests/InlineTest.php | 784 +++++ lib/symfony/yaml/Tests/ParseExceptionTest.php | 34 + lib/symfony/yaml/Tests/ParserTest.php | 2319 +++++++++++++++ lib/symfony/yaml/Tests/YamlTest.php | 40 + lib/twig/twig/lib/Twig/Test/Function.php | 38 + .../lib/Twig/Test/IntegrationTestCase.php | 11 + lib/twig/twig/lib/Twig/Test/Method.php | 42 + lib/twig/twig/lib/Twig/Test/Node.php | 40 + lib/twig/twig/lib/Twig/Test/NodeTestCase.php | 11 + 2086 files changed, 151849 insertions(+), 6 deletions(-) create mode 100644 lib/nikic/php-parser/test/PhpParser/AutoloaderTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/ClassTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/MethodTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/ParamTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/TraitTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Builder/UseTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/CodeParsingTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/CodeTestAbstract.php create mode 100644 lib/nikic/php-parser/test/PhpParser/CommentTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/ErrorHandler/CollectingTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/ErrorHandler/ThrowingTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/ErrorTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/LexerTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/NameTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/NodeAbstractTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/NodeDumperTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/NodeTraverserTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Parser/MultipleTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Parser/Php5Test.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Parser/Php7Test.php create mode 100644 lib/nikic/php-parser/test/PhpParser/ParserFactoryTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/ParserTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php create mode 100644 lib/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php create mode 100644 lib/nikic/php-parser/test/bootstrap.php create mode 100644 lib/nikic/php-parser/test/code/parser/blockComments.test create mode 100644 lib/nikic/php-parser/test/code/parser/comments.test create mode 100644 lib/nikic/php-parser/test/code/parser/errorHandling/eofError.test create mode 100644 lib/nikic/php-parser/test/code/parser/errorHandling/lexerErrors.test create mode 100644 lib/nikic/php-parser/test/code/parser/errorHandling/recovery.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/arrayDef.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/arrayDestructuring.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/assign.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/assignNewByRef.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/cast.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/clone.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/closure.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/comparison.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/constant_expr.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/errorSuppress.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/exit.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/args.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/constFetch.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/constantDeref.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/funcCall.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticCall.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticPropertyFetch.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/includeAndEval.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/issetAndEmpty.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/listWithKeys.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/logic.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/math.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/new.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/newWithoutClass.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/print.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/shellExec.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/ternaryAndCoalesce.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/globalNonSimpleVarError.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/indirectCall.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/isset.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/misc.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/new.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/uvs/staticProperty.test create mode 100644 lib/nikic/php-parser/test/code/parser/expr/variable.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/constantString.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/docString.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/docStringNewlines.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/encapsedNegVarOffset.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/encapsedString.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/float.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/int.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/invalidOctal.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/magicConst.test create mode 100644 lib/nikic/php-parser/test/code/parser/scalar/unicodeEscape.test create mode 100644 lib/nikic/php-parser/test/code/parser/semiReserved.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/abstract.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/anonymous.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/conditional.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/constModifierErrors.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/constModifiers.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/final.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/implicitPublic.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/interface.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/modifier.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/name.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/php4Style.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/simple.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/staticMethod.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/class/trait.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/const.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/controlFlow.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/declare.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/echo.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/builtinTypeDeclarations.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/byRef.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/conditional.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/defaultValues.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/nullableTypes.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/returnTypes.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/specialVars.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/typeDeclarations.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/variadic.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/function/variadicDefaultValue.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/generator/basic.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/generator/yieldPrecedence.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/generator/yieldUnaryPrecedence.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/haltCompiler.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/haltCompilerInvalidSyntax.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/haltCompilerOffset.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/haltCompilerOutermostScope.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/hashbang.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/if.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/inlineHTML.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/loop/do.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/loop/for.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/loop/foreach.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/loop/while.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/multiCatch.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/alias.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/braced.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/commentAfterNamespace.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/groupUse.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/groupUseErrors.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/groupUsePositions.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/groupUseTrailingComma.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/invalidName.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/mix.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/name.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/nested.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/notBraced.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/nsAfterHashbang.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmtInvalid.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/switch.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/tryCatch.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/tryWithoutCatch.test create mode 100644 lib/nikic/php-parser/test/code/parser/stmt/unset.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/comments.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/commentsInCommaList.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/anonymousClass.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/arrayDestructuring.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/call.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/closure.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/constant_deref.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/docStrings.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/include.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/intrinsics.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/list.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/literals.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/numbers.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/operators.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/parentheses.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/shortArraySyntax.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/uvs.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/variables.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/expr/yield.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/inlineHTMLandPHPtest.file-test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/onlyInlineHTML.file-test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/onlyPHP.file-test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/alias.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/break_continue.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/class.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/class_const.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/const.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/declare.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/do_while.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/for.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/foreach.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/function_signatures.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/global_static_variables.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/goto.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/groupUse.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/haltCompiler.file-test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/if.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/multiCatch.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/namespaces.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/nullable_types.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/switch.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/throw.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/traitUse.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/tryCatch.test create mode 100644 lib/nikic/php-parser/test/code/prettyPrinter/stmt/while.test create mode 100644 lib/pear/pear_exception/tests/PEAR/ExceptionTest.php create mode 100644 lib/psr/log/Psr/Log/Test/LoggerInterfaceTest.php create mode 100644 lib/psr/log/Psr/Log/Test/TestLogger.php create mode 100644 lib/symfony/cache/Tests/Adapter/AbstractRedisAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/AdapterTestCase.php create mode 100644 lib/symfony/cache/Tests/Adapter/ApcuAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/ArrayAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/ChainAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/DoctrineAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/FilesystemAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/NullAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PdoAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PredisAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PredisClusterAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/ProxyAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/RedisAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/RedisArrayAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/SimpleCacheAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/TraceableAdapterTest.php create mode 100644 lib/symfony/cache/Tests/Adapter/TraceableTagAwareAdapterTest.php create mode 100644 lib/symfony/cache/Tests/CacheItemTest.php create mode 100644 lib/symfony/cache/Tests/DoctrineProviderTest.php create mode 100644 lib/symfony/cache/Tests/Fixtures/ArrayCache.php create mode 100644 lib/symfony/cache/Tests/Fixtures/ExternalAdapter.php create mode 100644 lib/symfony/cache/Tests/Simple/AbstractRedisCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/ApcuCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/ArrayCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/CacheTestCase.php create mode 100644 lib/symfony/cache/Tests/Simple/ChainCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/DoctrineCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/FilesystemCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/MemcachedCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php create mode 100644 lib/symfony/cache/Tests/Simple/NullCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/PdoCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/PdoDbalCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/PhpArrayCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php create mode 100644 lib/symfony/cache/Tests/Simple/PhpFilesCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/Psr6CacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/RedisArrayCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/RedisCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/RedisClusterCacheTest.php create mode 100644 lib/symfony/cache/Tests/Simple/TraceableCacheTest.php create mode 100644 lib/symfony/cache/Tests/Traits/PdoPruneableTrait.php create mode 100644 lib/symfony/class-loader/Tests/ApcClassLoaderTest.php create mode 100644 lib/symfony/class-loader/Tests/ClassCollectionLoaderTest.php create mode 100644 lib/symfony/class-loader/Tests/ClassLoaderTest.php create mode 100644 lib/symfony/class-loader/Tests/ClassMapGeneratorTest.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/ApcPrefixCollision/A/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Apc/fallback/Namespaced/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/ATrait.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/B.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/BTrait.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CInterface.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/CTrait.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/D.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/E.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/F.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/G.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/GInterface.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/DeclaredClass.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/DeclaredInterface.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithDirMagic.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithFileMagic.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithHaltCompiler.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithStrictTypes.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced2/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced2/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Namespaced2/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike/WithComments.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Baz.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/WarmedClass.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/WarmedInterface.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/A/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/alpha/PrefixCollision/C/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/A/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Bar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/beta/PrefixCollision/C/B/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/SomeClass.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/notAClass.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/notPhpFile.md create mode 100644 lib/symfony/class-loader/Tests/Fixtures/classmap/sameNsMultipleClasses.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/deps/traits.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/fallback/Namespaced/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/fallback/Namespaced2/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/fallback/Pearlike/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/fallback/Pearlike2/FooBar.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/includepath/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/php5.4/traits.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/php5.5/class_cons.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/psr-4/Class_With_Underscores.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/psr-4/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Class_With_Underscores.php create mode 100644 lib/symfony/class-loader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Foo.php create mode 100644 lib/symfony/class-loader/Tests/Psr4ClassLoaderTest.php create mode 100644 lib/symfony/config/Tests/ConfigCacheFactoryTest.php create mode 100644 lib/symfony/config/Tests/ConfigCacheTest.php create mode 100644 lib/symfony/config/Tests/Definition/ArrayNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/BooleanNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/EnumNodeDefinitionTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/ExprBuilderTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/NodeBuilderTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/NumericNodeDefinitionTest.php create mode 100644 lib/symfony/config/Tests/Definition/Builder/TreeBuilderTest.php create mode 100644 lib/symfony/config/Tests/Definition/Dumper/XmlReferenceDumperTest.php create mode 100644 lib/symfony/config/Tests/Definition/Dumper/YamlReferenceDumperTest.php create mode 100644 lib/symfony/config/Tests/Definition/EnumNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/FinalizationTest.php create mode 100644 lib/symfony/config/Tests/Definition/FloatNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/IntegerNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/MergeTest.php create mode 100644 lib/symfony/config/Tests/Definition/NormalizationTest.php create mode 100644 lib/symfony/config/Tests/Definition/PrototypedArrayNodeTest.php create mode 100644 lib/symfony/config/Tests/Definition/ScalarNodeTest.php create mode 100644 lib/symfony/config/Tests/DependencyInjection/ConfigCachePassTest.php create mode 100644 lib/symfony/config/Tests/Exception/FileLoaderLoadExceptionTest.php create mode 100644 lib/symfony/config/Tests/FileLocatorTest.php create mode 100644 lib/symfony/config/Tests/Fixtures/Again/foo.xml create mode 100644 lib/symfony/config/Tests/Fixtures/BadParent.php create mode 100644 lib/symfony/config/Tests/Fixtures/BarNode.php create mode 100644 lib/symfony/config/Tests/Fixtures/Builder/BarNodeDefinition.php create mode 100644 lib/symfony/config/Tests/Fixtures/Builder/NodeBuilder.php create mode 100644 lib/symfony/config/Tests/Fixtures/Builder/VariableNodeDefinition.php create mode 100644 lib/symfony/config/Tests/Fixtures/Configuration/ExampleConfiguration.php create mode 100644 lib/symfony/config/Tests/Fixtures/Resource/.hiddenFile create mode 100644 lib/symfony/config/Tests/Fixtures/Resource/ConditionalClass.php create mode 100644 lib/symfony/config/Tests/Fixtures/Util/document_type.xml create mode 100644 lib/symfony/config/Tests/Fixtures/Util/invalid.xml create mode 100644 lib/symfony/config/Tests/Fixtures/Util/invalid_schema.xml create mode 100644 lib/symfony/config/Tests/Fixtures/Util/schema.xsd create mode 100644 lib/symfony/config/Tests/Fixtures/Util/valid.xml create mode 100644 lib/symfony/config/Tests/Fixtures/foo.xml create mode 100644 lib/symfony/config/Tests/Loader/DelegatingLoaderTest.php create mode 100644 lib/symfony/config/Tests/Loader/FileLoaderTest.php create mode 100644 lib/symfony/config/Tests/Loader/LoaderResolverTest.php create mode 100644 lib/symfony/config/Tests/Loader/LoaderTest.php create mode 100644 lib/symfony/config/Tests/Resource/ClassExistenceResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/ComposerResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/DirectoryResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/FileExistenceResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/FileResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/GlobResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/ReflectionClassResourceTest.php create mode 100644 lib/symfony/config/Tests/Resource/ResourceStub.php create mode 100644 lib/symfony/config/Tests/ResourceCheckerConfigCacheTest.php create mode 100644 lib/symfony/config/Tests/Util/XmlUtilsTest.php create mode 100644 lib/symfony/console/Tests/ApplicationTest.php create mode 100644 lib/symfony/console/Tests/Command/CommandTest.php create mode 100644 lib/symfony/console/Tests/Command/HelpCommandTest.php create mode 100644 lib/symfony/console/Tests/Command/ListCommandTest.php create mode 100644 lib/symfony/console/Tests/Command/LockableTraitTest.php create mode 100644 lib/symfony/console/Tests/CommandLoader/ContainerCommandLoaderTest.php create mode 100644 lib/symfony/console/Tests/CommandLoader/FactoryCommandLoaderTest.php create mode 100644 lib/symfony/console/Tests/DependencyInjection/AddConsoleCommandPassTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/AbstractDescriptorTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/ApplicationDescriptionTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/JsonDescriptorTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/MarkdownDescriptorTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/ObjectsProvider.php create mode 100644 lib/symfony/console/Tests/Descriptor/TextDescriptorTest.php create mode 100644 lib/symfony/console/Tests/Descriptor/XmlDescriptorTest.php create mode 100644 lib/symfony/console/Tests/EventListener/ErrorListenerTest.php create mode 100644 lib/symfony/console/Tests/Fixtures/BarBucCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorApplication1.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorApplication2.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorApplicationMbString.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorCommand1.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorCommand2.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorCommand3.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorCommand4.php create mode 100644 lib/symfony/console/Tests/Fixtures/DescriptorCommandMbString.php create mode 100644 lib/symfony/console/Tests/Fixtures/DummyOutput.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo1Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo2Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo3Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo4Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo5Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/Foo6Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooHiddenCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooLock2Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooLockCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooOptCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooSameCaseLowercaseCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooSameCaseUppercaseCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooSubnamespaced1Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/FooSubnamespaced2Command.php create mode 100644 lib/symfony/console/Tests/Fixtures/FoobarCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/interactive_output_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_0.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_10.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_11.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_12.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_13.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_14.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_15.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_16.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_17.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_5.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_6.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_7.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_8.txt create mode 100644 lib/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_9.txt create mode 100644 lib/symfony/console/Tests/Fixtures/TestAmbiguousCommandRegistering.php create mode 100644 lib/symfony/console/Tests/Fixtures/TestAmbiguousCommandRegistering2.php create mode 100644 lib/symfony/console/Tests/Fixtures/TestCommand.php create mode 100644 lib/symfony/console/Tests/Fixtures/application_1.json create mode 100644 lib/symfony/console/Tests/Fixtures/application_1.md create mode 100644 lib/symfony/console/Tests/Fixtures/application_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_1.xml create mode 100644 lib/symfony/console/Tests/Fixtures/application_2.json create mode 100644 lib/symfony/console/Tests/Fixtures/application_2.md create mode 100644 lib/symfony/console/Tests/Fixtures/application_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_2.xml create mode 100644 lib/symfony/console/Tests/Fixtures/application_filtered_namespace.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_gethelp.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_mbstring.md create mode 100644 lib/symfony/console/Tests/Fixtures/application_mbstring.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception3decorated.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception_doublewidth1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception_doublewidth2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception_escapeslines.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_renderexception_linebreaks.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_run1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_run2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_run3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/application_run4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/command_1.json create mode 100644 lib/symfony/console/Tests/Fixtures/command_1.md create mode 100644 lib/symfony/console/Tests/Fixtures/command_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/command_1.xml create mode 100644 lib/symfony/console/Tests/Fixtures/command_2.json create mode 100644 lib/symfony/console/Tests/Fixtures/command_2.md create mode 100644 lib/symfony/console/Tests/Fixtures/command_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/command_2.xml create mode 100644 lib/symfony/console/Tests/Fixtures/command_mbstring.md create mode 100644 lib/symfony/console/Tests/Fixtures/command_mbstring.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_1.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_1.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_1.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_2.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_2.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_2.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_3.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_3.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_3.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_4.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_4.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_4.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_default_inf_value.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_default_inf_value.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_default_inf_value.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_default_inf_value.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_style.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_style.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_style.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_argument_with_style.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_1.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_1.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_1.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_2.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_2.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_2.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_3.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_3.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_3.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_4.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_4.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_definition_4.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_1.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_1.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_1.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_1.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_2.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_2.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_2.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_2.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_3.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_3.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_3.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_3.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_4.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_4.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_4.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_4.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_5.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_5.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_5.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_5.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_6.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_6.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_6.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_6.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_default_inf_value.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_default_inf_value.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_default_inf_value.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_default_inf_value.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style.xml create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style_array.json create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style_array.md create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style_array.txt create mode 100644 lib/symfony/console/Tests/Fixtures/input_option_with_style_array.xml create mode 100644 lib/symfony/console/Tests/Formatter/OutputFormatterStyleStackTest.php create mode 100644 lib/symfony/console/Tests/Formatter/OutputFormatterStyleTest.php create mode 100644 lib/symfony/console/Tests/Formatter/OutputFormatterTest.php create mode 100644 lib/symfony/console/Tests/Helper/AbstractQuestionHelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/FormatterHelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/HelperSetTest.php create mode 100644 lib/symfony/console/Tests/Helper/HelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/ProcessHelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/ProgressBarTest.php create mode 100644 lib/symfony/console/Tests/Helper/ProgressIndicatorTest.php create mode 100644 lib/symfony/console/Tests/Helper/QuestionHelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/SymfonyQuestionHelperTest.php create mode 100644 lib/symfony/console/Tests/Helper/TableStyleTest.php create mode 100644 lib/symfony/console/Tests/Helper/TableTest.php create mode 100644 lib/symfony/console/Tests/Input/ArgvInputTest.php create mode 100644 lib/symfony/console/Tests/Input/ArrayInputTest.php create mode 100644 lib/symfony/console/Tests/Input/InputArgumentTest.php create mode 100644 lib/symfony/console/Tests/Input/InputDefinitionTest.php create mode 100644 lib/symfony/console/Tests/Input/InputOptionTest.php create mode 100644 lib/symfony/console/Tests/Input/InputTest.php create mode 100644 lib/symfony/console/Tests/Input/StringInputTest.php create mode 100644 lib/symfony/console/Tests/Logger/ConsoleLoggerTest.php create mode 100644 lib/symfony/console/Tests/Output/ConsoleOutputTest.php create mode 100644 lib/symfony/console/Tests/Output/NullOutputTest.php create mode 100644 lib/symfony/console/Tests/Output/OutputTest.php create mode 100644 lib/symfony/console/Tests/Output/StreamOutputTest.php create mode 100644 lib/symfony/console/Tests/Question/ChoiceQuestionTest.php create mode 100644 lib/symfony/console/Tests/Question/ConfirmationQuestionTest.php create mode 100644 lib/symfony/console/Tests/Style/SymfonyStyleTest.php create mode 100644 lib/symfony/console/Tests/TerminalTest.php create mode 100644 lib/symfony/console/Tests/Tester/ApplicationTesterTest.php create mode 100644 lib/symfony/console/Tests/Tester/CommandTesterTest.php create mode 100644 lib/symfony/css-selector/Tests/CssSelectorConverterTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/AbstractNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/AttributeNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/ClassNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/CombinedSelectorNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/ElementNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/FunctionNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/HashNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/NegationNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/PseudoNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/SelectorNodeTest.php create mode 100644 lib/symfony/css-selector/Tests/Node/SpecificityTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/CommentHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/HashHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/IdentifierHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/NumberHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/StringHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Handler/WhitespaceHandlerTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/ParserTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/ReaderTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Shortcut/ClassParserTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Shortcut/ElementParserTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Shortcut/EmptyStringParserTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/Shortcut/HashParserTest.php create mode 100644 lib/symfony/css-selector/Tests/Parser/TokenStreamTest.php create mode 100644 lib/symfony/css-selector/Tests/XPath/Fixtures/ids.html create mode 100644 lib/symfony/css-selector/Tests/XPath/Fixtures/lang.xml create mode 100644 lib/symfony/css-selector/Tests/XPath/Fixtures/shakespear.html create mode 100644 lib/symfony/css-selector/Tests/XPath/TranslatorTest.php create mode 100644 lib/symfony/debug/Resources/ext/tests/001.phpt create mode 100644 lib/symfony/debug/Resources/ext/tests/002.phpt create mode 100644 lib/symfony/debug/Resources/ext/tests/002_1.phpt create mode 100644 lib/symfony/debug/Resources/ext/tests/003.phpt create mode 100644 lib/symfony/debug/Tests/DebugClassLoaderTest.php create mode 100644 lib/symfony/debug/Tests/ErrorHandlerTest.php create mode 100644 lib/symfony/debug/Tests/Exception/FlattenExceptionTest.php create mode 100644 lib/symfony/debug/Tests/ExceptionHandlerTest.php create mode 100644 lib/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php create mode 100644 lib/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php create mode 100644 lib/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php create mode 100644 lib/symfony/debug/Tests/Fixtures/AnnotatedClass.php create mode 100644 lib/symfony/debug/Tests/Fixtures/ClassAlias.php create mode 100644 lib/symfony/debug/Tests/Fixtures/DefinitionInEvaluatedCode.php create mode 100644 lib/symfony/debug/Tests/Fixtures/DeprecatedClass.php create mode 100644 lib/symfony/debug/Tests/Fixtures/DeprecatedInterface.php create mode 100644 lib/symfony/debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php create mode 100644 lib/symfony/debug/Tests/Fixtures/ExtendedFinalMethod.php create mode 100644 lib/symfony/debug/Tests/Fixtures/FinalClasses.php create mode 100644 lib/symfony/debug/Tests/Fixtures/FinalMethod.php create mode 100644 lib/symfony/debug/Tests/Fixtures/FinalMethod2Trait.php create mode 100644 lib/symfony/debug/Tests/Fixtures/InternalClass.php create mode 100644 lib/symfony/debug/Tests/Fixtures/InternalInterface.php create mode 100644 lib/symfony/debug/Tests/Fixtures/InternalTrait.php create mode 100644 lib/symfony/debug/Tests/Fixtures/InternalTrait2.php create mode 100644 lib/symfony/debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php create mode 100644 lib/symfony/debug/Tests/Fixtures/NonDeprecatedInterface.php create mode 100644 lib/symfony/debug/Tests/Fixtures/PEARClass.php create mode 100644 lib/symfony/debug/Tests/Fixtures/Throwing.php create mode 100644 lib/symfony/debug/Tests/Fixtures/ToStringThrower.php create mode 100644 lib/symfony/debug/Tests/Fixtures/TraitWithInternalMethod.php create mode 100644 lib/symfony/debug/Tests/Fixtures/casemismatch.php create mode 100644 lib/symfony/debug/Tests/Fixtures/notPsr0Bis.php create mode 100644 lib/symfony/debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php create mode 100644 lib/symfony/debug/Tests/Fixtures/reallyNotPsr0.php create mode 100644 lib/symfony/debug/Tests/Fixtures2/RequiredTwice.php create mode 100644 lib/symfony/debug/Tests/HeaderMock.php create mode 100644 lib/symfony/debug/Tests/phpt/debug_class_loader.phpt create mode 100644 lib/symfony/debug/Tests/phpt/decorate_exception_hander.phpt create mode 100644 lib/symfony/debug/Tests/phpt/exception_rethrown.phpt create mode 100644 lib/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt create mode 100644 lib/symfony/dependency-injection/Tests/Argument/RewindableGeneratorTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ChildDefinitionTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/AutoAliasServicePassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/AutowireExceptionPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/AutowirePassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/AutowireRequiredMethodsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/CheckArgumentsValidityPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/CheckCircularReferencesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/CheckDefinitionValidityPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/CheckReferenceValidityPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/DecoratorServicePassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/DefinitionErrorExceptionPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ExtensionCompilerPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/FactoryReturnTypePassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/InlineServiceDefinitionsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/MergeExtensionConfigurationPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/OptionalServiceClass.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/PassConfigTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/PriorityTaggedServiceTraitTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/RegisterServiceSubscribersPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveBindingsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveChildDefinitionsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveClassPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveFactoryClassPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveHotPathPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveInvalidReferencesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveNamedArgumentsPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolvePrivatesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ResolveTaggedIteratorArgumentPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Compiler/ServiceLocatorTagPassTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Config/AutowireServiceResourceTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Config/ContainerParametersResourceCheckerTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Config/ContainerParametersResourceTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ContainerBuilderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ContainerTest.php create mode 100644 lib/symfony/dependency-injection/Tests/CrossCheckTest.php create mode 100644 lib/symfony/dependency-injection/Tests/DefinitionDecoratorTest.php create mode 100644 lib/symfony/dependency-injection/Tests/DefinitionTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Dumper/GraphvizDumperTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Dumper/PhpDumperTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Dumper/XmlDumperTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Dumper/YamlDumperTest.php create mode 100644 lib/symfony/dependency-injection/Tests/EnvVarProcessorTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Extension/ExtensionTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Bar.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/BarInterface.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/CaseSensitiveClass.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Container/ConstructorWithMandatoryArgumentsContainer.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Container/ConstructorWithOptionalArgumentsContainer.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Container/ConstructorWithoutArgumentsContainer.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Container/NoConstructorContainer.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/CustomDefinition.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/DeprecatedClass.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/FactoryDummy.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/FactoryDummyWithoutReturnTypes.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/FooForCircularWithAddCalls.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/NamedArgumentsDummy.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ParentNotExists.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/Foo.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/FooInterface.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/AnotherSub/DeeperBaz.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/Baz.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/Component1/Dir1/Service1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/Component1/Dir2/Service2.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/Component2/Dir1/Service4.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/OtherDir/Component2/Dir2/Service5.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/Sub/Bar.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/Prototype/Sub/BarInterface.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ScalarFactory.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/SimilarArgumentsDummy.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/StubbedTranslator.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/TestDefinition1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/TestDefinition2.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/TestServiceSubscriber.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/array.json create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/basic.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/basic.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/child.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/child.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/defaults.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/defaults.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/factory_short_notation.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/instanceof.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/instanceof.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/php7.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/php7.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/prototype.expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/prototype.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/services9.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/config/services_autoconfigure_with_parent.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/CustomContainer.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container10.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container11.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container12.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container13.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container14.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container15.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container16.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container17.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container19.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container21.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container24.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container33.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container8.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container9.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container_abstract.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container_almost_circular.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container_env_in_id.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container_inline_requires.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/containers/container_uninitialized_ref.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/directory/import/import.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/directory/recurse/simple.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/directory/recurse/simple.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/directory/simple.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services1.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services10-1.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services10.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services13.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services14.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services17.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services18.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services9.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/graphviz/services_inline.dot create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/FooVariadic.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/C1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/C2.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/C3.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/I1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/P1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/HotPath/T1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/ProjectExtension.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/ProjectWithXsdExtension.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/ProjectWithXsdExtensionInPhar.phar create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/autowiring_classes.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/classes.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/createphar.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/foo.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/includes/schema/project-1.0.xsd create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/almostvalid.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/ini_with_wrong_ext.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/nonvalid.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/parameters.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/parameters1.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/parameters2.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/ini/types.ini create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/custom_container_class_without_constructor.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/php_with_wrong_ext.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services1-1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services1.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services10.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services12.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services13.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services19.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services24.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services26.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services33.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services8.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services9.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services9_as_files.txt create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services9_compiled.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_adawson.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_almost_circular_private.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_almost_circular_public.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_array_params.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_base64_env.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_dedup_lazy_proxy.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_deep_graph.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_env_in_id.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_inline_requires.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_inline_self_ref.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_legacy_privates.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_locator.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_non_shared_lazy.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_private_frozen.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_private_in_expression.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_rot13_env.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_subscriber.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_tsantos.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_uninitialized_ref.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/services_unsupported_characters.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/php/simple.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/class_from_id.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/defaults_bindings.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/defaults_bindings2.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extension1/services.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extension2/services.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services1.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services2.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services3.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services4.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services5.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services6.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/extensions/services7.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/legacy_invalid_alias_definition.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/namespaces.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/nested_service_without_id.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/nonvalid.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services1.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services10.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services13.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services14.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services2.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services21.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services22.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services23.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services24.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services28.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services3.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services4.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services4_bad_import.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services5.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services6.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services7.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services8.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services9.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_abstract.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_autoconfigure.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_autoconfigure_with_parent.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_bindings.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_defaults_with_parent.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_deprecated.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_dump_load.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_inline_not_candidate.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_instanceof.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_instanceof_with_parent.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_named_args.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_prototype.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_tsantos.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/services_without_id.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/tag_with_empty_name.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/tag_without_name.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/with_key_outside_collection.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/withdoctype.xml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/xml/xml_with_wrong_ext.php create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/anonymous_services.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/anonymous_services_alias.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/anonymous_services_in_instanceof.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/anonymous_services_in_parameters.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_calls.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_decorates.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_empty_defaults.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_empty_instanceof.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_format.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_import.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_imports.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_parameters.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_service.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_services.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_types1.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bad_types2.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/badtag1.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/badtag2.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/badtag3.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/bar/services.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/class_from_id.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/defaults_bindings.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/defaults_bindings2.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/foo/services.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_child_not_applied/_child.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_child_not_applied/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_child_not_applied/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child/_child.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child_tags/_child.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child_tags/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/autoconfigure_parent_child_tags/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/child_parent/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/child_parent/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_child_tags/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_child_tags/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_instanceof_importance/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_instanceof_importance/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_parent_child/_child.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_parent_child/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/defaults_parent_child/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/instanceof_parent_child/_child.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/instanceof_parent_child/expected.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/integration/instanceof_parent_child/main.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/legacy_invalid_alias_definition.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/legacy_invalid_definition.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/nonvalid1.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/nonvalid2.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/null_config.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services1.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services10.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services11.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services13.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services14.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services2.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services21.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services22.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services23.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services24.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services26.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services28.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services3.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services31_invalid_tags.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services4.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services4_bad_import.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services6.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services7.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services8.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services9.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_adawson.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_autoconfigure.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_autoconfigure_with_parent.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_bindings.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_configurator_short_syntax.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_deep_graph.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_defaults_with_parent.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_dump_load.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_inline.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_instanceof.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_instanceof_with_parent.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_legacy_privates.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_named_args.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_prototype.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_prototype_namespace.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_prototype_namespace_without_resource.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/services_underscore.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/tag_name_empty_string.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/tag_name_no_string.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/tag_name_only.yml create mode 100644 lib/symfony/dependency-injection/Tests/Fixtures/yaml/yaml_with_wrong_ext.ini create mode 100644 lib/symfony/dependency-injection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php create mode 100644 lib/symfony/dependency-injection/Tests/LazyProxy/PhpDumper/NullDumperTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/ClosureLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/DirectoryLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/FileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/GlobFileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/IniFileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/LoaderResolverTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/PhpFileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/Loader/YamlFileLoaderTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ParameterBag/FrozenParameterBagTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ParameterBag/ParameterBagTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ParameterTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ReferenceTest.php create mode 100644 lib/symfony/dependency-injection/Tests/ServiceLocatorTest.php create mode 100644 lib/symfony/dotenv/Tests/DotenvTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/Debug/WrappedListenerTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/EventDispatcherTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/EventTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/GenericEventTest.php create mode 100644 lib/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php create mode 100644 lib/symfony/filesystem/Tests/ExceptionTest.php create mode 100644 lib/symfony/filesystem/Tests/FilesystemTest.php create mode 100644 lib/symfony/filesystem/Tests/FilesystemTestCase.php create mode 100644 lib/symfony/filesystem/Tests/Fixtures/MockStream/MockStream.php create mode 100644 lib/symfony/filesystem/Tests/LockHandlerTest.php create mode 100644 lib/symfony/finder/Tests/Comparator/ComparatorTest.php create mode 100644 lib/symfony/finder/Tests/Comparator/DateComparatorTest.php create mode 100644 lib/symfony/finder/Tests/Comparator/NumberComparatorTest.php create mode 100644 lib/symfony/finder/Tests/FinderTest.php create mode 100644 lib/symfony/finder/Tests/Fixtures/.dot/a create mode 100644 lib/symfony/finder/Tests/Fixtures/.dot/b/c.neon create mode 100644 lib/symfony/finder/Tests/Fixtures/.dot/b/d.neon create mode 100644 lib/symfony/finder/Tests/Fixtures/A/B/C/abc.dat create mode 100644 lib/symfony/finder/Tests/Fixtures/A/B/ab.dat create mode 100644 lib/symfony/finder/Tests/Fixtures/A/a.dat create mode 100644 lib/symfony/finder/Tests/Fixtures/copy/A/B/C/abc.dat.copy create mode 100644 lib/symfony/finder/Tests/Fixtures/copy/A/B/ab.dat.copy create mode 100644 lib/symfony/finder/Tests/Fixtures/copy/A/a.dat.copy create mode 100644 lib/symfony/finder/Tests/Fixtures/dolor.txt create mode 100644 lib/symfony/finder/Tests/Fixtures/ipsum.txt create mode 100644 lib/symfony/finder/Tests/Fixtures/lorem.txt create mode 100644 lib/symfony/finder/Tests/Fixtures/one/.dot create mode 100644 lib/symfony/finder/Tests/Fixtures/one/a create mode 100644 lib/symfony/finder/Tests/Fixtures/one/b/c.neon create mode 100644 lib/symfony/finder/Tests/Fixtures/one/b/d.neon create mode 100644 lib/symfony/finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat create mode 100644 lib/symfony/finder/Tests/Fixtures/with space/foo.txt create mode 100644 lib/symfony/finder/Tests/GlobTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/CustomFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/DateRangeFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/FilecontentFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/FilenameFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/FilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/Iterator.php create mode 100644 lib/symfony/finder/Tests/Iterator/IteratorTestCase.php create mode 100644 lib/symfony/finder/Tests/Iterator/MockFileListIterator.php create mode 100644 lib/symfony/finder/Tests/Iterator/MockSplFileInfo.php create mode 100644 lib/symfony/finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/PathFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/RealIteratorTestCase.php create mode 100644 lib/symfony/finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/SizeRangeFilterIteratorTest.php create mode 100644 lib/symfony/finder/Tests/Iterator/SortableIteratorTest.php create mode 100644 lib/symfony/framework-bundle/Test/ForwardCompatTestTrait.php create mode 100644 lib/symfony/framework-bundle/Test/KernelTestCase.php create mode 100644 lib/symfony/framework-bundle/Test/WebTestCase.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/TemplateFinderTest.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/ClientTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/CacheClearCommand/Fixture/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Command/CachePruneCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/RouterDebugCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/RouterMatchCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/TranslationDebugCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/TranslationUpdateCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Command/YamlLintCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/ApplicationTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/AbstractDescriptorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/JsonDescriptorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/MarkdownDescriptorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/ObjectsProvider.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/TextDescriptorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Console/Descriptor/XmlDescriptorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/AbstractControllerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/ControllerNameParserTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/ControllerResolverTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/ControllerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/ControllerTraitTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/RedirectControllerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Controller/TemplateControllerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/FormPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/ConfigurationTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/Resources/config/validation.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serialization.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serialization.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/files/foo.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/files/foo.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/files/foo.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/files/foo.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/assets.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/cache.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/csrf.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/default_config.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/full.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/profiler.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/property_info.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/request.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/session.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/web_link.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflows.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/translations/test_paths.en.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/assets.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/assets_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/assets_version_strategy_as_service.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/cache.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/cache_env_var.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/csrf.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/csrf_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/csrf_needs_session.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/default_config.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/esi_and_ssi_without_fragments.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/esi_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/form_no_csrf.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/lock.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/php_errors_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/php_errors_enabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/property_info.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/request.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/serializer_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/serializer_enabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/session.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/ssi_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/templating_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_disabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_enabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/translator_fallbacks.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_mapping.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_multiple_static_methods.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_no_static_method.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_strict_email.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/web_link.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_arguments_and_service.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_support_and_support_strategy.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_type_and_service.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflow_without_support_and_support_strategy.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflows_enabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/xml/workflows_without_type.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/assets.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/assets_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/assets_version_strategy_as_service.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/cache.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/cache_env_var.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/csrf.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/csrf_needs_session.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/default_config.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/esi_and_ssi_without_fragments.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/esi_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/form_no_csrf.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/lock.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/php_errors_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/php_errors_enabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/property_info.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/request.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/serializer_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/serializer_enabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/session.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/ssi_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/templating_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_disabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_enabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/translator_fallbacks.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_mapping.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_multiple_static_methods.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_no_static_method.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_strict_email.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/web_link.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_arguments_and_service.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_multiple_transitions_with_same_name.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_support_and_support_strategy.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_type_and_service.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflow_without_support_and_support_strategy.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflows_enabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/Fixtures/yml/workflows_without_type.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/FrameworkExtensionTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/config/serializer/foo.yml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/config/validator/foo.xml create mode 100644 lib/symfony/framework-bundle/Tests/DependencyInjection/translations/test_default.en.xlf create mode 100644 lib/symfony/framework-bundle/Tests/EventListener/ResolveControllerNameSubscriberTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/BaseBundle/BaseBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/BaseBundle/Resources/views/base.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/BaseBundle/Resources/views/controller/base.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/BaseBundle/Resources/views/this.is.a.template.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/DeclaredClass.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/alias_with_definition_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/array_parameter.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/array_parameter.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/array_parameter.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/array_parameter.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_arguments.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_arguments.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_arguments.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_public.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_public.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_public.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_public.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_services.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_services.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_services.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_services.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tag1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tag1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tags.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tags.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tags.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/builder_1_tags.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_3.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_3.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_3.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_3.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_4.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_4.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_4.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_4.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_5.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_5.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_5.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_5.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_6.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_6.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_6.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_6.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_7.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_7.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_7.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_7.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_from_callable.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_from_callable.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_from_callable.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/callable_from_callable.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/definition_arguments_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameter.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameter.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameter.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameter.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameters_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameters_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameters_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/parameters_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_2.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_2.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_2.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_2.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_collection_1.json create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_collection_1.md create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_collection_1.txt create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Descriptor/route_collection_1.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/BaseBundle/views/base.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/BaseBundle/views/controller/custom.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/translations/messages.fr.yml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/views/resource.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/views/this.is.a.template.format.engine create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Resources/views/translation.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Serialization/Author.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Serialization/Person.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Serialization/Resources/author.yml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Serialization/Resources/does_not_exist.yaml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Serialization/Resources/person.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TemplatePathsCache/templates-empty.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TemplatePathsCache/templates.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle/Controller/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Fabpot/FooBundle/FabpotFooBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/FooBundle/Controller/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/FooBundle/Controller/Sub/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/FooBundle/Controller/Test/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/FooBundle/FooBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/Controller/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/SensioCmsFooBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Sensio/FooBundle/Controller/DefaultController.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/TestBundle/Sensio/FooBundle/SensioFooBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Article.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Author.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Category.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Person.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Resources/author.yml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Resources/categories.yml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Resources/does_not_exist.yaml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/Resources/person.xml create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/Validation/SubCategory.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/WarmedClass.php create mode 100644 lib/symfony/framework-bundle/Tests/Fixtures/templates.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/AbstractWebTestCase.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/AnnotatedControllerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/AutowiringTypesTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/ProfilerController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestServiceResolutionController.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/AnnotationReaderPass.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Config/CustomConfig.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Configuration.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/Bundle/TestBundle/TestBundle.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/CachePoolClearCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/CachePoolsTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/ConfigDebugCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/ConfigDumpReferenceCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/ContainerDebugCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/ContainerDumpTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/DebugAutowiringCommandTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/FragmentTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/ProfilerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/PropertyInfoTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/SerializerTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/SessionTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/SubRequestsTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AnnotatedController/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AnnotatedController/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AnnotatedController/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AppKernel.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AutowiringTypes/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AutowiringTypes/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePoolClear/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePoolClear/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePools/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePools/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePools/redis_config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/CachePools/redis_custom_config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ConfigDump/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ConfigDump/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ContainerDebug/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ContainerDebug/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ContainerDump/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ContainerDump/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ControllerServiceResolution/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ControllerServiceResolution/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/ControllerServiceResolution/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Fragment/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Fragment/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Fragment/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Profiler/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Profiler/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Profiler/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Resources/views/fragment.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Serializer/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Serializer/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Session/bundles.php create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Session/config.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/Session/routing.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/config/default.yml create mode 100644 lib/symfony/framework-bundle/Tests/Functional/app/config/framework.yml create mode 100644 lib/symfony/framework-bundle/Tests/Kernel/ConcreteMicroKernel.php create mode 100644 lib/symfony/framework-bundle/Tests/Kernel/MicroKernelTraitTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Routing/DelegatingLoaderTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Routing/RedirectableUrlMatcherTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Routing/RouterTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/DelegatingEngineTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/GlobalVariablesTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/AssetsHelperTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Fixtures/StubTranslator.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/RequestHelperTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Child/form_label.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Custom/_text_id_widget.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Parent/form_label.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/SessionHelperTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Helper/StopwatchHelperTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/Loader/TemplateLocatorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/PhpEngineTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/TemplateFilenameParserTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/TemplateNameParserTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/TemplateReferenceTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/TemplateTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Templating/TimedPhpEngineTest.php create mode 100644 lib/symfony/framework-bundle/Tests/TestCase.php create mode 100644 lib/symfony/framework-bundle/Tests/Translation/PhpExtractorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Translation/TranslatorTest.php create mode 100644 lib/symfony/framework-bundle/Tests/Validator/ConstraintValidatorFactoryTest.php create mode 100644 lib/symfony/http-foundation/Tests/AcceptHeaderItemTest.php create mode 100644 lib/symfony/http-foundation/Tests/AcceptHeaderTest.php create mode 100644 lib/symfony/http-foundation/Tests/ApacheRequestTest.php create mode 100644 lib/symfony/http-foundation/Tests/BinaryFileResponseTest.php create mode 100644 lib/symfony/http-foundation/Tests/CookieTest.php create mode 100644 lib/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php create mode 100644 lib/symfony/http-foundation/Tests/File/FakeFile.php create mode 100644 lib/symfony/http-foundation/Tests/File/FileTest.php create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/-test create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/.unknownextension create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/case-sensitive-mime-type.xlsm create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/directory/.empty create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/other-file.example create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/test create mode 100644 lib/symfony/http-foundation/Tests/File/Fixtures/test.gif create mode 100644 lib/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php create mode 100644 lib/symfony/http-foundation/Tests/File/UploadedFileTest.php create mode 100644 lib/symfony/http-foundation/Tests/FileBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_max_age.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_max_age.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_raw_urlencode.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_raw_urlencode.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_samesite_lax.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_samesite_lax.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_samesite_strict.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_samesite_strict.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.expected create mode 100644 lib/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php create mode 100644 lib/symfony/http-foundation/Tests/HeaderBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/IpUtilsTest.php create mode 100644 lib/symfony/http-foundation/Tests/JsonResponseTest.php create mode 100644 lib/symfony/http-foundation/Tests/ParameterBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/RedirectResponseTest.php create mode 100644 lib/symfony/http-foundation/Tests/RequestMatcherTest.php create mode 100644 lib/symfony/http-foundation/Tests/RequestStackTest.php create mode 100644 lib/symfony/http-foundation/Tests/RequestTest.php create mode 100644 lib/symfony/http-foundation/Tests/ResponseFunctionalTest.php create mode 100644 lib/symfony/http-foundation/Tests/ResponseHeaderBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/ResponseTest.php create mode 100644 lib/symfony/http-foundation/Tests/ResponseTestCase.php create mode 100644 lib/symfony/http-foundation/Tests/ServerBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/SessionTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/common.inc create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.expected create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/MetadataBagTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/MockArraySessionStorageTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/MockFileSessionStorageTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Proxy/NativeProxyTest.php create mode 100644 lib/symfony/http-foundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php create mode 100644 lib/symfony/http-foundation/Tests/StreamedResponseTest.php create mode 100644 lib/symfony/http-foundation/Tests/schema/http-status-codes.rng create mode 100644 lib/symfony/http-foundation/Tests/schema/iana-registry.rng create mode 100644 lib/symfony/http-kernel/Tests/Bundle/BundleTest.php create mode 100644 lib/symfony/http-kernel/Tests/CacheClearer/ChainCacheClearerTest.php create mode 100644 lib/symfony/http-kernel/Tests/CacheClearer/Psr6CacheClearerTest.php create mode 100644 lib/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php create mode 100644 lib/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerTest.php create mode 100644 lib/symfony/http-kernel/Tests/ClientTest.php create mode 100644 lib/symfony/http-kernel/Tests/Config/EnvParametersResourceTest.php create mode 100644 lib/symfony/http-kernel/Tests/Config/FileLocatorTest.php create mode 100644 lib/symfony/http-kernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php create mode 100644 lib/symfony/http-kernel/Tests/Controller/ArgumentResolverTest.php create mode 100644 lib/symfony/http-kernel/Tests/Controller/ContainerControllerResolverTest.php create mode 100644 lib/symfony/http-kernel/Tests/Controller/ControllerResolverTest.php create mode 100644 lib/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php create mode 100644 lib/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/Compiler.log create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php create mode 100644 lib/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php create mode 100644 lib/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php create mode 100644 lib/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/FragmentRendererPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/LoggerPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/ResettableServicePassTest.php create mode 100644 lib/symfony/http-kernel/Tests/DependencyInjection/ServicesResetterTest.php create mode 100644 lib/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php create mode 100644 lib/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/DumpListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/123/Kernel123.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/hide.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/bar.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Bundle2Bundle/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/hide.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ClearableService.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Controller/BasicTypesController.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingRequest.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingSession.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Controller/NullableController.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Controller/VariadicController.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/KernelForOverrideName.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/KernelForTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/KernelWithoutBundles.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/ResettableService.php create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Resources/BaseBundle/hide.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Resources/Bundle1Bundle/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Resources/ChildBundle/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/Resources/FooBundle/foo.txt create mode 100644 lib/symfony/http-kernel/Tests/Fixtures/TestClient.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/EsiFragmentRendererTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/FragmentHandlerTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/RoutableFragmentRendererTest.php create mode 100644 lib/symfony/http-kernel/Tests/Fragment/SsiFragmentRendererTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/EsiTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/ResponseCacheStrategyTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/SsiTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/StoreTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/SubRequestHandlerTest.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/TestHttpKernel.php create mode 100644 lib/symfony/http-kernel/Tests/HttpCache/TestMultipleHttpKernel.php create mode 100644 lib/symfony/http-kernel/Tests/HttpKernelTest.php create mode 100644 lib/symfony/http-kernel/Tests/KernelTest.php create mode 100644 lib/symfony/http-kernel/Tests/Log/LoggerTest.php create mode 100644 lib/symfony/http-kernel/Tests/Logger.php create mode 100644 lib/symfony/http-kernel/Tests/Profiler/FileProfilerStorageTest.php create mode 100644 lib/symfony/http-kernel/Tests/Profiler/ProfilerTest.php create mode 100644 lib/symfony/http-kernel/Tests/TestHttpKernel.php create mode 100644 lib/symfony/http-kernel/Tests/UriSignerTest.php create mode 100644 lib/symfony/routing/Tests/Annotation/RouteTest.php create mode 100644 lib/symfony/routing/Tests/CompiledRouteTest.php create mode 100644 lib/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/EncodingClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php create mode 100644 lib/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php create mode 100644 lib/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php create mode 100644 lib/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php create mode 100644 lib/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php create mode 100644 lib/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php create mode 100644 lib/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php create mode 100644 lib/symfony/routing/Tests/Fixtures/annotated.php create mode 100644 lib/symfony/routing/Tests/Fixtures/bad_format.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/bar.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import__controller.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import__controller.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import_controller.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import_controller.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/override_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/override_defaults.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/routing.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/controller/routing.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/directory/routes3.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/directory_import/import.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php create mode 100644 lib/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php create mode 100644 lib/symfony/routing/Tests/Fixtures/empty.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/file_resource.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/foo.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/foo1.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/bar.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/bar.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/baz.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/baz.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/import_multiple.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/import_multiple.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/import_single.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/import_single.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/php_dsl.php create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/php_dsl_bar.php create mode 100644 lib/symfony/routing/Tests/Fixtures/glob/php_dsl_baz.php create mode 100644 lib/symfony/routing/Tests/Fixtures/incomplete.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/list_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/list_null_values.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/localized/utf8.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/map_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/map_null_values.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/missing_id.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/missing_path.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/namespaceprefix.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalid.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalid.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalid2.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalidkeys.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalidnode.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/nonvalidroute.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/null_values.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/php_dsl.php create mode 100644 lib/symfony/routing/Tests/Fixtures/php_dsl_sub.php create mode 100644 lib/symfony/routing/Tests/Fixtures/scalar_defaults.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/special_route_name.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/validpattern.php create mode 100644 lib/symfony/routing/Tests/Fixtures/validpattern.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/validpattern.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/validresource.php create mode 100644 lib/symfony/routing/Tests/Fixtures/validresource.xml create mode 100644 lib/symfony/routing/Tests/Fixtures/validresource.yml create mode 100644 lib/symfony/routing/Tests/Fixtures/with_define_path_variable.php create mode 100644 lib/symfony/routing/Tests/Fixtures/withdoctype.xml create mode 100644 lib/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php create mode 100644 lib/symfony/routing/Tests/Generator/UrlGeneratorTest.php create mode 100644 lib/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/ClosureLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/DirectoryLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/GlobFileLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/PhpFileLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/XmlFileLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Loader/YamlFileLoaderTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/DumpedUrlMatcherTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php create mode 100644 lib/symfony/routing/Tests/Matcher/UrlMatcherTest.php create mode 100644 lib/symfony/routing/Tests/RequestContextTest.php create mode 100644 lib/symfony/routing/Tests/RouteCollectionBuilderTest.php create mode 100644 lib/symfony/routing/Tests/RouteCollectionTest.php create mode 100644 lib/symfony/routing/Tests/RouteCompilerTest.php create mode 100644 lib/symfony/routing/Tests/RouteTest.php create mode 100644 lib/symfony/routing/Tests/RouterTest.php create mode 100644 lib/symfony/stopwatch/Tests/StopwatchEventTest.php create mode 100644 lib/symfony/stopwatch/Tests/StopwatchPeriodTest.php create mode 100644 lib/symfony/stopwatch/Tests/StopwatchTest.php create mode 100644 lib/symfony/twig-bridge/Tests/AppVariableTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Command/DebugCommandTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Command/LintCommandTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/AbstractBootstrap3LayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/AbstractBootstrap4LayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/CodeExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/DumpExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/ExpressionExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/StubFilesystemLoader.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/StubTranslator.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/child_label.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/custom_widgets.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/page_dynamic_extends.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/parent_label.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/theme.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/theme_extends.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/Fixtures/templates/form/theme_use.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionBootstrap3LayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionBootstrap4LayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionDivLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionTableLayoutTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/FormExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/HttpFoundationExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/HttpKernelExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/RoutingExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/RuntimeLoaderProvider.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/StopwatchExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/TranslationExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/WebLinkExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Extension/WorkflowExtensionTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Fixtures/extractor/syntax_error.twig create mode 100644 lib/symfony/twig-bridge/Tests/Fixtures/extractor/with_translations.html.twig create mode 100644 lib/symfony/twig-bridge/Tests/Node/DumpNodeTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Node/FormThemeTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Node/SearchAndRenderBlockNodeTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Node/TransNodeTest.php create mode 100644 lib/symfony/twig-bridge/Tests/NodeVisitor/ScopeTest.php create mode 100644 lib/symfony/twig-bridge/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php create mode 100644 lib/symfony/twig-bridge/Tests/NodeVisitor/TranslationNodeVisitorTest.php create mode 100644 lib/symfony/twig-bridge/Tests/NodeVisitor/TwigNodeProvider.php create mode 100644 lib/symfony/twig-bridge/Tests/TokenParser/FormThemeTokenParserTest.php create mode 100644 lib/symfony/twig-bridge/Tests/Translation/TwigExtractorTest.php create mode 100644 lib/symfony/twig-bridge/Tests/TwigEngineTest.php create mode 100644 lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml create mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php create mode 100644 lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php create mode 100644 lib/symfony/twig-bundle/Tests/TestCase.php create mode 100644 lib/symfony/var-dumper/Test/VarDumperTestTrait.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/CasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/DateCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/ExceptionCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/PdoCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/RedisCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/ReflectionCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/SplCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/StubCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Caster/XmlReaderCasterTest.php create mode 100644 lib/symfony/var-dumper/Tests/Cloner/DataTest.php create mode 100644 lib/symfony/var-dumper/Tests/Cloner/VarClonerTest.php create mode 100644 lib/symfony/var-dumper/Tests/Dumper/CliDumperTest.php create mode 100644 lib/symfony/var-dumper/Tests/Dumper/FunctionsTest.php create mode 100644 lib/symfony/var-dumper/Tests/Dumper/HtmlDumperTest.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/FooInterface.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/GeneratorDemo.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/NotLoadableClass.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/Php74.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/Twig.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/dumb-var.php create mode 100644 lib/symfony/var-dumper/Tests/Fixtures/xml_reader.xml create mode 100644 lib/symfony/var-dumper/Tests/Test/VarDumperTestTraitTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/Controller/ProfilerControllerTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/DependencyInjection/ConfigurationTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/DependencyInjection/WebProfilerExtensionTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/EventListener/WebDebugToolbarListenerTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/Fixtures/profile.data create mode 100644 lib/symfony/web-profiler-bundle/Tests/Profiler/TemplateManagerTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/Resources/IconTest.php create mode 100644 lib/symfony/web-profiler-bundle/Tests/TestCase.php create mode 100644 lib/symfony/yaml/Tests/Command/LintCommandTest.php create mode 100644 lib/symfony/yaml/Tests/DumperTest.php create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/arrow.gif create mode 100644 lib/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/embededPhp.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/escapedCharacters.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/index.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/legacyNonStringKeys.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/nonStringKeys.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/not_readable.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/nullMappingKey.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfComments.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfCompact.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfMergeKey.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfObjects.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfQuotes.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/sfTests.yml create mode 100644 lib/symfony/yaml/Tests/Fixtures/unindentedCollections.yml create mode 100644 lib/symfony/yaml/Tests/InlineTest.php create mode 100644 lib/symfony/yaml/Tests/ParseExceptionTest.php create mode 100644 lib/symfony/yaml/Tests/ParserTest.php create mode 100644 lib/symfony/yaml/Tests/YamlTest.php create mode 100644 lib/twig/twig/lib/Twig/Test/Function.php create mode 100644 lib/twig/twig/lib/Twig/Test/IntegrationTestCase.php create mode 100644 lib/twig/twig/lib/Twig/Test/Method.php create mode 100644 lib/twig/twig/lib/Twig/Test/Node.php create mode 100644 lib/twig/twig/lib/Twig/Test/NodeTestCase.php diff --git a/.gitignore b/.gitignore index fc9107066..51f650a97 100644 --- a/.gitignore +++ b/.gitignore @@ -15,12 +15,6 @@ # composer reserver directory, from sources, populate/update using "composer install" vendor/* test/vendor/* -# remove tests from libs (N°2651) -/lib/**/test/** -/lib/**/tests/** -/lib/**/Test/** -/lib/**/Tests/** -!/lib/twig/**/Expression/Test/** # all datas but listing prevention /data/** diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 79227041e..72abb91b0 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -596,6 +596,9 @@ return array( 'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php', 'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php', 'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php', + 'Psr\\Log\\Test\\DummyTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', + 'Psr\\Log\\Test\\LoggerInterfaceTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', + 'Psr\\Log\\Test\\TestLogger' => $vendorDir . '/psr/log/Psr/Log/Test/TestLogger.php', 'Psr\\SimpleCache\\CacheException' => $vendorDir . '/psr/simple-cache/src/CacheException.php', 'Psr\\SimpleCache\\CacheInterface' => $vendorDir . '/psr/simple-cache/src/CacheInterface.php', 'Psr\\SimpleCache\\InvalidArgumentException' => $vendorDir . '/psr/simple-cache/src/InvalidArgumentException.php', @@ -835,6 +838,9 @@ return array( 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser' => $vendorDir . '/symfony/framework-bundle/Templating/TemplateNameParser.php', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference' => $vendorDir . '/symfony/framework-bundle/Templating/TemplateReference.php', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TimedPhpEngine' => $vendorDir . '/symfony/framework-bundle/Templating/TimedPhpEngine.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\ForwardCompatTestTrait' => $vendorDir . '/symfony/framework-bundle/Test/ForwardCompatTestTrait.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase' => $vendorDir . '/symfony/framework-bundle/Test/KernelTestCase.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase' => $vendorDir . '/symfony/framework-bundle/Test/WebTestCase.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpExtractor' => $vendorDir . '/symfony/framework-bundle/Translation/PhpExtractor.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpStringTokenParser' => $vendorDir . '/symfony/framework-bundle/Translation/PhpStringTokenParser.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\TranslationLoader' => $vendorDir . '/symfony/framework-bundle/Translation/TranslationLoader.php', @@ -1647,6 +1653,7 @@ return array( 'Symfony\\Component\\VarDumper\\Dumper\\DataDumperInterface' => $vendorDir . '/symfony/var-dumper/Dumper/DataDumperInterface.php', 'Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper' => $vendorDir . '/symfony/var-dumper/Dumper/HtmlDumper.php', 'Symfony\\Component\\VarDumper\\Exception\\ThrowingCasterException' => $vendorDir . '/symfony/var-dumper/Exception/ThrowingCasterException.php', + 'Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait' => $vendorDir . '/symfony/var-dumper/Test/VarDumperTestTrait.php', 'Symfony\\Component\\VarDumper\\VarDumper' => $vendorDir . '/symfony/var-dumper/VarDumper.php', 'Symfony\\Component\\Yaml\\Command\\LintCommand' => $vendorDir . '/symfony/yaml/Command/LintCommand.php', 'Symfony\\Component\\Yaml\\Dumper' => $vendorDir . '/symfony/yaml/Dumper.php', @@ -2049,6 +2056,11 @@ return array( 'Twig_Test' => $vendorDir . '/twig/twig/lib/Twig/Test.php', 'Twig_TestCallableInterface' => $vendorDir . '/twig/twig/lib/Twig/TestCallableInterface.php', 'Twig_TestInterface' => $vendorDir . '/twig/twig/lib/Twig/TestInterface.php', + 'Twig_Test_Function' => $vendorDir . '/twig/twig/lib/Twig/Test/Function.php', + 'Twig_Test_IntegrationTestCase' => $vendorDir . '/twig/twig/lib/Twig/Test/IntegrationTestCase.php', + 'Twig_Test_Method' => $vendorDir . '/twig/twig/lib/Twig/Test/Method.php', + 'Twig_Test_Node' => $vendorDir . '/twig/twig/lib/Twig/Test/Node.php', + 'Twig_Test_NodeTestCase' => $vendorDir . '/twig/twig/lib/Twig/Test/NodeTestCase.php', 'Twig_Token' => $vendorDir . '/twig/twig/lib/Twig/Token.php', 'Twig_TokenParser' => $vendorDir . '/twig/twig/lib/Twig/TokenParser.php', 'Twig_TokenParserBroker' => $vendorDir . '/twig/twig/lib/Twig/TokenParserBroker.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index c473bbec4..44b851639 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -826,6 +826,9 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php', 'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php', 'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php', + 'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', + 'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php', + 'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php', 'Psr\\SimpleCache\\CacheException' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheException.php', 'Psr\\SimpleCache\\CacheInterface' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheInterface.php', 'Psr\\SimpleCache\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/simple-cache/src/InvalidArgumentException.php', @@ -1065,6 +1068,9 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TemplateNameParser.php', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TemplateReference.php', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TimedPhpEngine' => __DIR__ . '/..' . '/symfony/framework-bundle/Templating/TimedPhpEngine.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\ForwardCompatTestTrait' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/ForwardCompatTestTrait.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/KernelTestCase.php', + 'Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase' => __DIR__ . '/..' . '/symfony/framework-bundle/Test/WebTestCase.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpExtractor' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/PhpExtractor.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\PhpStringTokenParser' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/PhpStringTokenParser.php', 'Symfony\\Bundle\\FrameworkBundle\\Translation\\TranslationLoader' => __DIR__ . '/..' . '/symfony/framework-bundle/Translation/TranslationLoader.php', @@ -1877,6 +1883,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Symfony\\Component\\VarDumper\\Dumper\\DataDumperInterface' => __DIR__ . '/..' . '/symfony/var-dumper/Dumper/DataDumperInterface.php', 'Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper' => __DIR__ . '/..' . '/symfony/var-dumper/Dumper/HtmlDumper.php', 'Symfony\\Component\\VarDumper\\Exception\\ThrowingCasterException' => __DIR__ . '/..' . '/symfony/var-dumper/Exception/ThrowingCasterException.php', + 'Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait' => __DIR__ . '/..' . '/symfony/var-dumper/Test/VarDumperTestTrait.php', 'Symfony\\Component\\VarDumper\\VarDumper' => __DIR__ . '/..' . '/symfony/var-dumper/VarDumper.php', 'Symfony\\Component\\Yaml\\Command\\LintCommand' => __DIR__ . '/..' . '/symfony/yaml/Command/LintCommand.php', 'Symfony\\Component\\Yaml\\Dumper' => __DIR__ . '/..' . '/symfony/yaml/Dumper.php', @@ -2279,6 +2286,11 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Twig_Test' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test.php', 'Twig_TestCallableInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/TestCallableInterface.php', 'Twig_TestInterface' => __DIR__ . '/..' . '/twig/twig/lib/Twig/TestInterface.php', + 'Twig_Test_Function' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test/Function.php', + 'Twig_Test_IntegrationTestCase' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test/IntegrationTestCase.php', + 'Twig_Test_Method' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test/Method.php', + 'Twig_Test_Node' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test/Node.php', + 'Twig_Test_NodeTestCase' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Test/NodeTestCase.php', 'Twig_Token' => __DIR__ . '/..' . '/twig/twig/lib/Twig/Token.php', 'Twig_TokenParser' => __DIR__ . '/..' . '/twig/twig/lib/Twig/TokenParser.php', 'Twig_TokenParserBroker' => __DIR__ . '/..' . '/twig/twig/lib/Twig/TokenParserBroker.php', diff --git a/lib/nikic/php-parser/test/PhpParser/AutoloaderTest.php b/lib/nikic/php-parser/test/PhpParser/AutoloaderTest.php new file mode 100644 index 000000000..8eeded839 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/AutoloaderTest.php @@ -0,0 +1,15 @@ +assertTrue(class_exists('PhpParser\NodeVisitorAbstract')); + $this->assertFalse(class_exists('PHPParser_NodeVisitor_NameResolver')); + + $this->assertFalse(class_exists('PhpParser\FooBar')); + $this->assertFalse(class_exists('PHPParser_FooBar')); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/ClassTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/ClassTest.php new file mode 100644 index 000000000..0f7418212 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/ClassTest.php @@ -0,0 +1,161 @@ +createClassBuilder('SomeLogger') + ->extend('BaseLogger') + ->implement('Namespaced\Logger', new Name('SomeInterface')) + ->implement('\Fully\Qualified', 'namespace\NamespaceRelative') + ->getNode() + ; + + $this->assertEquals( + new Stmt\Class_('SomeLogger', array( + 'extends' => new Name('BaseLogger'), + 'implements' => array( + new Name('Namespaced\Logger'), + new Name('SomeInterface'), + new Name\FullyQualified('Fully\Qualified'), + new Name\Relative('NamespaceRelative'), + ), + )), + $node + ); + } + + public function testAbstract() { + $node = $this->createClassBuilder('Test') + ->makeAbstract() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Class_('Test', array( + 'flags' => Stmt\Class_::MODIFIER_ABSTRACT + )), + $node + ); + } + + public function testFinal() { + $node = $this->createClassBuilder('Test') + ->makeFinal() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Class_('Test', array( + 'flags' => Stmt\Class_::MODIFIER_FINAL + )), + $node + ); + } + + public function testStatementOrder() { + $method = new Stmt\ClassMethod('testMethod'); + $property = new Stmt\Property( + Stmt\Class_::MODIFIER_PUBLIC, + array(new Stmt\PropertyProperty('testProperty')) + ); + $const = new Stmt\ClassConst(array( + new Node\Const_('TEST_CONST', new Node\Scalar\String_('ABC')) + )); + $use = new Stmt\TraitUse(array(new Name('SomeTrait'))); + + $node = $this->createClassBuilder('Test') + ->addStmt($method) + ->addStmt($property) + ->addStmts(array($const, $use)) + ->getNode() + ; + + $this->assertEquals( + new Stmt\Class_('Test', array( + 'stmts' => array($use, $const, $property, $method) + )), + $node + ); + } + + public function testDocComment() { + $docComment = <<<'DOC' +/** + * Test + */ +DOC; + $class = $this->createClassBuilder('Test') + ->setDocComment($docComment) + ->getNode(); + + $this->assertEquals( + new Stmt\Class_('Test', array(), array( + 'comments' => array( + new Comment\Doc($docComment) + ) + )), + $class + ); + + $class = $this->createClassBuilder('Test') + ->setDocComment(new Comment\Doc($docComment)) + ->getNode(); + + $this->assertEquals( + new Stmt\Class_('Test', array(), array( + 'comments' => array( + new Comment\Doc($docComment) + ) + )), + $class + ); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Unexpected node of type "Stmt_Echo" + */ + public function testInvalidStmtError() { + $this->createClassBuilder('Test') + ->addStmt(new Stmt\Echo_(array())) + ; + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Doc comment must be a string or an instance of PhpParser\Comment\Doc + */ + public function testInvalidDocComment() { + $this->createClassBuilder('Test') + ->setDocComment(new Comment('Test')); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Name cannot be empty + */ + public function testEmptyName() { + $this->createClassBuilder('Test') + ->extend(''); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Name must be a string or an instance of PhpParser\Node\Name + */ + public function testInvalidName() { + $this->createClassBuilder('Test') + ->extend(array('Foo')); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php new file mode 100644 index 000000000..f6a9381d6 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php @@ -0,0 +1,106 @@ +createFunctionBuilder('test') + ->makeReturnByRef() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Function_('test', array( + 'byRef' => true + )), + $node + ); + } + + public function testParams() { + $param1 = new Node\Param('test1'); + $param2 = new Node\Param('test2'); + $param3 = new Node\Param('test3'); + + $node = $this->createFunctionBuilder('test') + ->addParam($param1) + ->addParams(array($param2, $param3)) + ->getNode() + ; + + $this->assertEquals( + new Stmt\Function_('test', array( + 'params' => array($param1, $param2, $param3) + )), + $node + ); + } + + public function testStmts() { + $stmt1 = new Print_(new String_('test1')); + $stmt2 = new Print_(new String_('test2')); + $stmt3 = new Print_(new String_('test3')); + + $node = $this->createFunctionBuilder('test') + ->addStmt($stmt1) + ->addStmts(array($stmt2, $stmt3)) + ->getNode() + ; + + $this->assertEquals( + new Stmt\Function_('test', array( + 'stmts' => array($stmt1, $stmt2, $stmt3) + )), + $node + ); + } + + public function testDocComment() { + $node = $this->createFunctionBuilder('test') + ->setDocComment('/** Test */') + ->getNode(); + + $this->assertEquals(new Stmt\Function_('test', array(), array( + 'comments' => array(new Comment\Doc('/** Test */')) + )), $node); + } + + public function testReturnType() { + $node = $this->createFunctionBuilder('test') + ->setReturnType('void') + ->getNode(); + + $this->assertEquals(new Stmt\Function_('test', array( + 'returnType' => 'void' + ), array()), $node); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage void type cannot be nullable + */ + public function testInvalidNullableVoidType() { + $this->createFunctionBuilder('test')->setReturnType('?void'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Expected parameter node, got "Name" + */ + public function testInvalidParamError() { + $this->createFunctionBuilder('test') + ->addParam(new Node\Name('foo')) + ; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php new file mode 100644 index 000000000..72c586688 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php @@ -0,0 +1,105 @@ +builder = new Interface_('Contract'); + } + + private function dump($node) { + $pp = new \PhpParser\PrettyPrinter\Standard; + return $pp->prettyPrint(array($node)); + } + + public function testEmpty() { + $contract = $this->builder->getNode(); + $this->assertInstanceOf('PhpParser\Node\Stmt\Interface_', $contract); + $this->assertSame('Contract', $contract->name); + } + + public function testExtending() { + $contract = $this->builder->extend('Space\Root1', 'Root2')->getNode(); + $this->assertEquals( + new Stmt\Interface_('Contract', array( + 'extends' => array( + new Node\Name('Space\Root1'), + new Node\Name('Root2') + ), + )), $contract + ); + } + + public function testAddMethod() { + $method = new Stmt\ClassMethod('doSomething'); + $contract = $this->builder->addStmt($method)->getNode(); + $this->assertSame(array($method), $contract->stmts); + } + + public function testAddConst() { + $const = new Stmt\ClassConst(array( + new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458.0)) + )); + $contract = $this->builder->addStmt($const)->getNode(); + $this->assertSame(299792458.0, $contract->stmts[0]->consts[0]->value->value); + } + + public function testOrder() { + $const = new Stmt\ClassConst(array( + new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458)) + )); + $method = new Stmt\ClassMethod('doSomething'); + $contract = $this->builder + ->addStmt($method) + ->addStmt($const) + ->getNode() + ; + + $this->assertInstanceOf('PhpParser\Node\Stmt\ClassConst', $contract->stmts[0]); + $this->assertInstanceOf('PhpParser\Node\Stmt\ClassMethod', $contract->stmts[1]); + } + + public function testDocComment() { + $node = $this->builder + ->setDocComment('/** Test */') + ->getNode(); + + $this->assertEquals(new Stmt\Interface_('Contract', array(), array( + 'comments' => array(new Comment\Doc('/** Test */')) + )), $node); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Unexpected node of type "Stmt_PropertyProperty" + */ + public function testInvalidStmtError() { + $this->builder->addStmt(new Stmt\PropertyProperty('invalid')); + } + + public function testFullFunctional() { + $const = new Stmt\ClassConst(array( + new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458)) + )); + $method = new Stmt\ClassMethod('doSomething'); + $contract = $this->builder + ->addStmt($method) + ->addStmt($const) + ->getNode() + ; + + eval($this->dump($contract)); + + $this->assertTrue(interface_exists('Contract', false)); + } +} + diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/MethodTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/MethodTest.php new file mode 100644 index 000000000..21c5617a2 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/MethodTest.php @@ -0,0 +1,163 @@ +createMethodBuilder('test') + ->makePublic() + ->makeAbstract() + ->makeStatic() + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'flags' => Stmt\Class_::MODIFIER_PUBLIC + | Stmt\Class_::MODIFIER_ABSTRACT + | Stmt\Class_::MODIFIER_STATIC, + 'stmts' => null, + )), + $node + ); + + $node = $this->createMethodBuilder('test') + ->makeProtected() + ->makeFinal() + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'flags' => Stmt\Class_::MODIFIER_PROTECTED + | Stmt\Class_::MODIFIER_FINAL + )), + $node + ); + + $node = $this->createMethodBuilder('test') + ->makePrivate() + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'type' => Stmt\Class_::MODIFIER_PRIVATE + )), + $node + ); + } + + public function testReturnByRef() { + $node = $this->createMethodBuilder('test') + ->makeReturnByRef() + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'byRef' => true + )), + $node + ); + } + + public function testParams() { + $param1 = new Node\Param('test1'); + $param2 = new Node\Param('test2'); + $param3 = new Node\Param('test3'); + + $node = $this->createMethodBuilder('test') + ->addParam($param1) + ->addParams(array($param2, $param3)) + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'params' => array($param1, $param2, $param3) + )), + $node + ); + } + + public function testStmts() { + $stmt1 = new Print_(new String_('test1')); + $stmt2 = new Print_(new String_('test2')); + $stmt3 = new Print_(new String_('test3')); + + $node = $this->createMethodBuilder('test') + ->addStmt($stmt1) + ->addStmts(array($stmt2, $stmt3)) + ->getNode() + ; + + $this->assertEquals( + new Stmt\ClassMethod('test', array( + 'stmts' => array($stmt1, $stmt2, $stmt3) + )), + $node + ); + } + public function testDocComment() { + $node = $this->createMethodBuilder('test') + ->setDocComment('/** Test */') + ->getNode(); + + $this->assertEquals(new Stmt\ClassMethod('test', array(), array( + 'comments' => array(new Comment\Doc('/** Test */')) + )), $node); + } + + public function testReturnType() { + $node = $this->createMethodBuilder('test') + ->setReturnType('bool') + ->getNode(); + $this->assertEquals(new Stmt\ClassMethod('test', array( + 'returnType' => 'bool' + ), array()), $node); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add statements to an abstract method + */ + public function testAddStmtToAbstractMethodError() { + $this->createMethodBuilder('test') + ->makeAbstract() + ->addStmt(new Print_(new String_('test'))) + ; + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot make method with statements abstract + */ + public function testMakeMethodWithStmtsAbstractError() { + $this->createMethodBuilder('test') + ->addStmt(new Print_(new String_('test'))) + ->makeAbstract() + ; + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Expected parameter node, got "Name" + */ + public function testInvalidParamError() { + $this->createMethodBuilder('test') + ->addParam(new Node\Name('foo')) + ; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php new file mode 100644 index 000000000..88131fc33 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php @@ -0,0 +1,46 @@ + array($docComment)) + ); + + $node = $this->createNamespaceBuilder('Name\Space') + ->addStmt($stmt1) + ->addStmts(array($stmt2, $stmt3)) + ->setDocComment($docComment) + ->getNode() + ; + $this->assertEquals($expected, $node); + + $node = $this->createNamespaceBuilder(new Node\Name(array('Name', 'Space'))) + ->setDocComment($docComment) + ->addStmts(array($stmt1, $stmt2)) + ->addStmt($stmt3) + ->getNode() + ; + $this->assertEquals($expected, $node); + + $node = $this->createNamespaceBuilder(null)->getNode(); + $this->assertNull($node->name); + $this->assertEmpty($node->stmts); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/ParamTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/ParamTest.php new file mode 100644 index 000000000..e67ae99f2 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/ParamTest.php @@ -0,0 +1,171 @@ +createParamBuilder('test') + ->setDefault($value) + ->getNode() + ; + + $this->assertEquals($expectedValueNode, $node->default); + } + + public function provideTestDefaultValues() { + return array( + array( + null, + new Expr\ConstFetch(new Node\Name('null')) + ), + array( + true, + new Expr\ConstFetch(new Node\Name('true')) + ), + array( + false, + new Expr\ConstFetch(new Node\Name('false')) + ), + array( + 31415, + new Scalar\LNumber(31415) + ), + array( + 3.1415, + new Scalar\DNumber(3.1415) + ), + array( + 'Hallo World', + new Scalar\String_('Hallo World') + ), + array( + array(1, 2, 3), + new Expr\Array_(array( + new Expr\ArrayItem(new Scalar\LNumber(1)), + new Expr\ArrayItem(new Scalar\LNumber(2)), + new Expr\ArrayItem(new Scalar\LNumber(3)), + )) + ), + array( + array('foo' => 'bar', 'bar' => 'foo'), + new Expr\Array_(array( + new Expr\ArrayItem( + new Scalar\String_('bar'), + new Scalar\String_('foo') + ), + new Expr\ArrayItem( + new Scalar\String_('foo'), + new Scalar\String_('bar') + ), + )) + ), + array( + new Scalar\MagicConst\Dir, + new Scalar\MagicConst\Dir + ) + ); + } + + /** + * @dataProvider provideTestTypeHints + */ + public function testTypeHints($typeHint, $expectedType) { + $node = $this->createParamBuilder('test') + ->setTypeHint($typeHint) + ->getNode() + ; + $type = $node->type; + + /* Manually implement comparison to avoid __toString stupidity */ + if ($expectedType instanceof Node\NullableType) { + $this->assertInstanceOf(get_class($expectedType), $type); + $expectedType = $expectedType->type; + $type = $type->type; + } + + if ($expectedType instanceof Node\Name) { + $this->assertInstanceOf(get_class($expectedType), $type); + $this->assertEquals($expectedType, $type); + } else { + $this->assertSame($expectedType, $type); + } + } + + public function provideTestTypeHints() { + return array( + array('array', 'array'), + array('callable', 'callable'), + array('bool', 'bool'), + array('int', 'int'), + array('float', 'float'), + array('string', 'string'), + array('iterable', 'iterable'), + array('object', 'object'), + array('Array', 'array'), + array('CALLABLE', 'callable'), + array('Some\Class', new Node\Name('Some\Class')), + array('\Foo', new Node\Name\FullyQualified('Foo')), + array('self', new Node\Name('self')), + array('?array', new Node\NullableType('array')), + array('?Some\Class', new Node\NullableType(new Node\Name('Some\Class'))), + array(new Node\Name('Some\Class'), new Node\Name('Some\Class')), + array(new Node\NullableType('int'), new Node\NullableType('int')), + array( + new Node\NullableType(new Node\Name('Some\Class')), + new Node\NullableType(new Node\Name('Some\Class')) + ), + ); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Parameter type cannot be void + */ + public function testVoidTypeError() { + $this->createParamBuilder('test')->setTypeHint('void'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Type must be a string, or an instance of Name or NullableType + */ + public function testInvalidTypeError() { + $this->createParamBuilder('test')->setTypeHint(new \stdClass); + } + + public function testByRef() { + $node = $this->createParamBuilder('test') + ->makeByRef() + ->getNode() + ; + + $this->assertEquals( + new Node\Param('test', null, null, true), + $node + ); + } + + public function testVariadic() { + $node = $this->createParamBuilder('test') + ->makeVariadic() + ->getNode() + ; + + $this->assertEquals( + new Node\Param('test', null, null, false, true), + $node + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php new file mode 100644 index 000000000..de8f4ce63 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php @@ -0,0 +1,147 @@ +createPropertyBuilder('test') + ->makePrivate() + ->makeStatic() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Property( + Stmt\Class_::MODIFIER_PRIVATE + | Stmt\Class_::MODIFIER_STATIC, + array( + new Stmt\PropertyProperty('test') + ) + ), + $node + ); + + $node = $this->createPropertyBuilder('test') + ->makeProtected() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Property( + Stmt\Class_::MODIFIER_PROTECTED, + array( + new Stmt\PropertyProperty('test') + ) + ), + $node + ); + + $node = $this->createPropertyBuilder('test') + ->makePublic() + ->getNode() + ; + + $this->assertEquals( + new Stmt\Property( + Stmt\Class_::MODIFIER_PUBLIC, + array( + new Stmt\PropertyProperty('test') + ) + ), + $node + ); + } + + public function testDocComment() { + $node = $this->createPropertyBuilder('test') + ->setDocComment('/** Test */') + ->getNode(); + + $this->assertEquals(new Stmt\Property( + Stmt\Class_::MODIFIER_PUBLIC, + array( + new Stmt\PropertyProperty('test') + ), + array( + 'comments' => array(new Comment\Doc('/** Test */')) + ) + ), $node); + } + + /** + * @dataProvider provideTestDefaultValues + */ + public function testDefaultValues($value, $expectedValueNode) { + $node = $this->createPropertyBuilder('test') + ->setDefault($value) + ->getNode() + ; + + $this->assertEquals($expectedValueNode, $node->props[0]->default); + } + + public function provideTestDefaultValues() { + return array( + array( + null, + new Expr\ConstFetch(new Name('null')) + ), + array( + true, + new Expr\ConstFetch(new Name('true')) + ), + array( + false, + new Expr\ConstFetch(new Name('false')) + ), + array( + 31415, + new Scalar\LNumber(31415) + ), + array( + 3.1415, + new Scalar\DNumber(3.1415) + ), + array( + 'Hallo World', + new Scalar\String_('Hallo World') + ), + array( + array(1, 2, 3), + new Expr\Array_(array( + new Expr\ArrayItem(new Scalar\LNumber(1)), + new Expr\ArrayItem(new Scalar\LNumber(2)), + new Expr\ArrayItem(new Scalar\LNumber(3)), + )) + ), + array( + array('foo' => 'bar', 'bar' => 'foo'), + new Expr\Array_(array( + new Expr\ArrayItem( + new Scalar\String_('bar'), + new Scalar\String_('foo') + ), + new Expr\ArrayItem( + new Scalar\String_('foo'), + new Scalar\String_('bar') + ), + )) + ), + array( + new Scalar\MagicConst\Dir, + new Scalar\MagicConst\Dir + ) + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/TraitTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/TraitTest.php new file mode 100644 index 000000000..874bc4d27 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/TraitTest.php @@ -0,0 +1,48 @@ +createTraitBuilder('TestTrait') + ->setDocComment('/** Nice trait */') + ->addStmt($method1) + ->addStmts([$method2, $method3]) + ->addStmt($prop) + ->addStmt($use) + ->getNode(); + $this->assertEquals(new Stmt\Trait_('TestTrait', [ + 'stmts' => [$use, $prop, $method1, $method2, $method3] + ], [ + 'comments' => [ + new Comment\Doc('/** Nice trait */') + ] + ]), $trait); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Unexpected node of type "Stmt_Echo" + */ + public function testInvalidStmtError() { + $this->createTraitBuilder('Test') + ->addStmt(new Stmt\Echo_(array())) + ; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Builder/UseTest.php b/lib/nikic/php-parser/test/PhpParser/Builder/UseTest.php new file mode 100644 index 000000000..adaeb3a5e --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Builder/UseTest.php @@ -0,0 +1,35 @@ +createUseBuilder('Foo\Bar')->getNode(); + $this->assertEquals(new Stmt\Use_(array( + new Stmt\UseUse(new Name('Foo\Bar'), 'Bar') + )), $node); + + $node = $this->createUseBuilder(new Name('Foo\Bar'))->as('XYZ')->getNode(); + $this->assertEquals(new Stmt\Use_(array( + new Stmt\UseUse(new Name('Foo\Bar'), 'XYZ') + )), $node); + + $node = $this->createUseBuilder('foo\bar', Stmt\Use_::TYPE_FUNCTION)->as('foo')->getNode(); + $this->assertEquals(new Stmt\Use_(array( + new Stmt\UseUse(new Name('foo\bar'), 'foo') + ), Stmt\Use_::TYPE_FUNCTION), $node); + } + + public function testNonExistingMethod() { + $this->setExpectedException('LogicException', 'Method "foo" does not exist'); + $builder = $this->createUseBuilder('Test'); + $builder->foo(); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php b/lib/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php new file mode 100644 index 000000000..1c3ef18df --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php @@ -0,0 +1,108 @@ +assertInstanceOf($className, $factory->$methodName('test')); + } + + public function provideTestFactory() { + return array( + array('namespace', 'PhpParser\Builder\Namespace_'), + array('class', 'PhpParser\Builder\Class_'), + array('interface', 'PhpParser\Builder\Interface_'), + array('trait', 'PhpParser\Builder\Trait_'), + array('method', 'PhpParser\Builder\Method'), + array('function', 'PhpParser\Builder\Function_'), + array('property', 'PhpParser\Builder\Property'), + array('param', 'PhpParser\Builder\Param'), + array('use', 'PhpParser\Builder\Use_'), + ); + } + + public function testNonExistingMethod() { + $this->setExpectedException('LogicException', 'Method "foo" does not exist'); + $factory = new BuilderFactory(); + $factory->foo(); + } + + public function testIntegration() { + $factory = new BuilderFactory; + $node = $factory->namespace('Name\Space') + ->addStmt($factory->use('Foo\Bar\SomeOtherClass')) + ->addStmt($factory->use('Foo\Bar')->as('A')) + ->addStmt($factory + ->class('SomeClass') + ->extend('SomeOtherClass') + ->implement('A\Few', '\Interfaces') + ->makeAbstract() + + ->addStmt($factory->method('firstMethod')) + + ->addStmt($factory->method('someMethod') + ->makePublic() + ->makeAbstract() + ->addParam($factory->param('someParam')->setTypeHint('SomeClass')) + ->setDocComment('/** + * This method does something. + * + * @param SomeClass And takes a parameter + */')) + + ->addStmt($factory->method('anotherMethod') + ->makeProtected() + ->addParam($factory->param('someParam')->setDefault('test')) + ->addStmt(new Expr\Print_(new Expr\Variable('someParam')))) + + ->addStmt($factory->property('someProperty')->makeProtected()) + ->addStmt($factory->property('anotherProperty') + ->makePrivate() + ->setDefault(array(1, 2, 3)))) + ->getNode() + ; + + $expected = <<<'EOC' +prettyPrintFile($stmts); + + $this->assertEquals( + str_replace("\r\n", "\n", $expected), + str_replace("\r\n", "\n", $generated) + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/CodeParsingTest.php b/lib/nikic/php-parser/test/PhpParser/CodeParsingTest.php new file mode 100644 index 000000000..1a4a9ad1d --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/CodeParsingTest.php @@ -0,0 +1,70 @@ + array( + 'startLine', 'endLine', 'startFilePos', 'endFilePos', 'comments' + ))); + $parser5 = new Parser\Php5($lexer); + $parser7 = new Parser\Php7($lexer); + + $dumpPositions = isset($modes['positions']); + $output5 = $this->getParseOutput($parser5, $code, $dumpPositions); + $output7 = $this->getParseOutput($parser7, $code, $dumpPositions); + + if (isset($modes['php5'])) { + $this->assertSame($expected, $output5, $name); + $this->assertNotSame($expected, $output7, $name); + } else if (isset($modes['php7'])) { + $this->assertNotSame($expected, $output5, $name); + $this->assertSame($expected, $output7, $name); + } else { + $this->assertSame($expected, $output5, $name); + $this->assertSame($expected, $output7, $name); + } + } + + private function getParseOutput(Parser $parser, $code, $dumpPositions) { + $errors = new ErrorHandler\Collecting; + $stmts = $parser->parse($code, $errors); + + $output = ''; + foreach ($errors->getErrors() as $error) { + $output .= $this->formatErrorMessage($error, $code) . "\n"; + } + + if (null !== $stmts) { + $dumper = new NodeDumper(['dumpComments' => true, 'dumpPositions' => $dumpPositions]); + $output .= $dumper->dump($stmts, $code); + } + + return canonicalize($output); + } + + public function provideTestParse() { + return $this->getTests(__DIR__ . '/../code/parser', 'test'); + } + + private function formatErrorMessage(Error $e, $code) { + if ($e->hasColumnInfo()) { + return $e->getMessageWithColumnInfo($code); + } else { + return $e->getMessage(); + } + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/CodeTestAbstract.php b/lib/nikic/php-parser/test/PhpParser/CodeTestAbstract.php new file mode 100644 index 000000000..369ee41b8 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/CodeTestAbstract.php @@ -0,0 +1,61 @@ +getPathname(); + $fileContents = file_get_contents($fileName); + $fileContents = canonicalize($fileContents); + + // evaluate @@{expr}@@ expressions + $fileContents = preg_replace_callback( + '/@@\{(.*?)\}@@/', + function($matches) { + return eval('return ' . $matches[1] . ';'); + }, + $fileContents + ); + + // parse sections + $parts = preg_split("/\n-----(?:\n|$)/", $fileContents); + + // first part is the name + $name = array_shift($parts) . ' (' . $fileName . ')'; + $shortName = ltrim(str_replace($directory, '', $fileName), '/\\'); + + // multiple sections possible with always two forming a pair + $chunks = array_chunk($parts, 2); + foreach ($chunks as $i => $chunk) { + $dataSetName = $shortName . (count($chunks) > 1 ? '#' . $i : ''); + list($expected, $mode) = $this->extractMode($chunk[1]); + $tests[$dataSetName] = array($name, $chunk[0], $expected, $mode); + } + } + + return $tests; + } + + private function extractMode($expected) { + $firstNewLine = strpos($expected, "\n"); + if (false === $firstNewLine) { + $firstNewLine = strlen($expected); + } + + $firstLine = substr($expected, 0, $firstNewLine); + if (0 !== strpos($firstLine, '!!')) { + return [$expected, null]; + } + + $expected = (string) substr($expected, $firstNewLine + 1); + return [$expected, substr($firstLine, 2)]; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/CommentTest.php b/lib/nikic/php-parser/test/PhpParser/CommentTest.php new file mode 100644 index 000000000..081dd57b7 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/CommentTest.php @@ -0,0 +1,73 @@ +assertSame('/* Some comment */', $comment->getText()); + $this->assertSame('/* Some comment */', (string) $comment); + $this->assertSame(1, $comment->getLine()); + $this->assertSame(10, $comment->getFilePos()); + } + + /** + * @dataProvider provideTestReformatting + */ + public function testReformatting($commentText, $reformattedText) { + $comment = new Comment($commentText); + $this->assertSame($reformattedText, $comment->getReformattedText()); + } + + public function provideTestReformatting() { + return array( + array('// Some text' . "\n", '// Some text'), + array('/* Some text */', '/* Some text */'), + array( + '/** + * Some text. + * Some more text. + */', + '/** + * Some text. + * Some more text. + */' + ), + array( + '/* + Some text. + Some more text. + */', + '/* + Some text. + Some more text. +*/' + ), + array( + '/* Some text. + More text. + Even more text. */', + '/* Some text. + More text. + Even more text. */' + ), + array( + '/* Some text. + More text. + Indented text. */', + '/* Some text. + More text. + Indented text. */', + ), + // invalid comment -> no reformatting + array( + 'hallo + world', + 'hallo + world', + ), + ); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/ErrorHandler/CollectingTest.php b/lib/nikic/php-parser/test/PhpParser/ErrorHandler/CollectingTest.php new file mode 100644 index 000000000..37429817e --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/ErrorHandler/CollectingTest.php @@ -0,0 +1,22 @@ +assertFalse($errorHandler->hasErrors()); + $this->assertEmpty($errorHandler->getErrors()); + + $errorHandler->handleError($e1 = new Error('Test 1')); + $errorHandler->handleError($e2 = new Error('Test 2')); + $this->assertTrue($errorHandler->hasErrors()); + $this->assertSame([$e1, $e2], $errorHandler->getErrors()); + + $errorHandler->clearErrors(); + $this->assertFalse($errorHandler->hasErrors()); + $this->assertEmpty($errorHandler->getErrors()); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/ErrorHandler/ThrowingTest.php b/lib/nikic/php-parser/test/PhpParser/ErrorHandler/ThrowingTest.php new file mode 100644 index 000000000..d7df7c267 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/ErrorHandler/ThrowingTest.php @@ -0,0 +1,16 @@ +handleError(new Error('Test')); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/ErrorTest.php b/lib/nikic/php-parser/test/PhpParser/ErrorTest.php new file mode 100644 index 000000000..59e880c30 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/ErrorTest.php @@ -0,0 +1,106 @@ + 10, + 'endLine' => 11, + ); + $error = new Error('Some error', $attributes); + + $this->assertSame('Some error', $error->getRawMessage()); + $this->assertSame($attributes, $error->getAttributes()); + $this->assertSame(10, $error->getStartLine()); + $this->assertSame(11, $error->getEndLine()); + $this->assertSame('Some error on line 10', $error->getMessage()); + + return $error; + } + + /** + * @depends testConstruct + */ + public function testSetMessageAndLine(Error $error) { + $error->setRawMessage('Some other error'); + $this->assertSame('Some other error', $error->getRawMessage()); + + $error->setStartLine(15); + $this->assertSame(15, $error->getStartLine()); + $this->assertSame('Some other error on line 15', $error->getMessage()); + } + + public function testUnknownLine() { + $error = new Error('Some error'); + + $this->assertSame(-1, $error->getStartLine()); + $this->assertSame(-1, $error->getEndLine()); + $this->assertSame('Some error on unknown line', $error->getMessage()); + } + + /** @dataProvider provideTestColumnInfo */ + public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColumn) { + $error = new Error('Some error', array( + 'startFilePos' => $startPos, + 'endFilePos' => $endPos, + )); + + $this->assertSame(true, $error->hasColumnInfo()); + $this->assertSame($startColumn, $error->getStartColumn($code)); + $this->assertSame($endColumn, $error->getEndColumn($code)); + + } + + public function provideTestColumnInfo() { + return array( + // Error at "bar" + array("assertSame(false, $error->hasColumnInfo()); + try { + $error->getStartColumn(''); + $this->fail('Expected RuntimeException'); + } catch (\RuntimeException $e) { + $this->assertSame('Error does not have column information', $e->getMessage()); + } + try { + $error->getEndColumn(''); + $this->fail('Expected RuntimeException'); + } catch (\RuntimeException $e) { + $this->assertSame('Error does not have column information', $e->getMessage()); + } + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Invalid position information + */ + public function testInvalidPosInfo() { + $error = new Error('Some error', array( + 'startFilePos' => 10, + 'endFilePos' => 11, + )); + $error->getStartColumn('code'); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php b/lib/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php new file mode 100644 index 000000000..f1fe6183a --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php @@ -0,0 +1,133 @@ +getLexer(); + $lexer->startLexing('assertSame($expectedToken, $lexer->getNextToken()); + $this->assertSame(0, $lexer->getNextToken()); + } + + /** + * @dataProvider provideTestReplaceKeywords + */ + public function testNoReplaceKeywordsAfterObjectOperator($keyword) { + $lexer = $this->getLexer(); + $lexer->startLexing('' . $keyword); + + $this->assertSame(Tokens::T_OBJECT_OPERATOR, $lexer->getNextToken()); + $this->assertSame(Tokens::T_STRING, $lexer->getNextToken()); + $this->assertSame(0, $lexer->getNextToken()); + } + + public function provideTestReplaceKeywords() { + return array( + // PHP 5.5 + array('finally', Tokens::T_FINALLY), + array('yield', Tokens::T_YIELD), + + // PHP 5.4 + array('callable', Tokens::T_CALLABLE), + array('insteadof', Tokens::T_INSTEADOF), + array('trait', Tokens::T_TRAIT), + array('__TRAIT__', Tokens::T_TRAIT_C), + + // PHP 5.3 + array('__DIR__', Tokens::T_DIR), + array('goto', Tokens::T_GOTO), + array('namespace', Tokens::T_NAMESPACE), + array('__NAMESPACE__', Tokens::T_NS_C), + ); + } + + /** + * @dataProvider provideTestLexNewFeatures + */ + public function testLexNewFeatures($code, array $expectedTokens) { + $lexer = $this->getLexer(); + $lexer->startLexing('assertSame($expectedTokenType, $lexer->getNextToken($text)); + $this->assertSame($expectedTokenText, $text); + } + $this->assertSame(0, $lexer->getNextToken()); + } + + /** + * @dataProvider provideTestLexNewFeatures + */ + public function testLeaveStuffAloneInStrings($code) { + $stringifiedToken = '"' . addcslashes($code, '"\\') . '"'; + + $lexer = $this->getLexer(); + $lexer->startLexing('assertSame(Tokens::T_CONSTANT_ENCAPSED_STRING, $lexer->getNextToken($text)); + $this->assertSame($stringifiedToken, $text); + $this->assertSame(0, $lexer->getNextToken()); + } + + public function provideTestLexNewFeatures() { + return array( + array('yield from', array( + array(Tokens::T_YIELD_FROM, 'yield from'), + )), + array("yield\r\nfrom", array( + array(Tokens::T_YIELD_FROM, "yield\r\nfrom"), + )), + array('...', array( + array(Tokens::T_ELLIPSIS, '...'), + )), + array('**', array( + array(Tokens::T_POW, '**'), + )), + array('**=', array( + array(Tokens::T_POW_EQUAL, '**='), + )), + array('??', array( + array(Tokens::T_COALESCE, '??'), + )), + array('<=>', array( + array(Tokens::T_SPACESHIP, '<=>'), + )), + array('0b1010110', array( + array(Tokens::T_LNUMBER, '0b1010110'), + )), + array('0b1011010101001010110101010010101011010101010101101011001110111100', array( + array(Tokens::T_DNUMBER, '0b1011010101001010110101010010101011010101010101101011001110111100'), + )), + array('\\', array( + array(Tokens::T_NS_SEPARATOR, '\\'), + )), + array("<<<'NOWDOC'\nNOWDOC;\n", array( + array(Tokens::T_START_HEREDOC, "<<<'NOWDOC'\n"), + array(Tokens::T_END_HEREDOC, 'NOWDOC'), + array(ord(';'), ';'), + )), + array("<<<'NOWDOC'\nFoobar\nNOWDOC;\n", array( + array(Tokens::T_START_HEREDOC, "<<<'NOWDOC'\n"), + array(Tokens::T_ENCAPSED_AND_WHITESPACE, "Foobar\n"), + array(Tokens::T_END_HEREDOC, 'NOWDOC'), + array(ord(';'), ';'), + )), + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/LexerTest.php b/lib/nikic/php-parser/test/PhpParser/LexerTest.php new file mode 100644 index 000000000..bf7a5d32f --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/LexerTest.php @@ -0,0 +1,265 @@ +markTestSkipped('HHVM does not throw warnings from token_get_all()'); + } + + $errorHandler = new ErrorHandler\Collecting(); + $lexer = $this->getLexer(['usedAttributes' => [ + 'comments', 'startLine', 'endLine', 'startFilePos', 'endFilePos' + ]]); + $lexer->startLexing($code, $errorHandler); + $errors = $errorHandler->getErrors(); + + $this->assertSame(count($messages), count($errors)); + for ($i = 0; $i < count($messages); $i++) { + $this->assertSame($messages[$i], $errors[$i]->getMessageWithColumnInfo($code)); + } + } + + public function provideTestError() { + return array( + array("getLexer($options); + $lexer->startLexing($code); + while ($id = $lexer->getNextToken($value, $startAttributes, $endAttributes)) { + $token = array_shift($tokens); + + $this->assertSame($token[0], $id); + $this->assertSame($token[1], $value); + $this->assertEquals($token[2], $startAttributes); + $this->assertEquals($token[3], $endAttributes); + } + } + + public function provideTestLex() { + return array( + // tests conversion of closing PHP tag and drop of whitespace and opening tags + array( + 'plaintext', + array(), + array( + array( + Tokens::T_STRING, 'tokens', + array('startLine' => 1), array('endLine' => 1) + ), + array( + ord(';'), '?>', + array('startLine' => 1), array('endLine' => 1) + ), + array( + Tokens::T_INLINE_HTML, 'plaintext', + array('startLine' => 1, 'hasLeadingNewline' => false), + array('endLine' => 1) + ), + ) + ), + // tests line numbers + array( + ' 2), array('endLine' => 2) + ), + array( + Tokens::T_STRING, 'token', + array('startLine' => 2), array('endLine' => 2) + ), + array( + ord('$'), '$', + array( + 'startLine' => 3, + 'comments' => array( + new Comment\Doc('/** doc' . "\n" . 'comment */', 2, 14), + ) + ), + array('endLine' => 3) + ), + ) + ), + // tests comment extraction + array( + ' 2, + 'comments' => array( + new Comment('/* comment */', 1, 6), + new Comment('// comment' . "\n", 1, 20), + new Comment\Doc('/** docComment 1 */', 2, 31), + new Comment\Doc('/** docComment 2 */', 2, 50), + ), + ), + array('endLine' => 2) + ), + ) + ), + // tests differing start and end line + array( + ' 1), array('endLine' => 2) + ), + ) + ), + // tests exact file offsets + array( + ' array('startFilePos', 'endFilePos')), + array( + array( + Tokens::T_CONSTANT_ENCAPSED_STRING, '"a"', + array('startFilePos' => 6), array('endFilePos' => 8) + ), + array( + ord(';'), ';', + array('startFilePos' => 9), array('endFilePos' => 9) + ), + array( + Tokens::T_CONSTANT_ENCAPSED_STRING, '"b"', + array('startFilePos' => 18), array('endFilePos' => 20) + ), + array( + ord(';'), ';', + array('startFilePos' => 21), array('endFilePos' => 21) + ), + ) + ), + // tests token offsets + array( + ' array('startTokenPos', 'endTokenPos')), + array( + array( + Tokens::T_CONSTANT_ENCAPSED_STRING, '"a"', + array('startTokenPos' => 1), array('endTokenPos' => 1) + ), + array( + ord(';'), ';', + array('startTokenPos' => 2), array('endTokenPos' => 2) + ), + array( + Tokens::T_CONSTANT_ENCAPSED_STRING, '"b"', + array('startTokenPos' => 5), array('endTokenPos' => 5) + ), + array( + ord(';'), ';', + array('startTokenPos' => 6), array('endTokenPos' => 6) + ), + ) + ), + // tests all attributes being disabled + array( + ' array()), + array( + array( + Tokens::T_VARIABLE, '$bar', + array(), array() + ), + array( + ord(';'), ';', + array(), array() + ) + ) + ), + // tests no tokens + array( + '', + array(), + array() + ), + ); + } + + /** + * @dataProvider provideTestHaltCompiler + */ + public function testHandleHaltCompiler($code, $remaining) { + $lexer = $this->getLexer(); + $lexer->startLexing($code); + + while (Tokens::T_HALT_COMPILER !== $lexer->getNextToken()); + + $this->assertSame($remaining, $lexer->handleHaltCompiler()); + $this->assertSame(0, $lexer->getNextToken()); + } + + public function provideTestHaltCompiler() { + return array( + array('Remaining Text', 'Remaining Text'), + //array('getLexer(); + $lexer->startLexing('getNextToken()); + $lexer->handleHaltCompiler(); + } + + public function testGetTokens() { + $code = 'getLexer(); + $lexer->startLexing($code); + $this->assertSame($expectedTokens, $lexer->getTokens()); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Node/NameTest.php b/lib/nikic/php-parser/test/PhpParser/Node/NameTest.php new file mode 100644 index 000000000..76a89c3ec --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/NameTest.php @@ -0,0 +1,134 @@ +assertSame(array('foo', 'bar'), $name->parts); + + $name = new Name('foo\bar'); + $this->assertSame(array('foo', 'bar'), $name->parts); + + $name = new Name($name); + $this->assertSame(array('foo', 'bar'), $name->parts); + } + + public function testGet() { + $name = new Name('foo'); + $this->assertSame('foo', $name->getFirst()); + $this->assertSame('foo', $name->getLast()); + + $name = new Name('foo\bar'); + $this->assertSame('foo', $name->getFirst()); + $this->assertSame('bar', $name->getLast()); + } + + public function testToString() { + $name = new Name('foo\bar'); + + $this->assertSame('foo\bar', (string) $name); + $this->assertSame('foo\bar', $name->toString()); + } + + public function testSlice() { + $name = new Name('foo\bar\baz'); + $this->assertEquals(new Name('foo\bar\baz'), $name->slice(0)); + $this->assertEquals(new Name('bar\baz'), $name->slice(1)); + $this->assertNull($name->slice(3)); + $this->assertEquals(new Name('foo\bar\baz'), $name->slice(-3)); + $this->assertEquals(new Name('bar\baz'), $name->slice(-2)); + $this->assertEquals(new Name('foo\bar'), $name->slice(0, -1)); + $this->assertNull($name->slice(0, -3)); + $this->assertEquals(new Name('bar'), $name->slice(1, -1)); + $this->assertNull($name->slice(1, -2)); + $this->assertEquals(new Name('bar'), $name->slice(-2, 1)); + $this->assertEquals(new Name('bar'), $name->slice(-2, -1)); + $this->assertNull($name->slice(-2, -2)); + } + + /** + * @expectedException \OutOfBoundsException + * @expectedExceptionMessage Offset 4 is out of bounds + */ + public function testSliceOffsetTooLarge() { + (new Name('foo\bar\baz'))->slice(4); + } + + /** + * @expectedException \OutOfBoundsException + * @expectedExceptionMessage Offset -4 is out of bounds + */ + public function testSliceOffsetTooSmall() { + (new Name('foo\bar\baz'))->slice(-4); + } + + /** + * @expectedException \OutOfBoundsException + * @expectedExceptionMessage Length 4 is out of bounds + */ + public function testSliceLengthTooLarge() { + (new Name('foo\bar\baz'))->slice(0, 4); + } + + /** + * @expectedException \OutOfBoundsException + * @expectedExceptionMessage Length -4 is out of bounds + */ + public function testSliceLengthTooSmall() { + (new Name('foo\bar\baz'))->slice(0, -4); + } + + public function testConcat() { + $this->assertEquals(new Name('foo\bar\baz'), Name::concat('foo', 'bar\baz')); + $this->assertEquals( + new Name\FullyQualified('foo\bar'), + Name\FullyQualified::concat(['foo'], new Name('bar')) + ); + + $attributes = ['foo' => 'bar']; + $this->assertEquals( + new Name\Relative('foo\bar\baz', $attributes), + Name\Relative::concat(new Name\FullyQualified('foo\bar'), 'baz', $attributes) + ); + + $this->assertEquals(new Name('foo'), Name::concat(null, 'foo')); + $this->assertEquals(new Name('foo'), Name::concat('foo', null)); + $this->assertNull(Name::concat(null, null)); + } + + public function testIs() { + $name = new Name('foo'); + $this->assertTrue ($name->isUnqualified()); + $this->assertFalse($name->isQualified()); + $this->assertFalse($name->isFullyQualified()); + $this->assertFalse($name->isRelative()); + + $name = new Name('foo\bar'); + $this->assertFalse($name->isUnqualified()); + $this->assertTrue ($name->isQualified()); + $this->assertFalse($name->isFullyQualified()); + $this->assertFalse($name->isRelative()); + + $name = new Name\FullyQualified('foo'); + $this->assertFalse($name->isUnqualified()); + $this->assertFalse($name->isQualified()); + $this->assertTrue ($name->isFullyQualified()); + $this->assertFalse($name->isRelative()); + + $name = new Name\Relative('foo'); + $this->assertFalse($name->isUnqualified()); + $this->assertFalse($name->isQualified()); + $this->assertFalse($name->isFullyQualified()); + $this->assertTrue ($name->isRelative()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Expected string, array of parts or Name instance + */ + public function testInvalidArg() { + Name::concat('foo', new \stdClass); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php new file mode 100644 index 000000000..3141f563d --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php @@ -0,0 +1,25 @@ +assertSame($name, $magicConst->getName()); + } + + public function provideTestGetName() { + return array( + array(new MagicConst\Class_, '__CLASS__'), + array(new MagicConst\Dir, '__DIR__'), + array(new MagicConst\File, '__FILE__'), + array(new MagicConst\Function_, '__FUNCTION__'), + array(new MagicConst\Line, '__LINE__'), + array(new MagicConst\Method, '__METHOD__'), + array(new MagicConst\Namespace_, '__NAMESPACE__'), + array(new MagicConst\Trait_, '__TRAIT__'), + ); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php new file mode 100644 index 000000000..be3903578 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php @@ -0,0 +1,61 @@ +assertSame( + $expected, + String_::parseEscapeSequences($string, $quote) + ); + } + + /** + * @dataProvider provideTestParse + */ + public function testCreate($expected, $string) { + $this->assertSame( + $expected, + String_::parse($string) + ); + } + + public function provideTestParseEscapeSequences() { + return array( + array('"', '\\"', '"'), + array('\\"', '\\"', '`'), + array('\\"\\`', '\\"\\`', null), + array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null), + array("\x1B", '\e', null), + array(chr(255), '\xFF', null), + array(chr(255), '\377', null), + array(chr(0), '\400', null), + array("\0", '\0', null), + array('\xFF', '\\\\xFF', null), + ); + } + + public function provideTestParse() { + $tests = array( + array('A', '\'A\''), + array('A', 'b\'A\''), + array('A', '"A"'), + array('A', 'b"A"'), + array('\\', '\'\\\\\''), + array('\'', '\'\\\'\''), + ); + + foreach ($this->provideTestParseEscapeSequences() as $i => $test) { + // skip second and third tests, they aren't for double quotes + if ($i != 1 && $i != 2) { + $tests[] = array($test[0], '"' . $test[1] . '"'); + } + } + + return $tests; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php new file mode 100644 index 000000000..610972c6b --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php @@ -0,0 +1,35 @@ +assertTrue($node->{'is' . $modifier}()); + } + + public function testNoModifiers() { + $node = new ClassConst(array(), 0); + + $this->assertTrue($node->isPublic()); + $this->assertFalse($node->isProtected()); + $this->assertFalse($node->isPrivate()); + $this->assertFalse($node->isStatic()); + } + + public function provideModifiers() { + return array( + array('public'), + array('protected'), + array('private'), + ); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php new file mode 100644 index 000000000..fa8aed808 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php @@ -0,0 +1,63 @@ + constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)) + )); + + $this->assertTrue($node->{'is' . $modifier}()); + } + + public function testNoModifiers() { + $node = new ClassMethod('foo', array('type' => 0)); + + $this->assertTrue($node->isPublic()); + $this->assertFalse($node->isProtected()); + $this->assertFalse($node->isPrivate()); + $this->assertFalse($node->isAbstract()); + $this->assertFalse($node->isFinal()); + $this->assertFalse($node->isStatic()); + } + + public function provideModifiers() { + return array( + array('public'), + array('protected'), + array('private'), + array('abstract'), + array('final'), + array('static'), + ); + } + + /** + * Checks that implicit public modifier detection for method is working + * + * @dataProvider implicitPublicModifiers + * + * @param integer $modifier Node type modifier + */ + public function testImplicitPublic($modifier) + { + $node = new ClassMethod('foo', array( + 'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)) + )); + + $this->assertTrue($node->isPublic(), 'Node should be implicitly public'); + } + + public function implicitPublicModifiers() { + return array( + array('abstract'), + array('final'), + array('static'), + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php new file mode 100644 index 000000000..75d49e3a8 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php @@ -0,0 +1,66 @@ + Class_::MODIFIER_ABSTRACT)); + $this->assertTrue($class->isAbstract()); + + $class = new Class_('Foo'); + $this->assertFalse($class->isAbstract()); + } + + public function testIsFinal() { + $class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL)); + $this->assertTrue($class->isFinal()); + + $class = new Class_('Foo'); + $this->assertFalse($class->isFinal()); + } + + public function testGetMethods() { + $methods = array( + new ClassMethod('foo'), + new ClassMethod('bar'), + new ClassMethod('fooBar'), + ); + $class = new Class_('Foo', array( + 'stmts' => array( + new TraitUse(array()), + $methods[0], + new ClassConst(array()), + $methods[1], + new Property(0, array()), + $methods[2], + ) + )); + + $this->assertSame($methods, $class->getMethods()); + } + + public function testGetMethod() { + $methodConstruct = new ClassMethod('__CONSTRUCT'); + $methodTest = new ClassMethod('test'); + $class = new Class_('Foo', array( + 'stmts' => array( + new ClassConst(array()), + $methodConstruct, + new Property(0, array()), + $methodTest, + ) + )); + + $this->assertSame($methodConstruct, $class->getMethod('__construct')); + $this->assertSame($methodTest, $class->getMethod('test')); + $this->assertNull($class->getMethod('nonExisting')); + } + + public function testDeprecatedTypeNode() { + $class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT)); + $this->assertTrue($class->isAbstract()); + $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->flags); + $this->assertSame(Class_::MODIFIER_ABSTRACT, $class->type); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php new file mode 100644 index 000000000..c49905826 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php @@ -0,0 +1,26 @@ + array( + new Node\Stmt\ClassConst(array(new Node\Const_('C1', new Node\Scalar\String_('C1')))), + $methods[0], + new Node\Stmt\ClassConst(array(new Node\Const_('C2', new Node\Scalar\String_('C2')))), + $methods[1], + new Node\Stmt\ClassConst(array(new Node\Const_('C3', new Node\Scalar\String_('C3')))), + ) + )); + + $this->assertSame($methods, $interface->getMethods()); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php new file mode 100644 index 000000000..bcfc0c6bd --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php @@ -0,0 +1,44 @@ +assertTrue($node->{'is' . $modifier}()); + } + + public function testNoModifiers() { + $node = new Property(0, array()); + + $this->assertTrue($node->isPublic()); + $this->assertFalse($node->isProtected()); + $this->assertFalse($node->isPrivate()); + $this->assertFalse($node->isStatic()); + } + + public function testStaticImplicitlyPublic() { + $node = new Property(Class_::MODIFIER_STATIC, array()); + $this->assertTrue($node->isPublic()); + $this->assertFalse($node->isProtected()); + $this->assertFalse($node->isPrivate()); + $this->assertTrue($node->isStatic()); + } + + public function provideModifiers() { + return array( + array('public'), + array('protected'), + array('private'), + array('static'), + ); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/NodeAbstractTest.php b/lib/nikic/php-parser/test/PhpParser/NodeAbstractTest.php new file mode 100644 index 000000000..7fd0a39c7 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/NodeAbstractTest.php @@ -0,0 +1,274 @@ +subNode1 = $subNode1; + $this->subNode2 = $subNode2; + } + + public function getSubNodeNames() { + return array('subNode1', 'subNode2'); + } + + // This method is only overwritten because the node is located in an unusual namespace + public function getType() { + return 'Dummy'; + } +} + +class NodeAbstractTest extends \PHPUnit_Framework_TestCase +{ + public function provideNodes() { + $attributes = array( + 'startLine' => 10, + 'comments' => array( + new Comment('// Comment' . "\n"), + new Comment\Doc('/** doc comment */'), + ), + ); + + $node = new DummyNode('value1', 'value2', $attributes); + $node->notSubNode = 'value3'; + + return array( + array($attributes, $node), + ); + } + + /** + * @dataProvider provideNodes + */ + public function testConstruct(array $attributes, Node $node) { + $this->assertSame('Dummy', $node->getType()); + $this->assertSame(array('subNode1', 'subNode2'), $node->getSubNodeNames()); + $this->assertSame(10, $node->getLine()); + $this->assertSame('/** doc comment */', $node->getDocComment()->getText()); + $this->assertSame('value1', $node->subNode1); + $this->assertSame('value2', $node->subNode2); + $this->assertTrue(isset($node->subNode1)); + $this->assertTrue(isset($node->subNode2)); + $this->assertFalse(isset($node->subNode3)); + $this->assertSame($attributes, $node->getAttributes()); + + return $node; + } + + /** + * @dataProvider provideNodes + */ + public function testGetDocComment(array $attributes, Node $node) { + $this->assertSame('/** doc comment */', $node->getDocComment()->getText()); + array_pop($node->getAttribute('comments')); // remove doc comment + $this->assertNull($node->getDocComment()); + array_pop($node->getAttribute('comments')); // remove comment + $this->assertNull($node->getDocComment()); + } + + public function testSetDocComment() { + $node = new DummyNode(null, null, []); + + // Add doc comment to node without comments + $docComment = new Comment\Doc('/** doc */'); + $node->setDocComment($docComment); + $this->assertSame($docComment, $node->getDocComment()); + + // Replace it + $docComment = new Comment\Doc('/** doc 2 */'); + $node->setDocComment($docComment); + $this->assertSame($docComment, $node->getDocComment()); + + // Add docmment to node with other comments + $c1 = new Comment('/* foo */'); + $c2 = new Comment('/* bar */'); + $docComment = new Comment\Doc('/** baz */'); + $node->setAttribute('comments', [$c1, $c2]); + $node->setDocComment($docComment); + $this->assertSame([$c1, $c2, $docComment], $node->getAttribute('comments')); + } + + /** + * @dataProvider provideNodes + */ + public function testChange(array $attributes, Node $node) { + // change of line + $node->setLine(15); + $this->assertSame(15, $node->getLine()); + + // direct modification + $node->subNode = 'newValue'; + $this->assertSame('newValue', $node->subNode); + + // indirect modification + $subNode =& $node->subNode; + $subNode = 'newNewValue'; + $this->assertSame('newNewValue', $node->subNode); + + // removal + unset($node->subNode); + $this->assertFalse(isset($node->subNode)); + } + + /** + * @dataProvider provideNodes + */ + public function testIteration(array $attributes, Node $node) { + // Iteration is simple object iteration over properties, + // not over subnodes + $i = 0; + foreach ($node as $key => $value) { + if ($i === 0) { + $this->assertSame('subNode1', $key); + $this->assertSame('value1', $value); + } else if ($i === 1) { + $this->assertSame('subNode2', $key); + $this->assertSame('value2', $value); + } else if ($i === 2) { + $this->assertSame('notSubNode', $key); + $this->assertSame('value3', $value); + } else { + throw new \Exception; + } + $i++; + } + $this->assertSame(3, $i); + } + + public function testAttributes() { + /** @var $node Node */ + $node = $this->getMockForAbstractClass('PhpParser\NodeAbstract'); + + $this->assertEmpty($node->getAttributes()); + + $node->setAttribute('key', 'value'); + $this->assertTrue($node->hasAttribute('key')); + $this->assertSame('value', $node->getAttribute('key')); + + $this->assertFalse($node->hasAttribute('doesNotExist')); + $this->assertNull($node->getAttribute('doesNotExist')); + $this->assertSame('default', $node->getAttribute('doesNotExist', 'default')); + + $node->setAttribute('null', null); + $this->assertTrue($node->hasAttribute('null')); + $this->assertNull($node->getAttribute('null')); + $this->assertNull($node->getAttribute('null', 'default')); + + $this->assertSame( + array( + 'key' => 'value', + 'null' => null, + ), + $node->getAttributes() + ); + } + + public function testJsonSerialization() { + $code = <<<'PHP' +parse(canonicalize($code)); + $json = json_encode($stmts, JSON_PRETTY_PRINT); + $this->assertEquals(canonicalize($expected), canonicalize($json)); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/NodeDumperTest.php b/lib/nikic/php-parser/test/PhpParser/NodeDumperTest.php new file mode 100644 index 000000000..9bb65a747 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/NodeDumperTest.php @@ -0,0 +1,105 @@ +assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node))); + } + + public function provideTestDump() { + return array( + array( + array(), +'array( +)' + ), + array( + array('Foo', 'Bar', 'Key' => 'FooBar'), +'array( + 0: Foo + 1: Bar + Key: FooBar +)' + ), + array( + new Node\Name(array('Hallo', 'World')), +'Name( + parts: array( + 0: Hallo + 1: World + ) +)' + ), + array( + new Node\Expr\Array_(array( + new Node\Expr\ArrayItem(new Node\Scalar\String_('Foo')) + )), +'Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: Foo + ) + byRef: false + ) + ) +)' + ), + ); + } + + public function testDumpWithPositions() { + $parser = (new ParserFactory)->create( + ParserFactory::ONLY_PHP7, + new Lexer(['usedAttributes' => ['startLine', 'endLine', 'startFilePos', 'endFilePos']]) + ); + $dumper = new NodeDumper(['dumpPositions' => true]); + + $code = "parse($code); + $dump = $dumper->dump($stmts, $code); + + $this->assertSame($this->canonicalize($expected), $this->canonicalize($dump)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Can only dump nodes and arrays. + */ + public function testError() { + $dumper = new NodeDumper; + $dumper->dump(new \stdClass); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/NodeTraverserTest.php b/lib/nikic/php-parser/test/PhpParser/NodeTraverserTest.php new file mode 100644 index 000000000..9d27edcb6 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/NodeTraverserTest.php @@ -0,0 +1,267 @@ +getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + $visitor->expects($this->at(0))->method('beforeTraverse')->with($stmts); + $visitor->expects($this->at(1))->method('enterNode')->with($echoNode); + $visitor->expects($this->at(2))->method('enterNode')->with($str1Node); + $visitor->expects($this->at(3))->method('leaveNode')->with($str1Node); + $visitor->expects($this->at(4))->method('enterNode')->with($str2Node); + $visitor->expects($this->at(5))->method('leaveNode')->with($str2Node); + $visitor->expects($this->at(6))->method('leaveNode')->with($echoNode); + $visitor->expects($this->at(7))->method('afterTraverse')->with($stmts); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + + $this->assertEquals($stmts, $traverser->traverse($stmts)); + } + + public function testModifying() { + $str1Node = new String_('Foo'); + $str2Node = new String_('Bar'); + $printNode = new Expr\Print_($str1Node); + + // first visitor changes the node, second verifies the change + $visitor1 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor2 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + // replace empty statements with string1 node + $visitor1->expects($this->at(0))->method('beforeTraverse')->with(array()) + ->will($this->returnValue(array($str1Node))); + $visitor2->expects($this->at(0))->method('beforeTraverse')->with(array($str1Node)); + + // replace string1 node with print node + $visitor1->expects($this->at(1))->method('enterNode')->with($str1Node) + ->will($this->returnValue($printNode)); + $visitor2->expects($this->at(1))->method('enterNode')->with($printNode); + + // replace string1 node with string2 node + $visitor1->expects($this->at(2))->method('enterNode')->with($str1Node) + ->will($this->returnValue($str2Node)); + $visitor2->expects($this->at(2))->method('enterNode')->with($str2Node); + + // replace string2 node with string1 node again + $visitor1->expects($this->at(3))->method('leaveNode')->with($str2Node) + ->will($this->returnValue($str1Node)); + $visitor2->expects($this->at(3))->method('leaveNode')->with($str1Node); + + // replace print node with string1 node again + $visitor1->expects($this->at(4))->method('leaveNode')->with($printNode) + ->will($this->returnValue($str1Node)); + $visitor2->expects($this->at(4))->method('leaveNode')->with($str1Node); + + // replace string1 node with empty statements again + $visitor1->expects($this->at(5))->method('afterTraverse')->with(array($str1Node)) + ->will($this->returnValue(array())); + $visitor2->expects($this->at(5))->method('afterTraverse')->with(array()); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor1); + $traverser->addVisitor($visitor2); + + // as all operations are reversed we end where we start + $this->assertEquals(array(), $traverser->traverse(array())); + } + + public function testRemove() { + $str1Node = new String_('Foo'); + $str2Node = new String_('Bar'); + + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + // remove the string1 node, leave the string2 node + $visitor->expects($this->at(2))->method('leaveNode')->with($str1Node) + ->will($this->returnValue(false)); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + + $this->assertEquals(array($str2Node), $traverser->traverse(array($str1Node, $str2Node))); + } + + public function testMerge() { + $strStart = new String_('Start'); + $strMiddle = new String_('End'); + $strEnd = new String_('Middle'); + $strR1 = new String_('Replacement 1'); + $strR2 = new String_('Replacement 2'); + + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + // replace strMiddle with strR1 and strR2 by merge + $visitor->expects($this->at(4))->method('leaveNode')->with($strMiddle) + ->will($this->returnValue(array($strR1, $strR2))); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + + $this->assertEquals( + array($strStart, $strR1, $strR2, $strEnd), + $traverser->traverse(array($strStart, $strMiddle, $strEnd)) + ); + } + + public function testDeepArray() { + $strNode = new String_('Foo'); + $stmts = array(array(array($strNode))); + + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(1))->method('enterNode')->with($strNode); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + + $this->assertEquals($stmts, $traverser->traverse($stmts)); + } + + public function testDontTraverseChildren() { + $strNode = new String_('str'); + $printNode = new Expr\Print_($strNode); + $varNode = new Expr\Variable('foo'); + $mulNode = new Expr\BinaryOp\Mul($varNode, $varNode); + $negNode = new Expr\UnaryMinus($mulNode); + $stmts = array($printNode, $negNode); + + $visitor1 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor2 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + $visitor1->expects($this->at(1))->method('enterNode')->with($printNode) + ->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN)); + $visitor2->expects($this->at(1))->method('enterNode')->with($printNode); + + $visitor1->expects($this->at(2))->method('leaveNode')->with($printNode); + $visitor2->expects($this->at(2))->method('leaveNode')->with($printNode); + + $visitor1->expects($this->at(3))->method('enterNode')->with($negNode); + $visitor2->expects($this->at(3))->method('enterNode')->with($negNode); + + $visitor1->expects($this->at(4))->method('enterNode')->with($mulNode); + $visitor2->expects($this->at(4))->method('enterNode')->with($mulNode) + ->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN)); + + $visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode); + $visitor2->expects($this->at(5))->method('leaveNode')->with($mulNode); + + $visitor1->expects($this->at(6))->method('leaveNode')->with($negNode); + $visitor2->expects($this->at(6))->method('leaveNode')->with($negNode); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor1); + $traverser->addVisitor($visitor2); + + $this->assertEquals($stmts, $traverser->traverse($stmts)); + } + + public function testStopTraversal() { + $varNode1 = new Expr\Variable('a'); + $varNode2 = new Expr\Variable('b'); + $varNode3 = new Expr\Variable('c'); + $mulNode = new Expr\BinaryOp\Mul($varNode1, $varNode2); + $printNode = new Expr\Print_($varNode3); + $stmts = [$mulNode, $printNode]; + + // From enterNode() with array parent + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(1))->method('enterNode')->with($mulNode) + ->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL)); + $visitor->expects($this->at(2))->method('afterTraverse'); + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + $this->assertEquals($stmts, $traverser->traverse($stmts)); + + // From enterNode with Node parent + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(2))->method('enterNode')->with($varNode1) + ->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL)); + $visitor->expects($this->at(3))->method('afterTraverse'); + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + $this->assertEquals($stmts, $traverser->traverse($stmts)); + + // From leaveNode with Node parent + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(3))->method('leaveNode')->with($varNode1) + ->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL)); + $visitor->expects($this->at(4))->method('afterTraverse'); + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + $this->assertEquals($stmts, $traverser->traverse($stmts)); + + // From leaveNode with array parent + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(6))->method('leaveNode')->with($mulNode) + ->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL)); + $visitor->expects($this->at(7))->method('afterTraverse'); + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + $this->assertEquals($stmts, $traverser->traverse($stmts)); + + // Check that pending array modifications are still carried out + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->expects($this->at(6))->method('leaveNode')->with($mulNode) + ->will($this->returnValue(NodeTraverser::REMOVE_NODE)); + $visitor->expects($this->at(7))->method('enterNode')->with($printNode) + ->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL)); + $visitor->expects($this->at(8))->method('afterTraverse'); + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor); + $this->assertEquals([$printNode], $traverser->traverse($stmts)); + + } + + public function testRemovingVisitor() { + $visitor1 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor2 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor3 = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + + $traverser = new NodeTraverser; + $traverser->addVisitor($visitor1); + $traverser->addVisitor($visitor2); + $traverser->addVisitor($visitor3); + + $preExpected = array($visitor1, $visitor2, $visitor3); + $this->assertAttributeSame($preExpected, 'visitors', $traverser, 'The appropriate visitors have not been added'); + + $traverser->removeVisitor($visitor2); + + $postExpected = array(0 => $visitor1, 2 => $visitor3); + $this->assertAttributeSame($postExpected, 'visitors', $traverser, 'The appropriate visitors are not present after removal'); + } + + public function testNoCloneNodes() { + $stmts = array(new Node\Stmt\Echo_(array(new String_('Foo'), new String_('Bar')))); + + $traverser = new NodeTraverser; + + $this->assertSame($stmts, $traverser->traverse($stmts)); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage leaveNode() may only return an array if the parent structure is an array + */ + public function testReplaceByArrayOnlyAllowedIfParentIsArray() { + $stmts = array(new Node\Expr\UnaryMinus(new Node\Scalar\LNumber(42))); + + $visitor = $this->getMockBuilder('PhpParser\NodeVisitor')->getMock(); + $visitor->method('leaveNode')->willReturn(array(new Node\Scalar\DNumber(42.0))); + + $traverser = new NodeTraverser(); + $traverser->addVisitor($visitor); + $traverser->traverse($stmts); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php b/lib/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php new file mode 100644 index 000000000..031337459 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php @@ -0,0 +1,468 @@ +addVisitor(new NameResolver); + + $stmts = $parser->parse($code); + $stmts = $traverser->traverse($stmts); + + $this->assertSame( + $this->canonicalize($expectedCode), + $prettyPrinter->prettyPrint($stmts) + ); + } + + /** + * @covers PhpParser\NodeVisitor\NameResolver + */ + public function testResolveLocations() { + $code = <<<'EOC' +addVisitor(new NameResolver); + + $stmts = $parser->parse($code); + $stmts = $traverser->traverse($stmts); + + $this->assertSame( + $this->canonicalize($expectedCode), + $prettyPrinter->prettyPrint($stmts) + ); + } + + public function testNoResolveSpecialName() { + $stmts = array(new Node\Expr\New_(new Name('self'))); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + + $this->assertEquals($stmts, $traverser->traverse($stmts)); + } + + public function testAddDeclarationNamespacedName() { + $nsStmts = array( + new Stmt\Class_('A'), + new Stmt\Interface_('B'), + new Stmt\Function_('C'), + new Stmt\Const_(array( + new Node\Const_('D', new Node\Scalar\LNumber(42)) + )), + new Stmt\Trait_('E'), + new Expr\New_(new Stmt\Class_(null)), + ); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + + $stmts = $traverser->traverse([new Stmt\Namespace_(new Name('NS'), $nsStmts)]); + $this->assertSame('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName); + $this->assertSame('NS\\B', (string) $stmts[0]->stmts[1]->namespacedName); + $this->assertSame('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName); + $this->assertSame('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName); + $this->assertSame('NS\\E', (string) $stmts[0]->stmts[4]->namespacedName); + $this->assertObjectNotHasAttribute('namespacedName', $stmts[0]->stmts[5]->class); + + $stmts = $traverser->traverse([new Stmt\Namespace_(null, $nsStmts)]); + $this->assertSame('A', (string) $stmts[0]->stmts[0]->namespacedName); + $this->assertSame('B', (string) $stmts[0]->stmts[1]->namespacedName); + $this->assertSame('C', (string) $stmts[0]->stmts[2]->namespacedName); + $this->assertSame('D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName); + $this->assertSame('E', (string) $stmts[0]->stmts[4]->namespacedName); + $this->assertObjectNotHasAttribute('namespacedName', $stmts[0]->stmts[5]->class); + } + + public function testAddRuntimeResolvedNamespacedName() { + $stmts = array( + new Stmt\Namespace_(new Name('NS'), array( + new Expr\FuncCall(new Name('foo')), + new Expr\ConstFetch(new Name('FOO')), + )), + new Stmt\Namespace_(null, array( + new Expr\FuncCall(new Name('foo')), + new Expr\ConstFetch(new Name('FOO')), + )), + ); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + $stmts = $traverser->traverse($stmts); + + $this->assertSame('NS\\foo', (string) $stmts[0]->stmts[0]->name->getAttribute('namespacedName')); + $this->assertSame('NS\\FOO', (string) $stmts[0]->stmts[1]->name->getAttribute('namespacedName')); + + $this->assertFalse($stmts[1]->stmts[0]->name->hasAttribute('namespacedName')); + $this->assertFalse($stmts[1]->stmts[1]->name->hasAttribute('namespacedName')); + } + + /** + * @dataProvider provideTestError + */ + public function testError(Node $stmt, $errorMsg) { + $this->setExpectedException('PhpParser\Error', $errorMsg); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + $traverser->traverse(array($stmt)); + } + + public function provideTestError() { + return array( + array( + new Stmt\Use_(array( + new Stmt\UseUse(new Name('A\B'), 'B', 0, array('startLine' => 1)), + new Stmt\UseUse(new Name('C\D'), 'B', 0, array('startLine' => 2)), + ), Stmt\Use_::TYPE_NORMAL), + 'Cannot use C\D as B because the name is already in use on line 2' + ), + array( + new Stmt\Use_(array( + new Stmt\UseUse(new Name('a\b'), 'b', 0, array('startLine' => 1)), + new Stmt\UseUse(new Name('c\d'), 'B', 0, array('startLine' => 2)), + ), Stmt\Use_::TYPE_FUNCTION), + 'Cannot use function c\d as B because the name is already in use on line 2' + ), + array( + new Stmt\Use_(array( + new Stmt\UseUse(new Name('A\B'), 'B', 0, array('startLine' => 1)), + new Stmt\UseUse(new Name('C\D'), 'B', 0, array('startLine' => 2)), + ), Stmt\Use_::TYPE_CONSTANT), + 'Cannot use const C\D as B because the name is already in use on line 2' + ), + array( + new Expr\New_(new Name\FullyQualified('self', array('startLine' => 3))), + "'\\self' is an invalid class name on line 3" + ), + array( + new Expr\New_(new Name\Relative('self', array('startLine' => 3))), + "'\\self' is an invalid class name on line 3" + ), + array( + new Expr\New_(new Name\FullyQualified('PARENT', array('startLine' => 3))), + "'\\PARENT' is an invalid class name on line 3" + ), + array( + new Expr\New_(new Name\Relative('STATIC', array('startLine' => 3))), + "'\\STATIC' is an invalid class name on line 3" + ), + ); + } + + public function testClassNameIsCaseInsensitive() + { + $source = <<<'EOC' +parse($source); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + + $stmts = $traverser->traverse($stmts); + $stmt = $stmts[0]; + + $this->assertSame(array('Bar', 'Baz'), $stmt->stmts[1]->expr->class->parts); + } + + public function testSpecialClassNamesAreCaseInsensitive() { + $source = <<<'EOC' +parse($source); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + + $stmts = $traverser->traverse($stmts); + $classStmt = $stmts[0]; + $methodStmt = $classStmt->stmts[0]->stmts[0]; + + $this->assertSame('SELF', (string)$methodStmt->stmts[0]->class); + $this->assertSame('PARENT', (string)$methodStmt->stmts[1]->class); + $this->assertSame('STATIC', (string)$methodStmt->stmts[2]->class); + } + + public function testAddOriginalNames() { + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver(null, ['preserveOriginalNames' => true])); + + $n1 = new Name('Bar'); + $n2 = new Name('bar'); + $origStmts = [ + new Stmt\Namespace_(new Name('Foo'), [ + new Expr\ClassConstFetch($n1, 'FOO'), + new Expr\FuncCall($n2), + ]) + ]; + + $stmts = $traverser->traverse($origStmts); + + $this->assertSame($n1, $stmts[0]->stmts[0]->class->getAttribute('originalName')); + $this->assertSame($n2, $stmts[0]->stmts[1]->name->getAttribute('originalName')); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Parser/MultipleTest.php b/lib/nikic/php-parser/test/PhpParser/Parser/MultipleTest.php new file mode 100644 index 000000000..01d3b6040 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Parser/MultipleTest.php @@ -0,0 +1,94 @@ + []]); + return new Multiple([new Php7($lexer), new Php5($lexer)]); + } + + private function getPrefer5() { + $lexer = new Lexer(['usedAttributes' => []]); + return new Multiple([new Php5($lexer), new Php7($lexer)]); + } + + /** @dataProvider provideTestParse */ + public function testParse($code, Multiple $parser, $expected) { + $this->assertEquals($expected, $parser->parse($code)); + } + + public function provideTestParse() { + return [ + [ + // PHP 7 only code + 'getPrefer5(), + [ + new Stmt\Class_('Test', ['stmts' => [ + new Stmt\ClassMethod('function') + ]]), + ] + ], + [ + // PHP 5 only code + 'b;', + $this->getPrefer7(), + [ + new Stmt\Global_([ + new Expr\Variable(new Expr\PropertyFetch(new Expr\Variable('a'), 'b')) + ]) + ] + ], + [ + // Different meaning (PHP 5) + 'getPrefer5(), + [ + new Expr\Variable( + new Expr\ArrayDimFetch(new Expr\Variable('a'), LNumber::fromString('0')) + ) + ] + ], + [ + // Different meaning (PHP 7) + 'getPrefer7(), + [ + new Expr\ArrayDimFetch( + new Expr\Variable(new Expr\Variable('a')), LNumber::fromString('0') + ) + ] + ], + ]; + } + + public function testThrownError() { + $this->setExpectedException('PhpParser\Error', 'FAIL A'); + + $parserA = $this->getMockBuilder('PhpParser\Parser')->getMock(); + $parserA->expects($this->at(0)) + ->method('parse')->will($this->throwException(new Error('FAIL A'))); + + $parserB = $this->getMockBuilder('PhpParser\Parser')->getMock(); + $parserB->expects($this->at(0)) + ->method('parse')->will($this->throwException(new Error('FAIL B'))); + + $parser = new Multiple([$parserA, $parserB]); + $parser->parse('dummy'); + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/Parser/Php5Test.php b/lib/nikic/php-parser/test/PhpParser/Parser/Php5Test.php new file mode 100644 index 000000000..58c4e617c --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Parser/Php5Test.php @@ -0,0 +1,14 @@ +assertInstanceOf($expected, (new ParserFactory)->create($kind, $lexer)); + } + + public function provideTestCreate() { + $lexer = new Lexer(); + return [ + [ + ParserFactory::PREFER_PHP7, $lexer, + 'PhpParser\Parser\Multiple' + ], + [ + ParserFactory::PREFER_PHP5, null, + 'PhpParser\Parser\Multiple' + ], + [ + ParserFactory::ONLY_PHP7, null, + 'PhpParser\Parser\Php7' + ], + [ + ParserFactory::ONLY_PHP5, $lexer, + 'PhpParser\Parser\Php5' + ] + ]; + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/PhpParser/ParserTest.php b/lib/nikic/php-parser/test/PhpParser/ParserTest.php new file mode 100644 index 000000000..0dabba216 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/ParserTest.php @@ -0,0 +1,184 @@ +getParser(new Lexer()); + $parser->parse('getParser(new Lexer()); + $parser->parse('getParser(new Lexer()); + $parser->parse(' array( + 'comments', 'startLine', 'endLine', + 'startTokenPos', 'endTokenPos', + ) + )); + + $code = <<<'EOC' +getParser($lexer); + $stmts = $parser->parse($code); + + /** @var \PhpParser\Node\Stmt\Function_ $fn */ + $fn = $stmts[0]; + $this->assertInstanceOf('PhpParser\Node\Stmt\Function_', $fn); + $this->assertEquals(array( + 'comments' => array( + new Comment\Doc('/** Doc comment */', 2, 6), + ), + 'startLine' => 3, + 'endLine' => 7, + 'startTokenPos' => 3, + 'endTokenPos' => 21, + ), $fn->getAttributes()); + + $param = $fn->params[0]; + $this->assertInstanceOf('PhpParser\Node\Param', $param); + $this->assertEquals(array( + 'startLine' => 3, + 'endLine' => 3, + 'startTokenPos' => 7, + 'endTokenPos' => 7, + ), $param->getAttributes()); + + /** @var \PhpParser\Node\Stmt\Echo_ $echo */ + $echo = $fn->stmts[0]; + $this->assertInstanceOf('PhpParser\Node\Stmt\Echo_', $echo); + $this->assertEquals(array( + 'comments' => array( + new Comment("// Line\n", 4, 49), + new Comment("// Comments\n", 5, 61), + ), + 'startLine' => 6, + 'endLine' => 6, + 'startTokenPos' => 16, + 'endTokenPos' => 19, + ), $echo->getAttributes()); + + /** @var \PhpParser\Node\Expr\Variable $var */ + $var = $echo->exprs[0]; + $this->assertInstanceOf('PhpParser\Node\Expr\Variable', $var); + $this->assertEquals(array( + 'startLine' => 6, + 'endLine' => 6, + 'startTokenPos' => 18, + 'endTokenPos' => 18, + ), $var->getAttributes()); + } + + /** + * @expectedException \RangeException + * @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar) + */ + public function testInvalidToken() { + $lexer = new InvalidTokenLexer; + $parser = $this->getParser($lexer); + $parser->parse('dummy'); + } + + /** + * @dataProvider provideTestExtraAttributes + */ + public function testExtraAttributes($code, $expectedAttributes) { + $parser = $this->getParser(new Lexer); + $stmts = $parser->parse("getAttributes(); + foreach ($expectedAttributes as $name => $value) { + $this->assertSame($value, $attributes[$name]); + } + } + + public function provideTestExtraAttributes() { + return array( + array('0', ['kind' => Scalar\LNumber::KIND_DEC]), + array('9', ['kind' => Scalar\LNumber::KIND_DEC]), + array('07', ['kind' => Scalar\LNumber::KIND_OCT]), + array('0xf', ['kind' => Scalar\LNumber::KIND_HEX]), + array('0XF', ['kind' => Scalar\LNumber::KIND_HEX]), + array('0b1', ['kind' => Scalar\LNumber::KIND_BIN]), + array('0B1', ['kind' => Scalar\LNumber::KIND_BIN]), + array('[]', ['kind' => Expr\Array_::KIND_SHORT]), + array('array()', ['kind' => Expr\Array_::KIND_LONG]), + array("'foo'", ['kind' => String_::KIND_SINGLE_QUOTED]), + array("b'foo'", ['kind' => String_::KIND_SINGLE_QUOTED]), + array("B'foo'", ['kind' => String_::KIND_SINGLE_QUOTED]), + array('"foo"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array('b"foo"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array('B"foo"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array('"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array('b"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array('B"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]), + array("<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']), + array("<< String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("<<<\"STR\"\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("b<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']), + array("B<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']), + array("<<< \t 'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']), + // HHVM doesn't support this due to a lexer bug + // (https://github.com/facebook/hhvm/issues/6970) + // array("<<<'\xff'\n\xff\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => "\xff"]), + array("<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("b<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("B<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("<<< \t \"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']), + array("die", ['kind' => Expr\Exit_::KIND_DIE]), + array("die('done')", ['kind' => Expr\Exit_::KIND_DIE]), + array("exit", ['kind' => Expr\Exit_::KIND_EXIT]), + array("exit(1)", ['kind' => Expr\Exit_::KIND_EXIT]), + array("?>Foo", ['hasLeadingNewline' => false]), + array("?>\nFoo", ['hasLeadingNewline' => true]), + array("namespace Foo;", ['kind' => Node\Stmt\Namespace_::KIND_SEMICOLON]), + array("namespace Foo {}", ['kind' => Node\Stmt\Namespace_::KIND_BRACED]), + array("namespace {}", ['kind' => Node\Stmt\Namespace_::KIND_BRACED]), + ); + } +} + +class InvalidTokenLexer extends Lexer { + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { + $value = 'foobar'; + return 999; + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php b/lib/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php new file mode 100644 index 000000000..908c18b2b --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php @@ -0,0 +1,207 @@ +parseModeLine($modeLine); + $prettyPrinter = new Standard($options); + + try { + $output5 = canonicalize($prettyPrinter->$method($parser5->parse($code))); + } catch (Error $e) { + $output5 = null; + if ('php7' !== $version) { + throw $e; + } + } + + try { + $output7 = canonicalize($prettyPrinter->$method($parser7->parse($code))); + } catch (Error $e) { + $output7 = null; + if ('php5' !== $version) { + throw $e; + } + } + + if ('php5' === $version) { + $this->assertSame($expected, $output5, $name); + $this->assertNotSame($expected, $output7, $name); + } else if ('php7' === $version) { + $this->assertSame($expected, $output7, $name); + $this->assertNotSame($expected, $output5, $name); + } else { + $this->assertSame($expected, $output5, $name); + $this->assertSame($expected, $output7, $name); + } + } + + /** + * @dataProvider provideTestPrettyPrint + * @covers PhpParser\PrettyPrinter\Standard + */ + public function testPrettyPrint($name, $code, $expected, $mode) { + $this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $expected, $mode); + } + + /** + * @dataProvider provideTestPrettyPrintFile + * @covers PhpParser\PrettyPrinter\Standard + */ + public function testPrettyPrintFile($name, $code, $expected, $mode) { + $this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $expected, $mode); + } + + public function provideTestPrettyPrint() { + return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'test'); + } + + public function provideTestPrettyPrintFile() { + return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'file-test'); + } + + public function testPrettyPrintExpr() { + $prettyPrinter = new Standard; + $expr = new Expr\BinaryOp\Mul( + new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')), + new Expr\Variable('c') + ); + $this->assertEquals('($a + $b) * $c', $prettyPrinter->prettyPrintExpr($expr)); + + $expr = new Expr\Closure(array( + 'stmts' => array(new Stmt\Return_(new String_("a\nb"))) + )); + $this->assertEquals("function () {\n return 'a\nb';\n}", $prettyPrinter->prettyPrintExpr($expr)); + } + + public function testCommentBeforeInlineHTML() { + $prettyPrinter = new PrettyPrinter\Standard; + $comment = new Comment\Doc("/**\n * This is a comment\n */"); + $stmts = [new Stmt\InlineHTML('Hello World!', ['comments' => [$comment]])]; + $expected = "\nHello World!"; + $this->assertSame($expected, $prettyPrinter->prettyPrintFile($stmts)); + } + + private function parseModeLine($modeLine) { + $parts = explode(' ', $modeLine, 2); + $version = isset($parts[0]) ? $parts[0] : 'both'; + $options = isset($parts[1]) ? json_decode($parts[1], true) : []; + return [$version, $options]; + } + + public function testArraySyntaxDefault() { + $prettyPrinter = new Standard(['shortArraySyntax' => true]); + $expr = new Expr\Array_([ + new Expr\ArrayItem(new String_('val'), new String_('key')) + ]); + $expected = "['key' => 'val']"; + $this->assertSame($expected, $prettyPrinter->prettyPrintExpr($expr)); + } + + /** + * @dataProvider provideTestKindAttributes + */ + public function testKindAttributes($node, $expected) { + $prttyPrinter = new PrettyPrinter\Standard; + $result = $prttyPrinter->prettyPrintExpr($node); + $this->assertSame($expected, $result); + } + + public function provideTestKindAttributes() { + $nowdoc = ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']; + $heredoc = ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']; + return [ + // Defaults to single quoted + [new String_('foo'), "'foo'"], + // Explicit single/double quoted + [new String_('foo', ['kind' => String_::KIND_SINGLE_QUOTED]), "'foo'"], + [new String_('foo', ['kind' => String_::KIND_DOUBLE_QUOTED]), '"foo"'], + // Fallback from doc string if no label + [new String_('foo', ['kind' => String_::KIND_NOWDOC]), "'foo'"], + [new String_('foo', ['kind' => String_::KIND_HEREDOC]), '"foo"'], + // Fallback if string contains label + [new String_("A\nB\nC", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'A']), "'A\nB\nC'"], + [new String_("A\nB\nC", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'B']), "'A\nB\nC'"], + [new String_("A\nB\nC", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'C']), "'A\nB\nC'"], + [new String_("STR;", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']), "'STR;'"], + // Doc string if label not contained (or not in ending position) + [new String_("foo", $nowdoc), "<<<'STR'\nfoo\nSTR\n"], + [new String_("foo", $heredoc), "<<prettyPrintExpr($node); + $this->assertSame($expected, $result); + } + + public function provideTestUnnaturalLiterals() { + return [ + [new LNumber(-1), '-1'], + [new LNumber(-PHP_INT_MAX - 1), '(-' . PHP_INT_MAX . '-1)'], + [new LNumber(-1, ['kind' => LNumber::KIND_BIN]), '-0b1'], + [new LNumber(-1, ['kind' => LNumber::KIND_OCT]), '-01'], + [new LNumber(-1, ['kind' => LNumber::KIND_HEX]), '-0x1'], + [new DNumber(\INF), '\INF'], + [new DNumber(-\INF), '-\INF'], + [new DNumber(-\NAN), '\NAN'], + ]; + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot pretty-print AST with Error nodes + */ + public function testPrettyPrintWithError() { + $stmts = [new Expr\PropertyFetch(new Expr\Variable('a'), new Expr\Error())]; + $prettyPrinter = new PrettyPrinter\Standard; + $prettyPrinter->prettyPrint($stmts); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot pretty-print AST with Error nodes + */ + public function testPrettyPrintWithErrorInClassConstFetch() { + $stmts = [new Expr\ClassConstFetch(new Name('Foo'), new Expr\Error())]; + $prettyPrinter = new PrettyPrinter\Standard; + $prettyPrinter->prettyPrint($stmts); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php b/lib/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php new file mode 100644 index 000000000..e1186f4d5 --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php @@ -0,0 +1,172 @@ + + */ + public function testSerialize() { + $code = << + + + + + 4 + + + + // comment + + /** doc comment */ + + + + 6 + + + + + + functionName + + + + + + 4 + + + 4 + + + + + + + + + + + + a + + + + + 4 + + + 4 + + + 10 + + + 0 + + + + + + + 4 + + + 4 + + + + + + + + + + + + b + + + + + 4 + + + 4 + + + 1 + + + + + + + + + + + + + + 5 + + + 5 + + + + + + 5 + + + 5 + + + 1 + + + Foo + + + + + + + + + + +XML; + + $parser = new PhpParser\Parser\Php7(new PhpParser\Lexer); + $serializer = new XML; + + $code = str_replace("\r\n", "\n", $code); + $stmts = $parser->parse($code); + $this->assertXmlStringEqualsXmlString($xml, $serializer->serialize($stmts)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unexpected node type + */ + public function testError() { + $serializer = new XML; + $serializer->serialize(array(new \stdClass)); + } +} diff --git a/lib/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php b/lib/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php new file mode 100644 index 000000000..3bc86dbed --- /dev/null +++ b/lib/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php @@ -0,0 +1,150 @@ + + + + + 1 + + + + // comment + + /** doc comment */ + + + + Test + + + +XML; + + $unserializer = new XML; + $this->assertEquals( + new Scalar\String_('Test', array( + 'startLine' => 1, + 'comments' => array( + new Comment('// comment' . "\n", 2), + new Comment\Doc('/** doc comment */', 3), + ), + )), + $unserializer->unserialize($xml) + ); + } + + public function testEmptyNode() { + $xml = << + + + +XML; + + $unserializer = new XML; + + $this->assertEquals( + new Scalar\MagicConst\Class_, + $unserializer->unserialize($xml) + ); + } + + public function testScalars() { + $xml = << + + + + + test + + + 1 + 1 + 1.5 + + + + + +XML; + $result = array( + array(), array(), + 'test', '', '', + 1, + 1, 1.5, + true, false, null + ); + + $unserializer = new XML; + $this->assertEquals($result, $unserializer->unserialize($xml)); + } + + /** + * @expectedException \DomainException + * @expectedExceptionMessage AST root element not found + */ + public function testWrongRootElementError() { + $xml = << + +XML; + + $unserializer = new XML; + $unserializer->unserialize($xml); + } + + /** + * @dataProvider provideTestErrors + */ + public function testErrors($xml, $errorMsg) { + $this->setExpectedException('DomainException', $errorMsg); + + $xml = << + + $xml + +XML; + + $unserializer = new XML; + $unserializer->unserialize($xml); + } + + public function provideTestErrors() { + return array( + array('test', '"true" scalar must be empty'), + array('test', '"false" scalar must be empty'), + array('test', '"null" scalar must be empty'), + array('bar', 'Unknown scalar type "foo"'), + array('x', '"x" is not a valid int'), + array('x', '"x" is not a valid float'), + array('', 'Expected node or scalar'), + array('test', 'Unexpected node of type "foo:bar"'), + array( + 'test', + 'Expected sub node or attribute, got node of type "foo:bar"' + ), + array( + '', + 'Expected node or scalar' + ), + array( + '', + 'Unknown node type "Foo"' + ), + ); + } +} diff --git a/lib/nikic/php-parser/test/bootstrap.php b/lib/nikic/php-parser/test/bootstrap.php new file mode 100644 index 000000000..9526b648b --- /dev/null +++ b/lib/nikic/php-parser/test/bootstrap.php @@ -0,0 +1,20 @@ + +----- +array( + 0: Stmt_Nop( + comments: array( + 0: /** doc */ + 1: /* foobar */ + 2: // foo + 3: // bar + ) + ) +) +----- + +; +----- +!!positions +Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1 +array( + 0: Expr_PropertyFetch[2:1 - 2:6]( + var: Expr_Variable[2:1 - 2:4]( + name: foo + ) + name: Expr_Error[3:1 - 2:6]( + ) + ) +) +----- + +} +----- +!!positions +Syntax error, unexpected '}', expecting T_STRING or T_VARIABLE or '{' or '$' from 4:1 to 4:1 +array( + 0: Stmt_Function[2:1 - 4:1]( + byRef: false + name: foo + params: array( + ) + returnType: null + stmts: array( + 0: Expr_PropertyFetch[3:5 - 3:10]( + var: Expr_Variable[3:5 - 3:8]( + name: bar + ) + name: Expr_Error[4:1 - 3:10]( + ) + ) + ) + ) +) +----- + 'd', 'e' => &$f); + +// short array syntax +[]; +[1, 2, 3]; +['a' => 'b']; +----- +array( + 0: Expr_Array( + items: array( + ) + ) + 1: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: a + ) + byRef: false + ) + ) + ) + 2: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: a + ) + byRef: false + ) + ) + ) + 3: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: a + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Scalar_String( + value: b + ) + byRef: false + ) + ) + ) + 4: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: a + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: true + ) + 2: Expr_ArrayItem( + key: Scalar_String( + value: c + ) + value: Scalar_String( + value: d + ) + byRef: false + ) + 3: Expr_ArrayItem( + key: Scalar_String( + value: e + ) + value: Expr_Variable( + name: f + ) + byRef: true + ) + ) + ) + 5: Expr_Array( + items: array( + ) + comments: array( + 0: // short array syntax + ) + ) + 6: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 1 + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 2 + ) + byRef: false + ) + 2: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 3 + ) + byRef: false + ) + ) + ) + 7: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Scalar_String( + value: b + ) + byRef: false + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/arrayDestructuring.test b/lib/nikic/php-parser/test/code/parser/expr/arrayDestructuring.test new file mode 100644 index 000000000..4ca76b216 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/arrayDestructuring.test @@ -0,0 +1,144 @@ +Array destructuring +----- + $b, 'b' => $a] = $baz; +----- +!!php7 +array( + 0: Expr_Assign( + var: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + ) + ) + expr: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: c + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: d + ) + byRef: false + ) + ) + ) + ) + 1: Expr_Assign( + var: Expr_Array( + items: array( + 0: null + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + 2: null + 3: null + 4: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + 5: null + ) + ) + expr: Expr_Variable( + name: foo + ) + ) + 2: Expr_Assign( + var: Expr_Array( + items: array( + 0: null + 1: Expr_ArrayItem( + key: null + value: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + ) + ) + byRef: false + ) + ) + ) + byRef: false + ) + 2: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + ) + ) + expr: Expr_Variable( + name: bar + ) + ) + 3: Expr_Assign( + var: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Expr_Variable( + name: b + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: Scalar_String( + value: b + ) + value: Expr_Variable( + name: a + ) + byRef: false + ) + ) + ) + expr: Expr_Variable( + name: baz + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/assign.test b/lib/nikic/php-parser/test/code/parser/expr/assign.test new file mode 100644 index 000000000..1d6b187ad --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/assign.test @@ -0,0 +1,301 @@ +Assignments +----- +>= $b; +$a **= $b; + +// chained assign +$a = $b *= $c **= $d; + +// by ref assign +$a =& $b; + +// list() assign +list($a) = $b; +list($a, , $b) = $c; +list($a, list(, $c), $d) = $e; + +// inc/dec +++$a; +$a++; +--$a; +$a--; +----- +array( + 0: Expr_Assign( + var: Expr_Variable( + name: a + comments: array( + 0: // simple assign + ) + ) + expr: Expr_Variable( + name: b + ) + comments: array( + 0: // simple assign + ) + ) + 1: Expr_AssignOp_BitwiseAnd( + var: Expr_Variable( + name: a + comments: array( + 0: // combined assign + ) + ) + expr: Expr_Variable( + name: b + ) + comments: array( + 0: // combined assign + ) + ) + 2: Expr_AssignOp_BitwiseOr( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 3: Expr_AssignOp_BitwiseXor( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 4: Expr_AssignOp_Concat( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 5: Expr_AssignOp_Div( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 6: Expr_AssignOp_Minus( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 7: Expr_AssignOp_Mod( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 8: Expr_AssignOp_Mul( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 9: Expr_AssignOp_Plus( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 10: Expr_AssignOp_ShiftLeft( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 11: Expr_AssignOp_ShiftRight( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 12: Expr_AssignOp_Pow( + var: Expr_Variable( + name: a + ) + expr: Expr_Variable( + name: b + ) + ) + 13: Expr_Assign( + var: Expr_Variable( + name: a + comments: array( + 0: // chained assign + ) + ) + expr: Expr_AssignOp_Mul( + var: Expr_Variable( + name: b + ) + expr: Expr_AssignOp_Pow( + var: Expr_Variable( + name: c + ) + expr: Expr_Variable( + name: d + ) + ) + ) + comments: array( + 0: // chained assign + ) + ) + 14: Expr_AssignRef( + var: Expr_Variable( + name: a + comments: array( + 0: // by ref assign + ) + ) + expr: Expr_Variable( + name: b + ) + comments: array( + 0: // by ref assign + ) + ) + 15: Expr_Assign( + var: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + ) + comments: array( + 0: // list() assign + ) + ) + expr: Expr_Variable( + name: b + ) + comments: array( + 0: // list() assign + ) + ) + 16: Expr_Assign( + var: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + 1: null + 2: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + ) + ) + expr: Expr_Variable( + name: c + ) + ) + 17: Expr_Assign( + var: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Expr_List( + items: array( + 0: null + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: c + ) + byRef: false + ) + ) + ) + byRef: false + ) + 2: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: d + ) + byRef: false + ) + ) + ) + expr: Expr_Variable( + name: e + ) + ) + 18: Expr_PreInc( + var: Expr_Variable( + name: a + ) + comments: array( + 0: // inc/dec + ) + ) + 19: Expr_PostInc( + var: Expr_Variable( + name: a + ) + ) + 20: Expr_PreDec( + var: Expr_Variable( + name: a + ) + ) + 21: Expr_PostDec( + var: Expr_Variable( + name: a + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/assignNewByRef.test b/lib/nikic/php-parser/test/code/parser/expr/assignNewByRef.test new file mode 100644 index 000000000..10e1317f0 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/assignNewByRef.test @@ -0,0 +1,39 @@ +Assigning new by reference (PHP 5 only) +----- + $b; +$a >= $b; +$a == $b; +$a === $b; +$a != $b; +$a !== $b; +$a <=> $b; +$a instanceof B; +$a instanceof $b; +----- +array( + 0: Expr_BinaryOp_Smaller( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 1: Expr_BinaryOp_SmallerOrEqual( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 2: Expr_BinaryOp_Greater( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 3: Expr_BinaryOp_GreaterOrEqual( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 4: Expr_BinaryOp_Equal( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 5: Expr_BinaryOp_Identical( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 6: Expr_BinaryOp_NotEqual( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 7: Expr_BinaryOp_NotIdentical( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 8: Expr_BinaryOp_Spaceship( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 9: Expr_Instanceof( + expr: Expr_Variable( + name: a + ) + class: Name( + parts: array( + 0: B + ) + ) + ) + 10: Expr_Instanceof( + expr: Expr_Variable( + name: a + ) + class: Expr_Variable( + name: b + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/expr/constant_expr.test b/lib/nikic/php-parser/test/code/parser/expr/constant_expr.test new file mode 100644 index 000000000..3e7a23ef0 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/constant_expr.test @@ -0,0 +1,621 @@ +Expressions in static scalar context +----- + 0; +const T_20 = 1 >= 0; +const T_21 = 1 === 1; +const T_22 = 1 !== 1; +const T_23 = 0 != "0"; +const T_24 = 1 == "1"; +const T_25 = 1 + 2 * 3; +const T_26 = "1" + 2 + "3"; +const T_27 = 2 ** 3; +const T_28 = [1, 2, 3][1]; +const T_29 = 12 - 13; +const T_30 = 12 ^ 13; +const T_31 = 12 & 13; +const T_32 = 12 | 13; +const T_33 = 12 % 3; +const T_34 = 100 >> 4; +const T_35 = !false; +----- +array( + 0: Stmt_Const( + consts: array( + 0: Const( + name: T_1 + value: Expr_BinaryOp_ShiftLeft( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 1: Stmt_Const( + consts: array( + 0: Const( + name: T_2 + value: Expr_BinaryOp_Div( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 2 + ) + ) + ) + ) + ) + 2: Stmt_Const( + consts: array( + 0: Const( + name: T_3 + value: Expr_BinaryOp_Plus( + left: Scalar_DNumber( + value: 1.5 + ) + right: Scalar_DNumber( + value: 1.5 + ) + ) + ) + ) + ) + 3: Stmt_Const( + consts: array( + 0: Const( + name: T_4 + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: foo + ) + right: Scalar_String( + value: bar + ) + ) + ) + ) + ) + 4: Stmt_Const( + consts: array( + 0: Const( + name: T_5 + value: Expr_BinaryOp_Mul( + left: Expr_BinaryOp_Plus( + left: Scalar_DNumber( + value: 1.5 + ) + right: Scalar_DNumber( + value: 1.5 + ) + ) + right: Scalar_LNumber( + value: 2 + ) + ) + ) + ) + ) + 5: Stmt_Const( + consts: array( + 0: Const( + name: T_6 + value: Expr_BinaryOp_Concat( + left: Expr_BinaryOp_Concat( + left: Expr_BinaryOp_Concat( + left: Scalar_String( + value: foo + ) + right: Scalar_LNumber( + value: 2 + ) + ) + right: Scalar_LNumber( + value: 3 + ) + ) + right: Scalar_DNumber( + value: 4 + ) + ) + ) + ) + ) + 6: Stmt_Const( + consts: array( + 0: Const( + name: T_7 + value: Scalar_MagicConst_Line( + ) + ) + ) + ) + 7: Stmt_Const( + consts: array( + 0: Const( + name: T_8 + value: Scalar_String( + value: This is a test string + ) + ) + ) + ) + 8: Stmt_Const( + consts: array( + 0: Const( + name: T_9 + value: Expr_BitwiseNot( + expr: Expr_UnaryMinus( + expr: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + ) + 9: Stmt_Const( + consts: array( + 0: Const( + name: T_10 + value: Expr_BinaryOp_Plus( + left: Expr_Ternary( + cond: Expr_UnaryMinus( + expr: Scalar_LNumber( + value: 1 + ) + ) + if: null + else: Scalar_LNumber( + value: 1 + ) + ) + right: Expr_Ternary( + cond: Scalar_LNumber( + value: 0 + ) + if: Scalar_LNumber( + value: 2 + ) + else: Scalar_LNumber( + value: 3 + ) + ) + ) + ) + ) + ) + 10: Stmt_Const( + consts: array( + 0: Const( + name: T_11 + value: Expr_BinaryOp_BooleanAnd( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 11: Stmt_Const( + consts: array( + 0: Const( + name: T_12 + value: Expr_BinaryOp_LogicalAnd( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 12: Stmt_Const( + consts: array( + 0: Const( + name: T_13 + value: Expr_BinaryOp_BooleanOr( + left: Scalar_LNumber( + value: 0 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 13: Stmt_Const( + consts: array( + 0: Const( + name: T_14 + value: Expr_BinaryOp_LogicalOr( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 14: Stmt_Const( + consts: array( + 0: Const( + name: T_15 + value: Expr_BinaryOp_LogicalXor( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 15: Stmt_Const( + consts: array( + 0: Const( + name: T_16 + value: Expr_BinaryOp_LogicalXor( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 16: Stmt_Const( + consts: array( + 0: Const( + name: T_17 + value: Expr_BinaryOp_Smaller( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 17: Stmt_Const( + consts: array( + 0: Const( + name: T_18 + value: Expr_BinaryOp_SmallerOrEqual( + left: Scalar_LNumber( + value: 0 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 18: Stmt_Const( + consts: array( + 0: Const( + name: T_19 + value: Expr_BinaryOp_Greater( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 19: Stmt_Const( + consts: array( + 0: Const( + name: T_20 + value: Expr_BinaryOp_GreaterOrEqual( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + ) + 20: Stmt_Const( + consts: array( + 0: Const( + name: T_21 + value: Expr_BinaryOp_Identical( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 21: Stmt_Const( + consts: array( + 0: Const( + name: T_22 + value: Expr_BinaryOp_NotIdentical( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 22: Stmt_Const( + consts: array( + 0: Const( + name: T_23 + value: Expr_BinaryOp_NotEqual( + left: Scalar_LNumber( + value: 0 + ) + right: Scalar_String( + value: 0 + ) + ) + ) + ) + ) + 23: Stmt_Const( + consts: array( + 0: Const( + name: T_24 + value: Expr_BinaryOp_Equal( + left: Scalar_LNumber( + value: 1 + ) + right: Scalar_String( + value: 1 + ) + ) + ) + ) + ) + 24: Stmt_Const( + consts: array( + 0: Const( + name: T_25 + value: Expr_BinaryOp_Plus( + left: Scalar_LNumber( + value: 1 + ) + right: Expr_BinaryOp_Mul( + left: Scalar_LNumber( + value: 2 + ) + right: Scalar_LNumber( + value: 3 + ) + ) + ) + ) + ) + ) + 25: Stmt_Const( + consts: array( + 0: Const( + name: T_26 + value: Expr_BinaryOp_Plus( + left: Expr_BinaryOp_Plus( + left: Scalar_String( + value: 1 + ) + right: Scalar_LNumber( + value: 2 + ) + ) + right: Scalar_String( + value: 3 + ) + ) + ) + ) + ) + 26: Stmt_Const( + consts: array( + 0: Const( + name: T_27 + value: Expr_BinaryOp_Pow( + left: Scalar_LNumber( + value: 2 + ) + right: Scalar_LNumber( + value: 3 + ) + ) + ) + ) + ) + 27: Stmt_Const( + consts: array( + 0: Const( + name: T_28 + value: Expr_ArrayDimFetch( + var: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 1 + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 2 + ) + byRef: false + ) + 2: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 3 + ) + byRef: false + ) + ) + ) + dim: Scalar_LNumber( + value: 1 + ) + ) + ) + ) + ) + 28: Stmt_Const( + consts: array( + 0: Const( + name: T_29 + value: Expr_BinaryOp_Minus( + left: Scalar_LNumber( + value: 12 + ) + right: Scalar_LNumber( + value: 13 + ) + ) + ) + ) + ) + 29: Stmt_Const( + consts: array( + 0: Const( + name: T_30 + value: Expr_BinaryOp_BitwiseXor( + left: Scalar_LNumber( + value: 12 + ) + right: Scalar_LNumber( + value: 13 + ) + ) + ) + ) + ) + 30: Stmt_Const( + consts: array( + 0: Const( + name: T_31 + value: Expr_BinaryOp_BitwiseAnd( + left: Scalar_LNumber( + value: 12 + ) + right: Scalar_LNumber( + value: 13 + ) + ) + ) + ) + ) + 31: Stmt_Const( + consts: array( + 0: Const( + name: T_32 + value: Expr_BinaryOp_BitwiseOr( + left: Scalar_LNumber( + value: 12 + ) + right: Scalar_LNumber( + value: 13 + ) + ) + ) + ) + ) + 32: Stmt_Const( + consts: array( + 0: Const( + name: T_33 + value: Expr_BinaryOp_Mod( + left: Scalar_LNumber( + value: 12 + ) + right: Scalar_LNumber( + value: 3 + ) + ) + ) + ) + ) + 33: Stmt_Const( + consts: array( + 0: Const( + name: T_34 + value: Expr_BinaryOp_ShiftRight( + left: Scalar_LNumber( + value: 100 + ) + right: Scalar_LNumber( + value: 4 + ) + ) + ) + ) + ) + 34: Stmt_Const( + consts: array( + 0: Const( + name: T_35 + value: Expr_BooleanNot( + expr: Expr_ConstFetch( + name: Name( + parts: array( + 0: false + ) + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/errorSuppress.test b/lib/nikic/php-parser/test/code/parser/expr/errorSuppress.test new file mode 100644 index 000000000..ce3fce96a --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/errorSuppress.test @@ -0,0 +1,12 @@ +Error suppression +----- +b['c'](); + +// array dereferencing +a()['b']; +----- +array( + 0: Expr_FuncCall( + name: Name( + parts: array( + 0: a + ) + comments: array( + 0: // function name variations + ) + ) + args: array( + ) + comments: array( + 0: // function name variations + ) + ) + 1: Expr_FuncCall( + name: Expr_Variable( + name: a + ) + args: array( + ) + ) + 2: Expr_FuncCall( + name: Expr_Variable( + name: Scalar_String( + value: a + ) + ) + args: array( + ) + ) + 3: Expr_FuncCall( + name: Expr_Variable( + name: Expr_Variable( + name: a + ) + ) + args: array( + ) + ) + 4: Expr_FuncCall( + name: Expr_Variable( + name: Expr_Variable( + name: Expr_Variable( + name: a + ) + ) + ) + args: array( + ) + ) + 5: Expr_FuncCall( + name: Expr_ArrayDimFetch( + var: Expr_Variable( + name: a + ) + dim: Scalar_String( + value: b + ) + ) + args: array( + ) + ) + 6: Expr_FuncCall( + name: Expr_ArrayDimFetch( + var: Expr_Variable( + name: a + ) + dim: Scalar_String( + value: b + ) + ) + args: array( + ) + ) + 7: Expr_FuncCall( + name: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + dim: Scalar_String( + value: c + ) + ) + args: array( + ) + ) + 8: Expr_ArrayDimFetch( + var: Expr_FuncCall( + name: Name( + parts: array( + 0: a + ) + comments: array( + 0: // array dereferencing + ) + ) + args: array( + ) + comments: array( + 0: // array dereferencing + ) + ) + dim: Scalar_String( + value: b + ) + comments: array( + 0: // array dereferencing + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test new file mode 100644 index 000000000..5e36ff810 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test @@ -0,0 +1,70 @@ +New expression dereferencing +----- +b; +(new A)->b(); +(new A)['b']; +(new A)['b']['c']; +----- +array( + 0: Expr_PropertyFetch( + var: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) + name: b + ) + 1: Expr_MethodCall( + var: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) + name: b + args: array( + ) + ) + 2: Expr_ArrayDimFetch( + var: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) + dim: Scalar_String( + value: b + ) + ) + 3: Expr_ArrayDimFetch( + var: Expr_ArrayDimFetch( + var: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) + dim: Scalar_String( + value: b + ) + ) + dim: Scalar_String( + value: c + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test new file mode 100644 index 000000000..584461bde --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test @@ -0,0 +1,145 @@ +Object access +----- +b; +$a->b['c']; +$a->b{'c'}; + +// method call variations +$a->b(); +$a->{'b'}(); +$a->$b(); +$a->$b['c'](); + +// array dereferencing +$a->b()['c']; +$a->b(){'c'}; // invalid PHP: drop Support? +----- +!!php5 +array( + 0: Expr_PropertyFetch( + var: Expr_Variable( + name: a + comments: array( + 0: // property fetch variations + ) + ) + name: b + comments: array( + 0: // property fetch variations + ) + ) + 1: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + dim: Scalar_String( + value: c + ) + ) + 2: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + dim: Scalar_String( + value: c + ) + ) + 3: Expr_MethodCall( + var: Expr_Variable( + name: a + comments: array( + 0: // method call variations + ) + ) + name: b + args: array( + ) + comments: array( + 0: // method call variations + ) + ) + 4: Expr_MethodCall( + var: Expr_Variable( + name: a + ) + name: Scalar_String( + value: b + ) + args: array( + ) + ) + 5: Expr_MethodCall( + var: Expr_Variable( + name: a + ) + name: Expr_Variable( + name: b + ) + args: array( + ) + ) + 6: Expr_MethodCall( + var: Expr_Variable( + name: a + ) + name: Expr_ArrayDimFetch( + var: Expr_Variable( + name: b + ) + dim: Scalar_String( + value: c + ) + ) + args: array( + ) + ) + 7: Expr_ArrayDimFetch( + var: Expr_MethodCall( + var: Expr_Variable( + name: a + comments: array( + 0: // array dereferencing + ) + ) + name: b + args: array( + ) + comments: array( + 0: // array dereferencing + ) + ) + dim: Scalar_String( + value: c + ) + comments: array( + 0: // array dereferencing + ) + ) + 8: Expr_ArrayDimFetch( + var: Expr_MethodCall( + var: Expr_Variable( + name: a + ) + name: b + args: array( + ) + ) + dim: Scalar_String( + value: c + ) + ) + 9: Stmt_Nop( + comments: array( + 0: // invalid PHP: drop Support? + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test new file mode 100644 index 000000000..ea3f9ef43 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test @@ -0,0 +1,62 @@ +Simple array access +----- + $b) = ['a' => 'b']; +list('a' => list($b => $c), 'd' => $e) = $x; +----- +!!php7 +array( + 0: Expr_Assign( + var: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Expr_Variable( + name: b + ) + byRef: false + ) + ) + ) + expr: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Scalar_String( + value: b + ) + byRef: false + ) + ) + ) + ) + 1: Expr_Assign( + var: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: Expr_Variable( + name: b + ) + value: Expr_Variable( + name: c + ) + byRef: false + ) + ) + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: Scalar_String( + value: d + ) + value: Expr_Variable( + name: e + ) + byRef: false + ) + ) + ) + expr: Expr_Variable( + name: x + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/logic.test b/lib/nikic/php-parser/test/code/parser/expr/logic.test new file mode 100644 index 000000000..b3634e91a --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/logic.test @@ -0,0 +1,159 @@ +Logical operators +----- +> $b; +$a ** $b; + +// associativity +$a * $b * $c; +$a * ($b * $c); + +// precedence +$a + $b * $c; +($a + $b) * $c; + +// pow is special +$a ** $b ** $c; +($a ** $b) ** $c; +----- +array( + 0: Expr_BitwiseNot( + expr: Expr_Variable( + name: a + ) + comments: array( + 0: // unary ops + ) + ) + 1: Expr_UnaryPlus( + expr: Expr_Variable( + name: a + ) + ) + 2: Expr_UnaryMinus( + expr: Expr_Variable( + name: a + ) + ) + 3: Expr_BinaryOp_BitwiseAnd( + left: Expr_Variable( + name: a + comments: array( + 0: // binary ops + ) + ) + right: Expr_Variable( + name: b + ) + comments: array( + 0: // binary ops + ) + ) + 4: Expr_BinaryOp_BitwiseOr( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 5: Expr_BinaryOp_BitwiseXor( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 6: Expr_BinaryOp_Concat( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 7: Expr_BinaryOp_Div( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 8: Expr_BinaryOp_Minus( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 9: Expr_BinaryOp_Mod( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 10: Expr_BinaryOp_Mul( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 11: Expr_BinaryOp_Plus( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 12: Expr_BinaryOp_ShiftLeft( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 13: Expr_BinaryOp_ShiftRight( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 14: Expr_BinaryOp_Pow( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + 15: Expr_BinaryOp_Mul( + left: Expr_BinaryOp_Mul( + left: Expr_Variable( + name: a + comments: array( + 0: // associativity + ) + ) + right: Expr_Variable( + name: b + ) + comments: array( + 0: // associativity + ) + ) + right: Expr_Variable( + name: c + ) + comments: array( + 0: // associativity + ) + ) + 16: Expr_BinaryOp_Mul( + left: Expr_Variable( + name: a + ) + right: Expr_BinaryOp_Mul( + left: Expr_Variable( + name: b + ) + right: Expr_Variable( + name: c + ) + ) + ) + 17: Expr_BinaryOp_Plus( + left: Expr_Variable( + name: a + comments: array( + 0: // precedence + ) + ) + right: Expr_BinaryOp_Mul( + left: Expr_Variable( + name: b + ) + right: Expr_Variable( + name: c + ) + ) + comments: array( + 0: // precedence + ) + ) + 18: Expr_BinaryOp_Mul( + left: Expr_BinaryOp_Plus( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + right: Expr_Variable( + name: c + ) + ) + 19: Expr_BinaryOp_Pow( + left: Expr_Variable( + name: a + comments: array( + 0: // pow is special + ) + ) + right: Expr_BinaryOp_Pow( + left: Expr_Variable( + name: b + ) + right: Expr_Variable( + name: c + ) + ) + comments: array( + 0: // pow is special + ) + ) + 20: Expr_BinaryOp_Pow( + left: Expr_BinaryOp_Pow( + left: Expr_Variable( + name: a + ) + right: Expr_Variable( + name: b + ) + ) + right: Expr_Variable( + name: c + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/new.test b/lib/nikic/php-parser/test/code/parser/expr/new.test new file mode 100644 index 000000000..a132bbb45 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/new.test @@ -0,0 +1,146 @@ +New +----- +b(); +new $a->b->c(); +new $a->b['c'](); +new $a->b{'c'}(); + +// test regression introduces by new dereferencing syntax +(new A); +----- +array( + 0: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) + 1: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + 0: Arg( + value: Expr_Variable( + name: b + ) + byRef: false + unpack: false + ) + ) + ) + 2: Expr_New( + class: Expr_Variable( + name: a + ) + args: array( + ) + comments: array( + 0: // class name variations + ) + ) + 3: Expr_New( + class: Expr_ArrayDimFetch( + var: Expr_Variable( + name: a + ) + dim: Scalar_String( + value: b + ) + ) + args: array( + ) + ) + 4: Expr_New( + class: Expr_StaticPropertyFetch( + class: Name( + parts: array( + 0: A + ) + ) + name: b + ) + args: array( + ) + ) + 5: Expr_New( + class: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + args: array( + ) + comments: array( + 0: // DNCR object access + ) + ) + 6: Expr_New( + class: Expr_PropertyFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + name: c + ) + args: array( + ) + ) + 7: Expr_New( + class: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + dim: Scalar_String( + value: c + ) + ) + args: array( + ) + ) + 8: Expr_New( + class: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Variable( + name: a + ) + name: b + ) + dim: Scalar_String( + value: c + ) + ) + args: array( + ) + ) + 9: Expr_New( + class: Name( + parts: array( + 0: A + ) + ) + args: array( + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/newWithoutClass.test b/lib/nikic/php-parser/test/code/parser/expr/newWithoutClass.test new file mode 100644 index 000000000..ca7f4981e --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/newWithoutClass.test @@ -0,0 +1,23 @@ +New without a class +----- +bar; +----- +!!php7 +Syntax error, unexpected T_OBJECT_OPERATOR, expecting ';' from 2:13 to 2:14 +array( + 0: Stmt_Global( + vars: array( + 0: Expr_Variable( + name: Expr_Variable( + name: foo + ) + ) + ) + ) + 1: Expr_ConstFetch( + name: Name( + parts: array( + 0: bar + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/expr/uvs/indirectCall.test b/lib/nikic/php-parser/test/code/parser/expr/uvs/indirectCall.test new file mode 100644 index 000000000..bb3e7fbea --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/uvs/indirectCall.test @@ -0,0 +1,481 @@ +UVS indirect calls +----- + 'b']->a); +isset("str"->a); +----- +!!php7 +array( + 0: Expr_Isset( + vars: array( + 0: Expr_ArrayDimFetch( + var: Expr_BinaryOp_Plus( + left: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 0 + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 1 + ) + byRef: false + ) + ) + ) + right: Expr_Array( + items: array( + ) + ) + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + 1: Expr_Isset( + vars: array( + 0: Expr_PropertyFetch( + var: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: Scalar_String( + value: a + ) + value: Scalar_String( + value: b + ) + byRef: false + ) + ) + ) + name: a + ) + ) + ) + 2: Expr_Isset( + vars: array( + 0: Expr_PropertyFetch( + var: Scalar_String( + value: str + ) + name: a + ) + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/expr/uvs/misc.test b/lib/nikic/php-parser/test/code/parser/expr/uvs/misc.test new file mode 100644 index 000000000..2c5ba900e --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/uvs/misc.test @@ -0,0 +1,109 @@ +Uniform variable syntax in PHP 7 (misc) +----- +length(); +(clone $obj)->b[0](1); +[0, 1][0] = 1; +----- +!!php7 +array( + 0: Expr_ArrayDimFetch( + var: Expr_ClassConstFetch( + class: Name( + parts: array( + 0: A + ) + ) + name: A + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + 1: Expr_ArrayDimFetch( + var: Expr_ArrayDimFetch( + var: Expr_ArrayDimFetch( + var: Expr_ClassConstFetch( + class: Name( + parts: array( + 0: A + ) + ) + name: A + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + dim: Scalar_LNumber( + value: 1 + ) + ) + dim: Scalar_LNumber( + value: 2 + ) + ) + 2: Expr_MethodCall( + var: Scalar_String( + value: string + ) + name: length + args: array( + ) + ) + 3: Expr_FuncCall( + name: Expr_ArrayDimFetch( + var: Expr_PropertyFetch( + var: Expr_Clone( + expr: Expr_Variable( + name: obj + ) + ) + name: b + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + args: array( + 0: Arg( + value: Scalar_LNumber( + value: 1 + ) + byRef: false + unpack: false + ) + ) + ) + 4: Expr_Assign( + var: Expr_ArrayDimFetch( + var: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 0 + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Scalar_LNumber( + value: 1 + ) + byRef: false + ) + ) + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + expr: Scalar_LNumber( + value: 1 + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/expr/uvs/new.test b/lib/nikic/php-parser/test/code/parser/expr/uvs/new.test new file mode 100644 index 000000000..e5f92f97a --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/uvs/new.test @@ -0,0 +1,95 @@ +UVS new expressions +----- +className; +new Test::$className; +new $test::$className; +new $weird[0]->foo::$className; +----- +!!php7 +array( + 0: Expr_New( + class: Expr_Variable( + name: className + ) + args: array( + ) + ) + 1: Expr_New( + class: Expr_ArrayDimFetch( + var: Expr_Variable( + name: array + ) + dim: Scalar_String( + value: className + ) + ) + args: array( + ) + ) + 2: Expr_New( + class: Expr_ArrayDimFetch( + var: Expr_Variable( + name: array + ) + dim: Scalar_String( + value: className + ) + ) + args: array( + ) + ) + 3: Expr_New( + class: Expr_PropertyFetch( + var: Expr_Variable( + name: obj + ) + name: className + ) + args: array( + ) + ) + 4: Expr_New( + class: Expr_StaticPropertyFetch( + class: Name( + parts: array( + 0: Test + ) + ) + name: className + ) + args: array( + ) + ) + 5: Expr_New( + class: Expr_StaticPropertyFetch( + class: Expr_Variable( + name: test + ) + name: className + ) + args: array( + ) + ) + 6: Expr_New( + class: Expr_StaticPropertyFetch( + class: Expr_PropertyFetch( + var: Expr_ArrayDimFetch( + var: Expr_Variable( + name: weird + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + name: foo + ) + name: className + ) + args: array( + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/expr/uvs/staticProperty.test b/lib/nikic/php-parser/test/code/parser/expr/uvs/staticProperty.test new file mode 100644 index 000000000..5fadfc483 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/expr/uvs/staticProperty.test @@ -0,0 +1,93 @@ +UVS static access +----- +c test +EOS; + +b<<B"; +"$A[B]"; +"$A[0]"; +"$A[1234]"; +"$A[9223372036854775808]"; +"$A[000]"; +"$A[0x0]"; +"$A[0b0]"; +"$A[$B]"; +"{$A}"; +"{$A['B']}"; +"${A}"; +"${A['B']}"; +"${$A}"; +"\{$A}"; +"\{ $A }"; +"\\{$A}"; +"\\{ $A }"; +"{$$A}[B]"; +"$$A[B]"; +"A $B C"; +b"$A"; +B"$A"; +----- +array( + 0: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: A + ) + ) + ) + 1: Scalar_Encapsed( + parts: array( + 0: Expr_PropertyFetch( + var: Expr_Variable( + name: A + ) + name: B + ) + ) + ) + 2: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: B + ) + ) + ) + ) + 3: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_LNumber( + value: 0 + ) + ) + ) + ) + 4: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_LNumber( + value: 1234 + ) + ) + ) + ) + 5: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: 9223372036854775808 + ) + ) + ) + ) + 6: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: 000 + ) + ) + ) + ) + 7: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: 0x0 + ) + ) + ) + ) + 8: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: 0b0 + ) + ) + ) + ) + 9: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Expr_Variable( + name: B + ) + ) + ) + ) + 10: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: A + ) + ) + ) + 11: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: B + ) + ) + ) + ) + 12: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: A + ) + ) + ) + 13: Scalar_Encapsed( + parts: array( + 0: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: B + ) + ) + ) + ) + 14: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: Expr_Variable( + name: A + ) + ) + ) + ) + 15: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: \{ + ) + 1: Expr_Variable( + name: A + ) + 2: Scalar_EncapsedStringPart( + value: } + ) + ) + ) + 16: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: \{ + ) + 1: Expr_Variable( + name: A + ) + 2: Scalar_EncapsedStringPart( + value: } + ) + ) + ) + 17: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: \ + ) + 1: Expr_Variable( + name: A + ) + ) + ) + 18: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: \{ + ) + 1: Expr_Variable( + name: A + ) + 2: Scalar_EncapsedStringPart( + value: } + ) + ) + ) + 19: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: Expr_Variable( + name: A + ) + ) + 1: Scalar_EncapsedStringPart( + value: [B] + ) + ) + ) + 20: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: $ + ) + 1: Expr_ArrayDimFetch( + var: Expr_Variable( + name: A + ) + dim: Scalar_String( + value: B + ) + ) + ) + ) + 21: Scalar_Encapsed( + parts: array( + 0: Scalar_EncapsedStringPart( + value: A + ) + 1: Expr_Variable( + name: B + ) + 2: Scalar_EncapsedStringPart( + value: C + ) + ) + ) + 22: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: A + ) + ) + ) + 23: Scalar_Encapsed( + parts: array( + 0: Expr_Variable( + name: A + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/scalar/float.test b/lib/nikic/php-parser/test/code/parser/scalar/float.test new file mode 100644 index 000000000..a16028e2a --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/scalar/float.test @@ -0,0 +1,74 @@ +Different float syntaxes +----- + float overflows +// (all are actually the same number, just in different representations) +18446744073709551615; +0xFFFFFFFFFFFFFFFF; +01777777777777777777777; +0177777777777777777777787; +0b1111111111111111111111111111111111111111111111111111111111111111; +----- +array( + 0: Scalar_DNumber( + value: 0 + ) + 1: Scalar_DNumber( + value: 0 + ) + 2: Scalar_DNumber( + value: 0 + ) + 3: Scalar_DNumber( + value: 0 + ) + 4: Scalar_DNumber( + value: 0 + ) + 5: Scalar_DNumber( + value: 0 + ) + 6: Scalar_DNumber( + value: 0 + ) + 7: Scalar_DNumber( + value: 302000000000 + ) + 8: Scalar_DNumber( + value: 3.002E+102 + ) + 9: Scalar_DNumber( + value: INF + ) + 10: Scalar_DNumber( + value: 1.844674407371E+19 + comments: array( + 0: // various integer -> float overflows + 1: // (all are actually the same number, just in different representations) + ) + ) + 11: Scalar_DNumber( + value: 1.844674407371E+19 + ) + 12: Scalar_DNumber( + value: 1.844674407371E+19 + ) + 13: Scalar_DNumber( + value: 1.844674407371E+19 + ) + 14: Scalar_DNumber( + value: 1.844674407371E+19 + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/scalar/int.test b/lib/nikic/php-parser/test/code/parser/scalar/int.test new file mode 100644 index 000000000..5a212677c --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/scalar/int.test @@ -0,0 +1,43 @@ +Different integer syntaxes +----- +array(); +$t->public(); + +Test::list(); +Test::protected(); + +$t->class; +$t->private; + +Test::TRAIT; +Test::FINAL; + +class Foo { + use TraitA, TraitB { + TraitA::catch insteadof namespace\TraitB; + TraitA::list as foreach; + TraitB::throw as protected public; + TraitB::self as protected; + exit as die; + \TraitC::exit as bye; + namespace\TraitC::exit as byebye; + TraitA:: + // + /** doc comment */ + # + catch /* comment */ + // comment + # comment + insteadof TraitB; + } +} +----- +array( + 0: Stmt_Class( + flags: 0 + name: Test + extends: null + implements: array( + ) + stmts: array( + 0: Stmt_ClassMethod( + flags: 0 + byRef: false + name: array + params: array( + ) + returnType: null + stmts: array( + ) + ) + 1: Stmt_ClassMethod( + flags: 0 + byRef: false + name: public + params: array( + ) + returnType: null + stmts: array( + ) + ) + 2: Stmt_ClassMethod( + flags: MODIFIER_STATIC (8) + byRef: false + name: list + params: array( + ) + returnType: null + stmts: array( + ) + ) + 3: Stmt_ClassMethod( + flags: MODIFIER_STATIC (8) + byRef: false + name: protected + params: array( + ) + returnType: null + stmts: array( + ) + ) + 4: Stmt_Property( + flags: MODIFIER_PUBLIC (1) + props: array( + 0: Stmt_PropertyProperty( + name: class + default: null + ) + ) + ) + 5: Stmt_Property( + flags: MODIFIER_PUBLIC (1) + props: array( + 0: Stmt_PropertyProperty( + name: private + default: null + ) + ) + ) + 6: Stmt_ClassConst( + flags: 0 + consts: array( + 0: Const( + name: TRAIT + value: Scalar_LNumber( + value: 3 + ) + ) + 1: Const( + name: FINAL + value: Scalar_LNumber( + value: 4 + ) + ) + ) + ) + 7: Stmt_ClassConst( + flags: 0 + consts: array( + 0: Const( + name: __CLASS__ + value: Scalar_LNumber( + value: 1 + ) + ) + 1: Const( + name: __TRAIT__ + value: Scalar_LNumber( + value: 2 + ) + ) + 2: Const( + name: __FUNCTION__ + value: Scalar_LNumber( + value: 3 + ) + ) + 3: Const( + name: __METHOD__ + value: Scalar_LNumber( + value: 4 + ) + ) + 4: Const( + name: __LINE__ + value: Scalar_LNumber( + value: 5 + ) + ) + 5: Const( + name: __FILE__ + value: Scalar_LNumber( + value: 6 + ) + ) + 6: Const( + name: __DIR__ + value: Scalar_LNumber( + value: 7 + ) + ) + 7: Const( + name: __NAMESPACE__ + value: Scalar_LNumber( + value: 8 + ) + ) + ) + ) + ) + ) + 1: Expr_Assign( + var: Expr_Variable( + name: t + ) + expr: Expr_New( + class: Name( + parts: array( + 0: Test + ) + ) + args: array( + ) + ) + ) + 2: Expr_MethodCall( + var: Expr_Variable( + name: t + ) + name: array + args: array( + ) + ) + 3: Expr_MethodCall( + var: Expr_Variable( + name: t + ) + name: public + args: array( + ) + ) + 4: Expr_StaticCall( + class: Name( + parts: array( + 0: Test + ) + ) + name: list + args: array( + ) + ) + 5: Expr_StaticCall( + class: Name( + parts: array( + 0: Test + ) + ) + name: protected + args: array( + ) + ) + 6: Expr_PropertyFetch( + var: Expr_Variable( + name: t + ) + name: class + ) + 7: Expr_PropertyFetch( + var: Expr_Variable( + name: t + ) + name: private + ) + 8: Expr_ClassConstFetch( + class: Name( + parts: array( + 0: Test + ) + ) + name: TRAIT + ) + 9: Expr_ClassConstFetch( + class: Name( + parts: array( + 0: Test + ) + ) + name: FINAL + ) + 10: Stmt_Class( + flags: 0 + name: Foo + extends: null + implements: array( + ) + stmts: array( + 0: Stmt_TraitUse( + traits: array( + 0: Name( + parts: array( + 0: TraitA + ) + ) + 1: Name( + parts: array( + 0: TraitB + ) + ) + ) + adaptations: array( + 0: Stmt_TraitUseAdaptation_Precedence( + trait: Name( + parts: array( + 0: TraitA + ) + ) + method: catch + insteadof: array( + 0: Name_Relative( + parts: array( + 0: TraitB + ) + ) + ) + ) + 1: Stmt_TraitUseAdaptation_Alias( + trait: Name( + parts: array( + 0: TraitA + ) + ) + method: list + newModifier: null + newName: foreach + ) + 2: Stmt_TraitUseAdaptation_Alias( + trait: Name( + parts: array( + 0: TraitB + ) + ) + method: throw + newModifier: MODIFIER_PROTECTED (2) + newName: public + ) + 3: Stmt_TraitUseAdaptation_Alias( + trait: Name( + parts: array( + 0: TraitB + ) + ) + method: self + newModifier: MODIFIER_PROTECTED (2) + newName: null + ) + 4: Stmt_TraitUseAdaptation_Alias( + trait: null + method: exit + newModifier: null + newName: die + ) + 5: Stmt_TraitUseAdaptation_Alias( + trait: Name_FullyQualified( + parts: array( + 0: TraitC + ) + ) + method: exit + newModifier: null + newName: bye + ) + 6: Stmt_TraitUseAdaptation_Alias( + trait: Name_Relative( + parts: array( + 0: TraitC + ) + ) + method: exit + newModifier: null + newName: byebye + ) + 7: Stmt_TraitUseAdaptation_Precedence( + trait: Name( + parts: array( + 0: TraitA + ) + ) + method: catch + insteadof: array( + 0: Name( + parts: array( + 0: TraitB + ) + ) + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test b/lib/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test new file mode 100644 index 000000000..ae83dabb9 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test @@ -0,0 +1,112 @@ +Blockless statements for if/for/etc +----- + 'baz'] +) {} +----- +array( + 0: Stmt_Function( + byRef: false + name: a + params: array( + 0: Param( + type: null + byRef: false + variadic: false + name: b + default: Expr_ConstFetch( + name: Name( + parts: array( + 0: null + ) + ) + ) + ) + 1: Param( + type: null + byRef: false + variadic: false + name: c + default: Scalar_String( + value: foo + ) + ) + 2: Param( + type: null + byRef: false + variadic: false + name: d + default: Expr_ClassConstFetch( + class: Name( + parts: array( + 0: A + ) + ) + name: B + ) + ) + 3: Param( + type: null + byRef: false + variadic: false + name: f + default: Expr_UnaryPlus( + expr: Scalar_LNumber( + value: 1 + ) + ) + ) + 4: Param( + type: null + byRef: false + variadic: false + name: g + default: Expr_UnaryMinus( + expr: Scalar_DNumber( + value: 1 + ) + ) + ) + 5: Param( + type: null + byRef: false + variadic: false + name: h + default: Expr_Array( + items: array( + ) + ) + ) + 6: Param( + type: null + byRef: false + variadic: false + name: i + default: Expr_Array( + items: array( + ) + ) + ) + 7: Param( + type: null + byRef: false + variadic: false + name: j + default: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: foo + ) + byRef: false + ) + ) + ) + ) + 8: Param( + type: null + byRef: false + variadic: false + name: k + default: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Scalar_String( + value: foo + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: Scalar_String( + value: bar + ) + value: Scalar_String( + value: baz + ) + byRef: false + ) + ) + ) + ) + ) + returnType: null + stmts: array( + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/stmt/function/nullableTypes.test b/lib/nikic/php-parser/test/code/parser/stmt/function/nullableTypes.test new file mode 100644 index 000000000..d96df4fae --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/function/nullableTypes.test @@ -0,0 +1,47 @@ +Nullable types +----- + $value; + + // expressions + $data = yield; + $data = (yield $value); + $data = (yield $key => $value); + + // yield in language constructs with their own parentheses + if (yield $foo); elseif (yield $foo); + if (yield $foo): elseif (yield $foo): endif; + while (yield $foo); + do {} while (yield $foo); + switch (yield $foo) {} + die(yield $foo); + + // yield in function calls + func(yield $foo); + $foo->func(yield $foo); + new Foo(yield $foo); + + yield from $foo; + yield from $foo and yield from $bar; + yield from $foo + $bar; +} +----- +array( + 0: Stmt_Function( + byRef: false + name: gen + params: array( + ) + returnType: null + stmts: array( + 0: Expr_Yield( + key: null + value: null + comments: array( + 0: // statements + ) + ) + 1: Expr_Yield( + key: null + value: Expr_Variable( + name: value + ) + ) + 2: Expr_Yield( + key: Expr_Variable( + name: key + ) + value: Expr_Variable( + name: value + ) + ) + 3: Expr_Assign( + var: Expr_Variable( + name: data + comments: array( + 0: // expressions + ) + ) + expr: Expr_Yield( + key: null + value: null + ) + comments: array( + 0: // expressions + ) + ) + 4: Expr_Assign( + var: Expr_Variable( + name: data + ) + expr: Expr_Yield( + key: null + value: Expr_Variable( + name: value + ) + ) + ) + 5: Expr_Assign( + var: Expr_Variable( + name: data + ) + expr: Expr_Yield( + key: Expr_Variable( + name: key + ) + value: Expr_Variable( + name: value + ) + ) + ) + 6: Stmt_If( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + elseifs: array( + 0: Stmt_ElseIf( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + ) + ) + else: null + comments: array( + 0: // yield in language constructs with their own parentheses + ) + ) + 7: Stmt_If( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + elseifs: array( + 0: Stmt_ElseIf( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + ) + ) + else: null + ) + 8: Stmt_While( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + ) + 9: Stmt_Do( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + stmts: array( + ) + ) + 10: Stmt_Switch( + cond: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + cases: array( + ) + ) + 11: Expr_Exit( + expr: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + ) + 12: Expr_FuncCall( + name: Name( + parts: array( + 0: func + ) + comments: array( + 0: // yield in function calls + ) + ) + args: array( + 0: Arg( + value: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + byRef: false + unpack: false + ) + ) + comments: array( + 0: // yield in function calls + ) + ) + 13: Expr_MethodCall( + var: Expr_Variable( + name: foo + ) + name: func + args: array( + 0: Arg( + value: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + byRef: false + unpack: false + ) + ) + ) + 14: Expr_New( + class: Name( + parts: array( + 0: Foo + ) + ) + args: array( + 0: Arg( + value: Expr_Yield( + key: null + value: Expr_Variable( + name: foo + ) + ) + byRef: false + unpack: false + ) + ) + ) + 15: Expr_YieldFrom( + expr: Expr_Variable( + name: foo + ) + ) + 16: Expr_BinaryOp_LogicalAnd( + left: Expr_YieldFrom( + expr: Expr_Variable( + name: foo + ) + ) + right: Expr_YieldFrom( + expr: Expr_Variable( + name: bar + ) + ) + ) + 17: Expr_YieldFrom( + expr: Expr_BinaryOp_Plus( + left: Expr_Variable( + name: foo + ) + right: Expr_Variable( + name: bar + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldPrecedence.test b/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldPrecedence.test new file mode 100644 index 000000000..ff0d4df08 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldPrecedence.test @@ -0,0 +1,230 @@ +Yield operator precedence +----- + "a" . "b"; + yield "k" => "a" or die; + var_dump([yield "k" => "a" . "b"]); + yield yield "k1" => yield "k2" => "a" . "b"; + yield yield "k1" => (yield "k2") => "a" . "b"; + var_dump([yield "k1" => yield "k2" => "a" . "b"]); + var_dump([yield "k1" => (yield "k2") => "a" . "b"]); +} +----- +!!php7 +array( + 0: Stmt_Function( + byRef: false + name: gen + params: array( + ) + returnType: null + stmts: array( + 0: Expr_Yield( + key: null + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + 1: Expr_BinaryOp_LogicalOr( + left: Expr_Yield( + key: null + value: Scalar_String( + value: a + ) + ) + right: Expr_Exit( + expr: null + ) + ) + 2: Expr_Yield( + key: Scalar_String( + value: k + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + 3: Expr_BinaryOp_LogicalOr( + left: Expr_Yield( + key: Scalar_String( + value: k + ) + value: Scalar_String( + value: a + ) + ) + right: Expr_Exit( + expr: null + ) + ) + 4: Expr_FuncCall( + name: Name( + parts: array( + 0: var_dump + ) + ) + args: array( + 0: Arg( + value: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Yield( + key: Scalar_String( + value: k + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + byRef: false + ) + ) + ) + byRef: false + unpack: false + ) + ) + ) + 5: Expr_Yield( + key: null + value: Expr_Yield( + key: Scalar_String( + value: k1 + ) + value: Expr_Yield( + key: Scalar_String( + value: k2 + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + ) + ) + 6: Expr_Yield( + key: Expr_Yield( + key: Scalar_String( + value: k1 + ) + value: Expr_Yield( + key: null + value: Scalar_String( + value: k2 + ) + ) + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + 7: Expr_FuncCall( + name: Name( + parts: array( + 0: var_dump + ) + ) + args: array( + 0: Arg( + value: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Yield( + key: Scalar_String( + value: k1 + ) + value: Expr_Yield( + key: Scalar_String( + value: k2 + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + ) + ) + byRef: false + ) + ) + ) + byRef: false + unpack: false + ) + ) + ) + 8: Expr_FuncCall( + name: Name( + parts: array( + 0: var_dump + ) + ) + args: array( + 0: Arg( + value: Expr_Array( + items: array( + 0: Expr_ArrayItem( + key: Expr_Yield( + key: Scalar_String( + value: k1 + ) + value: Expr_Yield( + key: null + value: Scalar_String( + value: k2 + ) + ) + ) + value: Expr_BinaryOp_Concat( + left: Scalar_String( + value: a + ) + right: Scalar_String( + value: b + ) + ) + byRef: false + ) + ) + ) + byRef: false + unpack: false + ) + ) + ) + ) + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldUnaryPrecedence.test b/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldUnaryPrecedence.test new file mode 100644 index 000000000..13f96602c --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/generator/yieldUnaryPrecedence.test @@ -0,0 +1,48 @@ +Yield with unary operator argument +----- + +Hallo World! +----- +array( + 0: Expr_Variable( + name: a + ) + 1: Stmt_HaltCompiler( + remaining: Hallo World! + ) +) +----- + +#!/usr/bin/env php +----- +array( + 0: Stmt_InlineHTML( + value: #!/usr/bin/env php + + ) + 1: Stmt_Echo( + exprs: array( + 0: Scalar_String( + value: foobar + ) + ) + ) + 2: Stmt_InlineHTML( + value: #!/usr/bin/env php + ) +) diff --git a/lib/nikic/php-parser/test/code/parser/stmt/if.test b/lib/nikic/php-parser/test/code/parser/stmt/if.test new file mode 100644 index 000000000..e054c8976 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/if.test @@ -0,0 +1,103 @@ +If/Elseif/Else +----- + +B + + $c) {} +foreach ($a as $b => &$c) {} +foreach ($a as list($a, $b)) {} +foreach ($a as $a => list($b, , $c)) {} + +// foreach on expression +foreach (array() as $b) {} + +// alternative syntax +foreach ($a as $b): +endforeach; +----- +array( + 0: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: null + byRef: false + valueVar: Expr_Variable( + name: b + ) + stmts: array( + ) + comments: array( + 0: // foreach on variable + ) + ) + 1: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: null + byRef: true + valueVar: Expr_Variable( + name: b + ) + stmts: array( + ) + ) + 2: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: Expr_Variable( + name: b + ) + byRef: false + valueVar: Expr_Variable( + name: c + ) + stmts: array( + ) + ) + 3: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: Expr_Variable( + name: b + ) + byRef: true + valueVar: Expr_Variable( + name: c + ) + stmts: array( + ) + ) + 4: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: null + byRef: false + valueVar: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: a + ) + byRef: false + ) + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + ) + ) + stmts: array( + ) + ) + 5: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: Expr_Variable( + name: a + ) + byRef: false + valueVar: Expr_List( + items: array( + 0: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: b + ) + byRef: false + ) + 1: null + 2: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: c + ) + byRef: false + ) + ) + ) + stmts: array( + ) + ) + 6: Stmt_Foreach( + expr: Expr_Array( + items: array( + ) + ) + keyVar: null + byRef: false + valueVar: Expr_Variable( + name: b + ) + stmts: array( + ) + comments: array( + 0: // foreach on expression + ) + ) + 7: Stmt_Foreach( + expr: Expr_Variable( + name: a + ) + keyVar: null + byRef: false + valueVar: Expr_Variable( + name: b + ) + stmts: array( + ) + comments: array( + 0: // alternative syntax + ) + ) +) \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/parser/stmt/loop/while.test b/lib/nikic/php-parser/test/code/parser/stmt/loop/while.test new file mode 100644 index 000000000..65f6b2336 --- /dev/null +++ b/lib/nikic/php-parser/test/code/parser/stmt/loop/while.test @@ -0,0 +1,25 @@ +While loop +----- + +Hi! +----- +array( + 0: Stmt_Declare( + declares: array( + 0: Stmt_DeclareDeclare( + key: A + value: Scalar_String( + value: B + ) + ) + ) + stmts: null + ) + 1: Stmt_Namespace( + name: Name( + parts: array( + 0: B + ) + ) + stmts: array( + ) + ) + 2: Stmt_HaltCompiler( + remaining: Hi! + ) +) +----- +a = $a; + } +}; +----- +new class +{ +}; +new class extends A implements B, C +{ +}; +new class($a) extends A +{ + private $a; + public function __construct($a) + { + $this->a = $a; + } +}; diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/arrayDestructuring.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/arrayDestructuring.test new file mode 100644 index 000000000..bff1999e4 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/arrayDestructuring.test @@ -0,0 +1,14 @@ +Array destructuring +----- + $b, 'b' => $a] = $baz; +----- +!!php7 +[$a, $b] = [$c, $d]; +[, $a, , , $b, ] = $foo; +[, [[$a]], $b] = $bar; +['a' => $b, 'b' => $a] = $baz; \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/call.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/call.test new file mode 100644 index 000000000..0ec8925cf --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/call.test @@ -0,0 +1,13 @@ +Calls +----- +d} +STR; + +call( + <<d} +STR; +call(<<> $b; +$a < $b; +$a <= $b; +$a > $b; +$a >= $b; +$a == $b; +$a != $b; +$a <> $b; +$a === $b; +$a !== $b; +$a <=> $b; +$a & $b; +$a ^ $b; +$a | $b; +$a && $b; +$a || $b; +$a ? $b : $c; +$a ?: $c; +$a ?? $c; + +$a = $b; +$a **= $b; +$a *= $b; +$a /= $b; +$a %= $b; +$a += $b; +$a -= $b; +$a .= $b; +$a <<= $b; +$a >>= $b; +$a &= $b; +$a ^= $b; +$a |= $b; +$a =& $b; + +$a and $b; +$a xor $b; +$a or $b; + +$a instanceof Foo; +$a instanceof $b; +----- +$a ** $b; +++$a; +--$a; +$a++; +$a--; +@$a; +~$a; +-$a; ++$a; +(int) $a; +(int) $a; +(double) $a; +(double) $a; +(double) $a; +(string) $a; +(string) $a; +(array) $a; +(object) $a; +(bool) $a; +(bool) $a; +(unset) $a; +$a * $b; +$a / $b; +$a % $b; +$a + $b; +$a - $b; +$a . $b; +$a << $b; +$a >> $b; +$a < $b; +$a <= $b; +$a > $b; +$a >= $b; +$a == $b; +$a != $b; +$a != $b; +$a === $b; +$a !== $b; +$a <=> $b; +$a & $b; +$a ^ $b; +$a | $b; +$a && $b; +$a || $b; +$a ? $b : $c; +$a ?: $c; +$a ?? $c; +$a = $b; +$a **= $b; +$a *= $b; +$a /= $b; +$a %= $b; +$a += $b; +$a -= $b; +$a .= $b; +$a <<= $b; +$a >>= $b; +$a &= $b; +$a ^= $b; +$a |= $b; +$a =& $b; +$a and $b; +$a xor $b; +$a or $b; +$a instanceof Foo; +$a instanceof $b; diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/parentheses.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/parentheses.test new file mode 100644 index 000000000..a49c1108d --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/parentheses.test @@ -0,0 +1,86 @@ +Pretty printer generates least-parentheses output +----- + 0) > (1 < 0); +++$a + $b; +$a + $b++; + +$a ** $b ** $c; +($a ** $b) ** $c; +-1 ** 2; + +yield from $a and yield from $b; +yield from ($a and yield from $b); + +print ($a and print $b); + +-(-$a); ++(+$a); +-(--$a); ++(++$a); + +// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment +// and incdec only work on variables. +!$a = $b; +++$a ** $b; +$a ** $b++; +----- +echo 'abc' . 'cde' . 'fgh'; +echo 'abc' . ('cde' . 'fgh'); +echo 'abc' . 1 + 2 . 'fgh'; +echo 'abc' . (1 + 2) . 'fgh'; +echo 1 * 2 + 3 / 4 % 5 . 6; +echo 1 * (2 + 3) / (4 % (5 . 6)); +$a = $b = $c = $d = $f && true; +($a = $b = $c = $d = $f) && true; +$a = $b = $c = $d = $f and true; +$a = $b = $c = $d = ($f and true); +$a ? $b : $c ? $d : $e ? $f : $g; +$a ? $b : ($c ? $d : ($e ? $f : $g)); +$a ? $b ? $c : $d : $f; +$a ?? $b ?? $c; +($a ?? $b) ?? $c; +$a ?? ($b ? $c : $d); +$a || ($b ?? $c); +(1 > 0) > (1 < 0); +++$a + $b; +$a + $b++; +$a ** $b ** $c; +($a ** $b) ** $c; +-1 ** 2; +yield from $a and yield from $b; +yield from ($a and yield from $b); +print ($a and print $b); +-(-$a); ++(+$a); +-(--$a); ++(++$a); +// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment +// and incdec only work on variables. +!($a = $b); +(++$a) ** $b; +$a ** ($b++); diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/shortArraySyntax.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/shortArraySyntax.test new file mode 100644 index 000000000..082c2e047 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/shortArraySyntax.test @@ -0,0 +1,11 @@ +Short array syntax +----- + 'b', 'c' => 'd']; +----- +[]; +array(1, 2, 3); +['a' => 'b', 'c' => 'd']; \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test new file mode 100644 index 000000000..02877ad32 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test @@ -0,0 +1,23 @@ +Escape sequences in double-quoted strings +----- +b)(); +(A::$b)(); +----- +!!php7 +(function () { +})(); +array('a', 'b')()(); +A::$b::$c; +$A::$b[$c](); +$A::{$b[$c]}(); +A::${$b}[$c](); +($a->b)(); +(A::$b)(); diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/variables.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/variables.test new file mode 100644 index 000000000..4e0fa2e12 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/variables.test @@ -0,0 +1,73 @@ +Variables +----- +b; +$a->b(); +$a->b($c); +$a->$b(); +$a->{$b}(); +$a->$b[$c](); +$$a->b; +$a[$b]; +$a[$b](); +$$a[$b]; +$a::B; +$a::$b; +$a::b(); +$a::b($c); +$a::$b(); +$a::$b[$c]; +$a::$b[$c]($d); +$a::{$b[$c]}($d); +$a::{$b->c}(); +A::$$b[$c](); +a(); +$a(); +$a()[$b]; +$a->b()[$c]; +$a::$b()[$c]; +(new A)->b; +(new A())->b(); +(new $$a)[$b]; +(new $a->b)->c; + +global $a, $$a, $$a[$b], $$a->b; +----- +!!php5 +$a; +${$a}; +${$a}; +$a->b; +$a->b(); +$a->b($c); +$a->{$b}(); +$a->{$b}(); +$a->{$b[$c]}(); +${$a}->b; +$a[$b]; +$a[$b](); +${$a[$b]}; +$a::B; +$a::$b; +$a::b(); +$a::b($c); +$a::$b(); +$a::$b[$c]; +$a::{$b[$c]}($d); +$a::{$b[$c]}($d); +$a::{$b->c}(); +A::${$b[$c]}(); +a(); +$a(); +$a()[$b]; +$a->b()[$c]; +$a::$b()[$c]; +(new A())->b; +(new A())->b(); +(new ${$a}())[$b]; +(new $a->b())->c; +global $a, ${$a}, ${$a[$b]}, ${$a->b}; diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/expr/yield.test b/lib/nikic/php-parser/test/code/prettyPrinter/expr/yield.test new file mode 100644 index 000000000..12ab7dec1 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/expr/yield.test @@ -0,0 +1,46 @@ +Yield +----- + $b; + $a = yield; + $a = (yield $b); + $a = (yield $b => $c); +} +// TODO Get rid of parens for cases 2 and 3 +----- +function gen() +{ + yield; + (yield $a); + (yield $a => $b); + $a = yield; + $a = (yield $b); + $a = (yield $b => $c); +} +// TODO Get rid of parens for cases 2 and 3 +----- + $c; + yield from $a; + $a = yield from $b; +} +// TODO Get rid of parens for last case +----- +!!php7 +function gen() +{ + $a = (yield $b); + $a = (yield $b => $c); + yield from $a; + $a = (yield from $b); +} +// TODO Get rid of parens for last case \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/inlineHTMLandPHPtest.file-test b/lib/nikic/php-parser/test/code/prettyPrinter/inlineHTMLandPHPtest.file-test new file mode 100644 index 000000000..b33eb527d --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/inlineHTMLandPHPtest.file-test @@ -0,0 +1,58 @@ +File containing both inline HTML and PHP +----- +HTML + +HTML +----- + +HTML +----- +HTML + +HTML +----- +HTML + +HTML +----- +HTML + +HTML + +HTML +----- +HTML + +HTML + +HTML +----- +HTMLHTML +----- +HTMLHTML \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/onlyInlineHTML.file-test b/lib/nikic/php-parser/test/code/prettyPrinter/onlyInlineHTML.file-test new file mode 100644 index 000000000..e98071914 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/onlyInlineHTML.file-test @@ -0,0 +1,19 @@ +File containing only inline HTML +----- +Hallo World +Foo Bar +Bar Foo +World Hallo +----- +Hallo World +Foo Bar +Bar Foo +World Hallo +----- + + +Test +----- + + +Test \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/onlyPHP.file-test b/lib/nikic/php-parser/test/code/prettyPrinter/onlyPHP.file-test new file mode 100644 index 000000000..9550b107e --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/onlyPHP.file-test @@ -0,0 +1,16 @@ +File containing only PHP +----- +a = 'bar'; + echo 'test'; + } + + protected function baz() {} + public function foo() {} + abstract static function bar() {} +} + +trait Bar +{ + function test() + { + } +} +----- +class Foo extends Bar implements ABC, \DEF, namespace\GHI +{ + var $a = 'foo'; + private $b = 'bar'; + static $c = 'baz'; + function test() + { + $this->a = 'bar'; + echo 'test'; + } + protected function baz() + { + } + public function foo() + { + } + static abstract function bar() + { + } +} +trait Bar +{ + function test() + { + } +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/stmt/class_const.test b/lib/nikic/php-parser/test/code/prettyPrinter/stmt/class_const.test new file mode 100644 index 000000000..e73ad4304 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/stmt/class_const.test @@ -0,0 +1,20 @@ +Class constants +----- + $val) { + +} + +foreach ($arr as $key => &$val) { + +} +----- +foreach ($arr as $val) { +} +foreach ($arr as &$val) { +} +foreach ($arr as $key => $val) { +} +foreach ($arr as $key => &$val) { +} \ No newline at end of file diff --git a/lib/nikic/php-parser/test/code/prettyPrinter/stmt/function_signatures.test b/lib/nikic/php-parser/test/code/prettyPrinter/stmt/function_signatures.test new file mode 100644 index 000000000..af1088a05 --- /dev/null +++ b/lib/nikic/php-parser/test/code/prettyPrinter/stmt/function_signatures.test @@ -0,0 +1,43 @@ +Function signatures +----- +assertNull($e->getCause()); + } + + public function testGetCauseException() + { + $cause = new Exception('foo bar'); + $e = new PEAR_Exception('I caught an exception', $cause); + $this->assertNotNull($e->getCause()); + $this->assertInstanceOf('Exception', $e->getCause()); + $this->assertEquals($cause, $e->getCause()); + } + + public function testGetCauseMessage() + { + $cause = new Exception('foo bar'); + $e = new PEAR_Exception('I caught an exception', $cause); + + $e->getCauseMessage($causes); + $this->assertEquals('I caught an exception', $causes[0]['message']); + $this->assertEquals('foo bar', $causes[1]['message']); + } + + public function testGetTraceSafe() + { + $e = new PEAR_Exception('oops'); + $this->assertInternalType('array', $e->getTraceSafe()); + } + + public function testGetErrorClass() + { + $e = new PEAR_Exception('oops'); + $this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass()); + } + + public function testGetErrorMethod() + { + $e = new PEAR_Exception('oops'); + $this->assertEquals('testGetErrorMethod', $e->getErrorMethod()); + } + + public function test__toString() + { + $e = new PEAR_Exception('oops'); + $this->assertInternalType('string', (string) $e); + $this->assertContains('oops', (string) $e); + } + + public function testToHtml() + { + $e = new PEAR_Exception('oops'); + $html = $e->toHtml(); + $this->assertInternalType('string', $html); + $this->assertContains('oops', $html); + } +} +?> diff --git a/lib/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/lib/psr/log/Psr/Log/Test/LoggerInterfaceTest.php new file mode 100644 index 000000000..9ecb6c4b0 --- /dev/null +++ b/lib/psr/log/Psr/Log/Test/LoggerInterfaceTest.php @@ -0,0 +1,146 @@ + ". + * + * Example ->error('Foo') would yield "error Foo". + * + * @return string[] + */ + abstract public function getLogs(); + + public function testImplements() + { + $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); + } + + /** + * @dataProvider provideLevelsAndMessages + */ + public function testLogsAtAllLevels($level, $message) + { + $logger = $this->getLogger(); + $logger->{$level}($message, array('user' => 'Bob')); + $logger->log($level, $message, array('user' => 'Bob')); + + $expected = array( + $level.' message of level '.$level.' with context: Bob', + $level.' message of level '.$level.' with context: Bob', + ); + $this->assertEquals($expected, $this->getLogs()); + } + + public function provideLevelsAndMessages() + { + return array( + LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), + LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), + LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), + LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), + LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), + LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), + LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), + LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), + ); + } + + /** + * @expectedException \Psr\Log\InvalidArgumentException + */ + public function testThrowsOnInvalidLevel() + { + $logger = $this->getLogger(); + $logger->log('invalid level', 'Foo'); + } + + public function testContextReplacement() + { + $logger = $this->getLogger(); + $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + + $expected = array('info {Message {nothing} Bob Bar a}'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testObjectCastToString() + { + if (method_exists($this, 'createPartialMock')) { + $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString')); + } else { + $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); + } + $dummy->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('DUMMY')); + + $this->getLogger()->warning($dummy); + + $expected = array('warning DUMMY'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testContextCanContainAnything() + { + $closed = fopen('php://memory', 'r'); + fclose($closed); + + $context = array( + 'bool' => true, + 'null' => null, + 'string' => 'Foo', + 'int' => 0, + 'float' => 0.5, + 'nested' => array('with object' => new DummyTest), + 'object' => new \DateTime, + 'resource' => fopen('php://memory', 'r'), + 'closed' => $closed, + ); + + $this->getLogger()->warning('Crazy context data', $context); + + $expected = array('warning Crazy context data'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testContextExceptionKeyCanBeExceptionOrOtherValues() + { + $logger = $this->getLogger(); + $logger->warning('Random message', array('exception' => 'oops')); + $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); + + $expected = array( + 'warning Random message', + 'critical Uncaught Exception!' + ); + $this->assertEquals($expected, $this->getLogs()); + } +} + +class DummyTest +{ + public function __toString() + { + return 'DummyTest'; + } +} diff --git a/lib/psr/log/Psr/Log/Test/TestLogger.php b/lib/psr/log/Psr/Log/Test/TestLogger.php new file mode 100644 index 000000000..1be323049 --- /dev/null +++ b/lib/psr/log/Psr/Log/Test/TestLogger.php @@ -0,0 +1,147 @@ + $level, + 'message' => $message, + 'context' => $context, + ]; + + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } + + public function hasRecords($level) + { + return isset($this->recordsByLevel[$level]); + } + + public function hasRecord($record, $level) + { + if (is_string($record)) { + $record = ['message' => $record]; + } + return $this->hasRecordThatPasses(function ($rec) use ($record) { + if ($rec['message'] !== $record['message']) { + return false; + } + if (isset($record['context']) && $rec['context'] !== $record['context']) { + return false; + } + return true; + }, $level); + } + + public function hasRecordThatContains($message, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($message) { + return strpos($rec['message'], $message) !== false; + }, $level); + } + + public function hasRecordThatMatches($regex, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($regex) { + return preg_match($regex, $rec['message']) > 0; + }, $level); + } + + public function hasRecordThatPasses(callable $predicate, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + foreach ($this->recordsByLevel[$level] as $i => $rec) { + if (call_user_func($predicate, $rec, $i)) { + return true; + } + } + return false; + } + + public function __call($method, $args) + { + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { + $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; + $level = strtolower($matches[2]); + if (method_exists($this, $genericMethod)) { + $args[] = $level; + return call_user_func_array([$this, $genericMethod], $args); + } + } + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); + } + + public function reset() + { + $this->records = []; + $this->recordsByLevel = []; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/AbstractRedisAdapterTest.php b/lib/symfony/cache/Tests/Adapter/AbstractRedisAdapterTest.php new file mode 100644 index 000000000..d1fa9535c --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/AbstractRedisAdapterTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\RedisAdapter; + +abstract class AbstractRedisAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testExpiration' => 'Testing expiration slows down the test suite', + 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + protected static $redis; + + public function createCachePool($defaultLifetime = 0) + { + return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + } + + public static function setUpBeforeClass() + { + if (!\extension_loaded('redis')) { + self::markTestSkipped('Extension redis required.'); + } + if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { + $e = error_get_last(); + self::markTestSkipped($e['message']); + } + } + + public static function tearDownAfterClass() + { + self::$redis = null; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/AdapterTestCase.php b/lib/symfony/cache/Tests/Adapter/AdapterTestCase.php new file mode 100644 index 000000000..5758a2861 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/AdapterTestCase.php @@ -0,0 +1,175 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Cache\IntegrationTests\CachePoolTest; +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\PruneableInterface; + +abstract class AdapterTestCase extends CachePoolTest +{ + protected function setUp() + { + parent::setUp(); + + if (!\array_key_exists('testDeferredSaveWithoutCommit', $this->skippedTests) && \defined('HHVM_VERSION')) { + $this->skippedTests['testDeferredSaveWithoutCommit'] = 'Destructors are called late on HHVM.'; + } + + if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) { + $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; + } + } + + public function testDefaultLifeTime() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(2); + + $item = $cache->getItem('key.dlt'); + $item->set('value'); + $cache->save($item); + sleep(1); + + $item = $cache->getItem('key.dlt'); + $this->assertTrue($item->isHit()); + + sleep(2); + $item = $cache->getItem('key.dlt'); + $this->assertFalse($item->isHit()); + } + + public function testExpiration() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(); + $cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2)); + $cache->save($cache->getItem('k2')->set('v2')->expiresAfter(366 * 86400)); + + sleep(3); + $item = $cache->getItem('k1'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get(), "Item's value must be null when isHit() is false."); + + $item = $cache->getItem('k2'); + $this->assertTrue($item->isHit()); + $this->assertSame('v2', $item->get()); + } + + public function testNotUnserializable() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(); + + $item = $cache->getItem('foo'); + $cache->save($item->set(new NotUnserializable())); + + $item = $cache->getItem('foo'); + $this->assertFalse($item->isHit()); + + foreach ($cache->getItems(['foo']) as $item) { + } + $cache->save($item->set(new NotUnserializable())); + + foreach ($cache->getItems(['foo']) as $item) { + } + $this->assertFalse($item->isHit()); + } + + public function testPrune() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + if (!method_exists($this, 'isPruned')) { + $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); + } + + /** @var PruneableInterface|CacheItemPoolInterface $cache */ + $cache = $this->createCachePool(); + + $doSet = function ($name, $value, \DateInterval $expiresAfter = null) use ($cache) { + $item = $cache->getItem($name); + $item->set($value); + + if ($expiresAfter) { + $item->expiresAfter($expiresAfter); + } + + $cache->save($item); + }; + + $doSet('foo', 'foo-val', new \DateInterval('PT05S')); + $doSet('bar', 'bar-val', new \DateInterval('PT10S')); + $doSet('baz', 'baz-val', new \DateInterval('PT15S')); + $doSet('qux', 'qux-val', new \DateInterval('PT20S')); + + sleep(30); + $cache->prune(); + $this->assertTrue($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'bar')); + $this->assertTrue($this->isPruned($cache, 'baz')); + $this->assertTrue($this->isPruned($cache, 'qux')); + + $doSet('foo', 'foo-val'); + $doSet('bar', 'bar-val', new \DateInterval('PT20S')); + $doSet('baz', 'baz-val', new \DateInterval('PT40S')); + $doSet('qux', 'qux-val', new \DateInterval('PT80S')); + + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertFalse($this->isPruned($cache, 'bar')); + $this->assertFalse($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'bar')); + $this->assertFalse($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'qux')); + } +} + +class NotUnserializable implements \Serializable +{ + public function serialize() + { + return serialize(123); + } + + public function unserialize($ser) + { + throw new \Exception(__CLASS__); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/ApcuAdapterTest.php b/lib/symfony/cache/Tests/Adapter/ApcuAdapterTest.php new file mode 100644 index 000000000..5cca73f56 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/ApcuAdapterTest.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Log\NullLogger; +use Symfony\Component\Cache\Adapter\ApcuAdapter; + +class ApcuAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testExpiration' => 'Testing expiration slows down the test suite', + 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + public function createCachePool($defaultLifetime = 0) + { + if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) { + $this->markTestSkipped('APCu extension is required.'); + } + if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + if ('testWithCliSapi' !== $this->getName()) { + $this->markTestSkipped('apc.enable_cli=1 is required.'); + } + } + if ('\\' === \DIRECTORY_SEPARATOR) { + $this->markTestSkipped('Fails transiently on Windows.'); + } + + return new ApcuAdapter(str_replace('\\', '.', __CLASS__), $defaultLifetime); + } + + public function testUnserializable() + { + $pool = $this->createCachePool(); + + $item = $pool->getItem('foo'); + $item->set(function () {}); + + $this->assertFalse($pool->save($item)); + + $item = $pool->getItem('foo'); + $this->assertFalse($item->isHit()); + } + + public function testVersion() + { + $namespace = str_replace('\\', '.', \get_class($this)); + + $pool1 = new ApcuAdapter($namespace, 0, 'p1'); + + $item = $pool1->getItem('foo'); + $this->assertFalse($item->isHit()); + $this->assertTrue($pool1->save($item->set('bar'))); + + $item = $pool1->getItem('foo'); + $this->assertTrue($item->isHit()); + $this->assertSame('bar', $item->get()); + + $pool2 = new ApcuAdapter($namespace, 0, 'p2'); + + $item = $pool2->getItem('foo'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get()); + + $item = $pool1->getItem('foo'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get()); + } + + public function testNamespace() + { + $namespace = str_replace('\\', '.', \get_class($this)); + + $pool1 = new ApcuAdapter($namespace.'_1', 0, 'p1'); + + $item = $pool1->getItem('foo'); + $this->assertFalse($item->isHit()); + $this->assertTrue($pool1->save($item->set('bar'))); + + $item = $pool1->getItem('foo'); + $this->assertTrue($item->isHit()); + $this->assertSame('bar', $item->get()); + + $pool2 = new ApcuAdapter($namespace.'_2', 0, 'p1'); + + $item = $pool2->getItem('foo'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get()); + + $item = $pool1->getItem('foo'); + $this->assertTrue($item->isHit()); + $this->assertSame('bar', $item->get()); + } + + public function testWithCliSapi() + { + try { + // disable PHPUnit error handler to mimic a production environment + $isCalled = false; + set_error_handler(function () use (&$isCalled) { + $isCalled = true; + }); + $pool = new ApcuAdapter(str_replace('\\', '.', __CLASS__)); + $pool->setLogger(new NullLogger()); + + $item = $pool->getItem('foo'); + $item->isHit(); + $pool->save($item->set('bar')); + $this->assertFalse($isCalled); + } finally { + restore_error_handler(); + } + } +} diff --git a/lib/symfony/cache/Tests/Adapter/ArrayAdapterTest.php b/lib/symfony/cache/Tests/Adapter/ArrayAdapterTest.php new file mode 100644 index 000000000..e6adc9d01 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/ArrayAdapterTest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\ArrayAdapter; + +/** + * @group time-sensitive + */ +class ArrayAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', + 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', + ]; + + public function createCachePool($defaultLifetime = 0) + { + return new ArrayAdapter($defaultLifetime); + } + + public function testGetValuesHitAndMiss() + { + /** @var ArrayAdapter $cache */ + $cache = $this->createCachePool(); + + // Hit + $item = $cache->getItem('foo'); + $item->set('4711'); + $cache->save($item); + + $fooItem = $cache->getItem('foo'); + $this->assertTrue($fooItem->isHit()); + $this->assertEquals('4711', $fooItem->get()); + + // Miss (should be present as NULL in $values) + $cache->getItem('bar'); + + $values = $cache->getValues(); + + $this->assertCount(2, $values); + $this->assertArrayHasKey('foo', $values); + $this->assertSame(serialize('4711'), $values['foo']); + $this->assertArrayHasKey('bar', $values); + $this->assertNull($values['bar']); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/ChainAdapterTest.php b/lib/symfony/cache/Tests/Adapter/ChainAdapterTest.php new file mode 100644 index 000000000..5e48930dd --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/ChainAdapterTest.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\Cache\Adapter\AdapterInterface; +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\ChainAdapter; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\PruneableInterface; +use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; + +/** + * @author Kévin Dunglas + * @group time-sensitive + */ +class ChainAdapterTest extends AdapterTestCase +{ + public function createCachePool($defaultLifetime = 0) + { + return new ChainAdapter([new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime); + } + + public function testEmptyAdaptersException() + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('At least one adapter must be specified.'); + new ChainAdapter([]); + } + + public function testInvalidAdapterException() + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('The class "stdClass" does not implement'); + new ChainAdapter([new \stdClass()]); + } + + public function testPrune() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = new ChainAdapter([ + $this->getPruneableMock(), + $this->getNonPruneableMock(), + $this->getPruneableMock(), + ]); + $this->assertTrue($cache->prune()); + + $cache = new ChainAdapter([ + $this->getPruneableMock(), + $this->getFailingPruneableMock(), + $this->getPruneableMock(), + ]); + $this->assertFalse($cache->prune()); + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(true); + + return $pruneable; + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getFailingPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(false); + + return $pruneable; + } + + /** + * @return MockObject|AdapterInterface + */ + private function getNonPruneableMock() + { + return $this + ->getMockBuilder(AdapterInterface::class) + ->getMock(); + } +} + +interface PruneableCacheInterface extends PruneableInterface, AdapterInterface +{ +} diff --git a/lib/symfony/cache/Tests/Adapter/DoctrineAdapterTest.php b/lib/symfony/cache/Tests/Adapter/DoctrineAdapterTest.php new file mode 100644 index 000000000..8f520cb59 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/DoctrineAdapterTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\DoctrineAdapter; +use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; + +/** + * @group time-sensitive + */ +class DoctrineAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.', + 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.', + 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', + ]; + + public function createCachePool($defaultLifetime = 0) + { + return new DoctrineAdapter(new ArrayCache($defaultLifetime), '', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/FilesystemAdapterTest.php b/lib/symfony/cache/Tests/Adapter/FilesystemAdapterTest.php new file mode 100644 index 000000000..fa8306826 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/FilesystemAdapterTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; + +/** + * @group time-sensitive + */ +class FilesystemAdapterTest extends AdapterTestCase +{ + public function createCachePool($defaultLifetime = 0) + { + return new FilesystemAdapter('', $defaultLifetime); + } + + public static function tearDownAfterClass() + { + self::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + + public static function rmdir($dir) + { + if (!file_exists($dir)) { + return; + } + if (!$dir || 0 !== strpos(\dirname($dir), sys_get_temp_dir())) { + throw new \Exception(__METHOD__."() operates only on subdirs of system's temp dir"); + } + $children = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::CHILD_FIRST + ); + foreach ($children as $child) { + if ($child->isDir()) { + rmdir($child); + } else { + unlink($child); + } + } + rmdir($dir); + } + + protected function isPruned(CacheItemPoolInterface $cache, $name) + { + $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); + $getFileMethod->setAccessible(true); + + return !file_exists($getFileMethod->invoke($cache, $name)); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/lib/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php new file mode 100644 index 000000000..536e2c2d4 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Adapter\AbstractAdapter; + +class MaxIdLengthAdapterTest extends TestCase +{ + public function testLongKey() + { + $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) + ->setConstructorArgs([str_repeat('-', 10)]) + ->setMethods(['doHave', 'doFetch', 'doDelete', 'doSave', 'doClear']) + ->getMock(); + + $cache->expects($this->exactly(2)) + ->method('doHave') + ->withConsecutive( + [$this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')], + [$this->equalTo('----------:---------------------------------------')] + ); + + $cache->hasItem(str_repeat('-', 40)); + $cache->hasItem(str_repeat('-', 39)); + } + + public function testLongKeyVersioning() + { + $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) + ->setConstructorArgs([str_repeat('-', 26)]) + ->getMock(); + + $cache + ->method('doFetch') + ->willReturn(['2:']); + + $reflectionClass = new \ReflectionClass(AbstractAdapter::class); + + $reflectionMethod = $reflectionClass->getMethod('getId'); + $reflectionMethod->setAccessible(true); + + // No versioning enabled + $this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); + + $reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($cache, true); + + // Versioning enabled + $this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); + } + + public function testTooLongNamespace() + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")'); + $this->getMockBuilder(MaxIdLengthAdapter::class) + ->setConstructorArgs([str_repeat('-', 40)]) + ->getMock(); + } +} + +abstract class MaxIdLengthAdapter extends AbstractAdapter +{ + protected $maxIdLength = 50; + + public function __construct($ns) + { + parent::__construct($ns); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php b/lib/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php new file mode 100644 index 000000000..3a996079a --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php @@ -0,0 +1,198 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Adapter\MemcachedAdapter; + +class MemcachedAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + protected static $client; + + public static function setUpBeforeClass() + { + if (!MemcachedAdapter::isSupported()) { + self::markTestSkipped('Extension memcached >=2.2.0 required.'); + } + self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); + self::$client->get('foo'); + $code = self::$client->getResultCode(); + + if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { + self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); + } + } + + public function createCachePool($defaultLifetime = 0) + { + $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client; + + return new MemcachedAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); + } + + public function testOptions() + { + $client = MemcachedAdapter::createConnection([], [ + 'libketama_compatible' => false, + 'distribution' => 'modula', + 'compression' => true, + 'serializer' => 'php', + 'hash' => 'md5', + ]); + + $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); + $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); + $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); + $this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); + $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); + } + + /** + * @dataProvider provideBadOptions + */ + public function testBadOptions($name, $value) + { + $this->expectException('ErrorException'); + $this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::'); + MemcachedAdapter::createConnection([], [$name => $value]); + } + + public function provideBadOptions() + { + return [ + ['foo', 'bar'], + ['hash', 'zyx'], + ['serializer', 'zyx'], + ['distribution', 'zyx'], + ]; + } + + public function testDefaultOptions() + { + $this->assertTrue(MemcachedAdapter::isSupported()); + + $client = MemcachedAdapter::createConnection([]); + + $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); + $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); + $this->assertSame(1, $client->getOption(\Memcached::OPT_TCP_NODELAY)); + $this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); + } + + public function testOptionSerializer() + { + $this->expectException('Symfony\Component\Cache\Exception\CacheException'); + $this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); + if (!\Memcached::HAVE_JSON) { + $this->markTestSkipped('Memcached::HAVE_JSON required'); + } + + new MemcachedAdapter(MemcachedAdapter::createConnection([], ['serializer' => 'json'])); + } + + /** + * @dataProvider provideServersSetting + */ + public function testServersSetting($dsn, $host, $port) + { + $client1 = MemcachedAdapter::createConnection($dsn); + $client2 = MemcachedAdapter::createConnection([$dsn]); + $client3 = MemcachedAdapter::createConnection([[$host, $port]]); + $expect = [ + 'host' => $host, + 'port' => $port, + ]; + + $f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; }; + $this->assertSame([$expect], array_map($f, $client1->getServerList())); + $this->assertSame([$expect], array_map($f, $client2->getServerList())); + $this->assertSame([$expect], array_map($f, $client3->getServerList())); + } + + public function provideServersSetting() + { + yield [ + 'memcached://127.0.0.1/50', + '127.0.0.1', + 11211, + ]; + yield [ + 'memcached://localhost:11222?weight=25', + 'localhost', + 11222, + ]; + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + yield [ + 'memcached://user:password@127.0.0.1?weight=50', + '127.0.0.1', + 11211, + ]; + } + yield [ + 'memcached:///var/run/memcached.sock?weight=25', + '/var/run/memcached.sock', + 0, + ]; + yield [ + 'memcached:///var/local/run/memcached.socket?weight=25', + '/var/local/run/memcached.socket', + 0, + ]; + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + yield [ + 'memcached://user:password@/var/local/run/memcached.socket?weight=25', + '/var/local/run/memcached.socket', + 0, + ]; + } + } + + /** + * @dataProvider provideDsnWithOptions + */ + public function testDsnWithOptions($dsn, array $options, array $expectedOptions) + { + $client = MemcachedAdapter::createConnection($dsn, $options); + + foreach ($expectedOptions as $option => $expect) { + $this->assertSame($expect, $client->getOption($option)); + } + } + + public function provideDsnWithOptions() + { + if (!class_exists('\Memcached')) { + self::markTestSkipped('Extension memcached required.'); + } + + yield [ + 'memcached://localhost:11222?retry_timeout=10', + [\Memcached::OPT_RETRY_TIMEOUT => 8], + [\Memcached::OPT_RETRY_TIMEOUT => 10], + ]; + yield [ + 'memcached://localhost:11222?socket_recv_size=1&socket_send_size=2', + [\Memcached::OPT_RETRY_TIMEOUT => 8], + [\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8], + ]; + } + + public function testClear() + { + $this->assertTrue($this->createCachePool()->clear()); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php b/lib/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php new file mode 100644 index 000000000..c27140333 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\ProxyAdapter; + +/** + * @group time-sensitive + */ +class NamespacedProxyAdapterTest extends ProxyAdapterTest +{ + public function createCachePool($defaultLifetime = 0) + { + return new ProxyAdapter(new ArrayAdapter($defaultLifetime), 'foo', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/NullAdapterTest.php b/lib/symfony/cache/Tests/Adapter/NullAdapterTest.php new file mode 100644 index 000000000..b771fa0ed --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/NullAdapterTest.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use PHPUnit\Framework\TestCase; +use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\NullAdapter; + +/** + * @group time-sensitive + */ +class NullAdapterTest extends TestCase +{ + public function createCachePool() + { + return new NullAdapter(); + } + + public function testGetItem() + { + $adapter = $this->createCachePool(); + + $item = $adapter->getItem('key'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get(), "Item's value must be null when isHit is false."); + } + + public function testHasItem() + { + $this->assertFalse($this->createCachePool()->hasItem('key')); + } + + public function testGetItems() + { + $adapter = $this->createCachePool(); + + $keys = ['foo', 'bar', 'baz', 'biz']; + + /** @var CacheItemInterface[] $items */ + $items = $adapter->getItems($keys); + $count = 0; + + foreach ($items as $key => $item) { + $itemKey = $item->getKey(); + + $this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items'); + $this->assertContains($key, $keys, 'Cache key can not change.'); + $this->assertFalse($item->isHit()); + + // Remove $key for $keys + foreach ($keys as $k => $v) { + if ($v === $key) { + unset($keys[$k]); + } + } + + ++$count; + } + + $this->assertSame(4, $count); + } + + public function testIsHit() + { + $adapter = $this->createCachePool(); + + $item = $adapter->getItem('key'); + $this->assertFalse($item->isHit()); + } + + public function testClear() + { + $this->assertTrue($this->createCachePool()->clear()); + } + + public function testDeleteItem() + { + $this->assertTrue($this->createCachePool()->deleteItem('key')); + } + + public function testDeleteItems() + { + $this->assertTrue($this->createCachePool()->deleteItems(['key', 'foo', 'bar'])); + } + + public function testSave() + { + $adapter = $this->createCachePool(); + + $item = $adapter->getItem('key'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get(), "Item's value must be null when isHit is false."); + + $this->assertFalse($adapter->save($item)); + } + + public function testDeferredSave() + { + $adapter = $this->createCachePool(); + + $item = $adapter->getItem('key'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get(), "Item's value must be null when isHit is false."); + + $this->assertFalse($adapter->saveDeferred($item)); + } + + public function testCommit() + { + $adapter = $this->createCachePool(); + + $item = $adapter->getItem('key'); + $this->assertFalse($item->isHit()); + $this->assertNull($item->get(), "Item's value must be null when isHit is false."); + + $this->assertFalse($adapter->saveDeferred($item)); + $this->assertFalse($this->createCachePool()->commit()); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PdoAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PdoAdapterTest.php new file mode 100644 index 000000000..dd2a91185 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PdoAdapterTest.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\PdoAdapter; +use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; + +/** + * @group time-sensitive + */ +class PdoAdapterTest extends AdapterTestCase +{ + use PdoPruneableTrait; + + protected static $dbFile; + + public static function setUpBeforeClass() + { + if (!\extension_loaded('pdo_sqlite')) { + self::markTestSkipped('Extension pdo_sqlite required.'); + } + + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); + + $pool = new PdoAdapter('sqlite:'.self::$dbFile); + $pool->createTable(); + } + + public static function tearDownAfterClass() + { + @unlink(self::$dbFile); + } + + public function createCachePool($defaultLifetime = 0) + { + return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); + } + + public function testCleanupExpiredItems() + { + $pdo = new \PDO('sqlite:'.self::$dbFile); + + $getCacheItemCount = function () use ($pdo) { + return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN); + }; + + $this->assertSame(0, $getCacheItemCount()); + + $cache = $this->createCachePool(); + + $item = $cache->getItem('some_nice_key'); + $item->expiresAfter(1); + $item->set(1); + + $cache->save($item); + $this->assertSame(1, $getCacheItemCount()); + + sleep(2); + + $newItem = $cache->getItem($item->getKey()); + $this->assertFalse($newItem->isHit()); + $this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items'); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php new file mode 100644 index 000000000..aa53958cf --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Doctrine\DBAL\DriverManager; +use Symfony\Component\Cache\Adapter\PdoAdapter; +use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; + +/** + * @group time-sensitive + */ +class PdoDbalAdapterTest extends AdapterTestCase +{ + use PdoPruneableTrait; + + protected static $dbFile; + + public static function setUpBeforeClass() + { + if (!\extension_loaded('pdo_sqlite')) { + self::markTestSkipped('Extension pdo_sqlite required.'); + } + + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); + + $pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); + $pool->createTable(); + } + + public static function tearDownAfterClass() + { + @unlink(self::$dbFile); + } + + public function createCachePool($defaultLifetime = 0) + { + return new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php new file mode 100644 index 000000000..751f758cc --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\NullAdapter; +use Symfony\Component\Cache\Adapter\PhpArrayAdapter; + +/** + * @group time-sensitive + */ +class PhpArrayAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testBasicUsage' => 'PhpArrayAdapter is read-only.', + 'testBasicUsageWithLongKey' => 'PhpArrayAdapter is read-only.', + 'testClear' => 'PhpArrayAdapter is read-only.', + 'testClearWithDeferredItems' => 'PhpArrayAdapter is read-only.', + 'testDeleteItem' => 'PhpArrayAdapter is read-only.', + 'testSaveExpired' => 'PhpArrayAdapter is read-only.', + 'testSaveWithoutExpire' => 'PhpArrayAdapter is read-only.', + 'testDeferredSave' => 'PhpArrayAdapter is read-only.', + 'testDeferredSaveWithoutCommit' => 'PhpArrayAdapter is read-only.', + 'testDeleteItems' => 'PhpArrayAdapter is read-only.', + 'testDeleteDeferredItem' => 'PhpArrayAdapter is read-only.', + 'testCommit' => 'PhpArrayAdapter is read-only.', + 'testSaveDeferredWhenChangingValues' => 'PhpArrayAdapter is read-only.', + 'testSaveDeferredOverwrite' => 'PhpArrayAdapter is read-only.', + 'testIsHitDeferred' => 'PhpArrayAdapter is read-only.', + + 'testExpiresAt' => 'PhpArrayAdapter does not support expiration.', + 'testExpiresAtWithNull' => 'PhpArrayAdapter does not support expiration.', + 'testExpiresAfterWithNull' => 'PhpArrayAdapter does not support expiration.', + 'testDeferredExpired' => 'PhpArrayAdapter does not support expiration.', + 'testExpiration' => 'PhpArrayAdapter does not support expiration.', + + 'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + + 'testDefaultLifeTime' => 'PhpArrayAdapter does not allow configuring a default lifetime.', + 'testPrune' => 'PhpArrayAdapter just proxies', + ]; + + protected static $file; + + public static function setUpBeforeClass() + { + self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; + } + + protected function tearDown() + { + if (file_exists(sys_get_temp_dir().'/symfony-cache')) { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + } + + public function createCachePool() + { + return new PhpArrayAdapterWrapper(self::$file, new NullAdapter()); + } + + public function testStore() + { + $arrayWithRefs = []; + $arrayWithRefs[0] = 123; + $arrayWithRefs[1] = &$arrayWithRefs[0]; + + $object = (object) [ + 'foo' => 'bar', + 'foo2' => 'bar2', + ]; + + $expected = [ + 'null' => null, + 'serializedString' => serialize($object), + 'arrayWithRefs' => $arrayWithRefs, + 'object' => $object, + 'arrayWithObject' => ['bar' => $object], + ]; + + $adapter = $this->createCachePool(); + $adapter->warmUp($expected); + + foreach ($expected as $key => $value) { + $this->assertSame(serialize($value), serialize($adapter->getItem($key)->get()), 'Warm up should create a PHP file that OPCache can load in memory'); + } + } + + public function testStoredFile() + { + $expected = [ + 'integer' => 42, + 'float' => 42.42, + 'boolean' => true, + 'array_simple' => ['foo', 'bar'], + 'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'], + ]; + + $adapter = $this->createCachePool(); + $adapter->warmUp($expected); + + $values = eval(substr(file_get_contents(self::$file), 6)); + + $this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory'); + } +} + +class PhpArrayAdapterWrapper extends PhpArrayAdapter +{ + public function save(CacheItemInterface $item) + { + \call_user_func(\Closure::bind(function () use ($item) { + $this->values[$item->getKey()] = $item->get(); + $this->warmUp($this->values); + $this->values = eval(substr(file_get_contents($this->file), 6)); + }, $this, PhpArrayAdapter::class)); + + return true; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php b/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php new file mode 100644 index 000000000..4bdd7580f --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\PhpArrayAdapter; + +/** + * @group time-sensitive + */ +class PhpArrayAdapterWithFallbackTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', + 'testPrune' => 'PhpArrayAdapter just proxies', + ]; + + protected static $file; + + public static function setUpBeforeClass() + { + self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; + } + + protected function tearDown() + { + if (file_exists(sys_get_temp_dir().'/symfony-cache')) { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + } + + public function createCachePool($defaultLifetime = 0) + { + return new PhpArrayAdapter(self::$file, new FilesystemAdapter('php-array-fallback', $defaultLifetime)); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php new file mode 100644 index 000000000..247160d53 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\PhpFilesAdapter; + +/** + * @group time-sensitive + */ +class PhpFilesAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.', + ]; + + public function createCachePool() + { + if (!PhpFilesAdapter::isSupported()) { + $this->markTestSkipped('OPcache extension is not enabled.'); + } + + return new PhpFilesAdapter('sf-cache'); + } + + public static function tearDownAfterClass() + { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + + protected function isPruned(CacheItemPoolInterface $cache, $name) + { + $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); + $getFileMethod->setAccessible(true); + + return !file_exists($getFileMethod->invoke($cache, $name)); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PredisAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PredisAdapterTest.php new file mode 100644 index 000000000..6aadbf266 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PredisAdapterTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Predis\Connection\StreamConnection; +use Symfony\Component\Cache\Adapter\RedisAdapter; + +class PredisAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + self::$redis = new \Predis\Client(['host' => getenv('REDIS_HOST')]); + } + + public function testCreateConnection() + { + $redisHost = getenv('REDIS_HOST'); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', ['class' => \Predis\Client::class, 'timeout' => 3]); + $this->assertInstanceOf(\Predis\Client::class, $redis); + + $connection = $redis->getConnection(); + $this->assertInstanceOf(StreamConnection::class, $connection); + + $params = [ + 'scheme' => 'tcp', + 'host' => $redisHost, + 'path' => '', + 'dbindex' => '1', + 'port' => 6379, + 'class' => 'Predis\Client', + 'timeout' => 3, + 'persistent' => 0, + 'persistent_id' => null, + 'read_timeout' => 0, + 'retry_interval' => 0, + 'lazy' => false, + 'database' => '1', + 'password' => null, + ]; + $this->assertSame($params, $connection->getParameters()->toArray()); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PredisClusterAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PredisClusterAdapterTest.php new file mode 100644 index 000000000..1afabaf1d --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PredisClusterAdapterTest.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +class PredisClusterAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + self::$redis = new \Predis\Client([['host' => getenv('REDIS_HOST')]]); + } + + public static function tearDownAfterClass() + { + self::$redis = null; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php b/lib/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php new file mode 100644 index 000000000..5b09919e2 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { + self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + } + self::$redis = new \Predis\Client(explode(' ', $hosts), ['cluster' => 'redis']); + } + + public static function tearDownAfterClass() + { + self::$redis = null; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/ProxyAdapterTest.php b/lib/symfony/cache/Tests/Adapter/ProxyAdapterTest.php new file mode 100644 index 000000000..810cb31a2 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/ProxyAdapterTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\ProxyAdapter; +use Symfony\Component\Cache\CacheItem; + +/** + * @group time-sensitive + */ +class ProxyAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', + 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', + 'testPrune' => 'ProxyAdapter just proxies', + ]; + + public function createCachePool($defaultLifetime = 0) + { + return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime); + } + + public function testProxyfiedItem() + { + $this->expectException('Exception'); + $this->expectExceptionMessage('OK bar'); + $item = new CacheItem(); + $pool = new ProxyAdapter(new TestingArrayAdapter($item)); + + $proxyItem = $pool->getItem('foo'); + + $this->assertNotSame($item, $proxyItem); + $pool->save($proxyItem->set('bar')); + } +} + +class TestingArrayAdapter extends ArrayAdapter +{ + private $item; + + public function __construct(CacheItemInterface $item) + { + $this->item = $item; + } + + public function getItem($key) + { + return $this->item; + } + + public function save(CacheItemInterface $item) + { + if ($item === $this->item) { + throw new \Exception('OK '.$item->get()); + } + } +} diff --git a/lib/symfony/cache/Tests/Adapter/RedisAdapterTest.php b/lib/symfony/cache/Tests/Adapter/RedisAdapterTest.php new file mode 100644 index 000000000..edc6a9934 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/RedisAdapterTest.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Adapter\RedisAdapter; +use Symfony\Component\Cache\Traits\RedisProxy; + +class RedisAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true]); + } + + public function createCachePool($defaultLifetime = 0) + { + $adapter = parent::createCachePool($defaultLifetime); + $this->assertInstanceOf(RedisProxy::class, self::$redis); + + return $adapter; + } + + public function testCreateConnection() + { + $redisHost = getenv('REDIS_HOST'); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost); + $this->assertInstanceOf(\Redis::class, $redis); + $this->assertTrue($redis->isConnected()); + $this->assertSame(0, $redis->getDbNum()); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2'); + $this->assertSame(2, $redis->getDbNum()); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost, ['timeout' => 3]); + $this->assertEquals(3, $redis->getTimeout()); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4'); + $this->assertEquals(4, $redis->getTimeout()); + + $redis = RedisAdapter::createConnection('redis://'.$redisHost, ['read_timeout' => 5]); + $this->assertEquals(5, $redis->getReadTimeout()); + } + + /** + * @dataProvider provideFailedCreateConnection + */ + public function testFailedCreateConnection($dsn) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Redis connection failed'); + RedisAdapter::createConnection($dsn); + } + + public function provideFailedCreateConnection() + { + return [ + ['redis://localhost:1234'], + ['redis://foo@localhost'], + ['redis://localhost/123'], + ]; + } + + /** + * @dataProvider provideInvalidCreateConnection + */ + public function testInvalidCreateConnection($dsn) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Invalid Redis DSN'); + RedisAdapter::createConnection($dsn); + } + + public function provideInvalidCreateConnection() + { + return [ + ['foo://localhost'], + ['redis://'], + ]; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/RedisArrayAdapterTest.php b/lib/symfony/cache/Tests/Adapter/RedisArrayAdapterTest.php new file mode 100644 index 000000000..bd9def326 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +class RedisArrayAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + parent::setupBeforeClass(); + if (!class_exists('RedisArray')) { + self::markTestSkipped('The RedisArray class is required.'); + } + self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php b/lib/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php new file mode 100644 index 000000000..9c339d2dd --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +class RedisClusterAdapterTest extends AbstractRedisAdapterTest +{ + public static function setUpBeforeClass() + { + if (!class_exists('RedisCluster')) { + self::markTestSkipped('The RedisCluster class is required.'); + } + if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { + self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + } + + self::$redis = new \RedisCluster(null, explode(' ', $hosts)); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/SimpleCacheAdapterTest.php b/lib/symfony/cache/Tests/Adapter/SimpleCacheAdapterTest.php new file mode 100644 index 000000000..d8470a2e7 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/SimpleCacheAdapterTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\SimpleCacheAdapter; +use Symfony\Component\Cache\Simple\ArrayCache; +use Symfony\Component\Cache\Simple\FilesystemCache; + +/** + * @group time-sensitive + */ +class SimpleCacheAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testPrune' => 'SimpleCache just proxies', + ]; + + public function createCachePool($defaultLifetime = 0) + { + return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime); + } + + public function testValidCacheKeyWithNamespace() + { + $cache = new SimpleCacheAdapter(new ArrayCache(), 'some_namespace', 0); + $item = $cache->getItem('my_key'); + $item->set('someValue'); + $cache->save($item); + + $this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.'); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php b/lib/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php new file mode 100644 index 000000000..0108b9250 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php @@ -0,0 +1,318 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\AdapterInterface; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\TagAwareAdapter; + +/** + * @group time-sensitive + */ +class TagAwareAdapterTest extends AdapterTestCase +{ + public function createCachePool($defaultLifetime = 0) + { + return new TagAwareAdapter(new FilesystemAdapter('', $defaultLifetime)); + } + + public static function tearDownAfterClass() + { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + + public function testInvalidTag() + { + $this->expectException('Psr\Cache\InvalidArgumentException'); + $pool = $this->createCachePool(); + $item = $pool->getItem('foo'); + $item->tag(':'); + } + + public function testInvalidateTags() + { + $pool = $this->createCachePool(); + + $i0 = $pool->getItem('i0'); + $i1 = $pool->getItem('i1'); + $i2 = $pool->getItem('i2'); + $i3 = $pool->getItem('i3'); + $foo = $pool->getItem('foo'); + + $pool->save($i0->tag('bar')); + $pool->save($i1->tag('foo')); + $pool->save($i2->tag('foo')->tag('bar')); + $pool->save($i3->tag('foo')->tag('baz')); + $pool->save($foo); + + $pool->invalidateTags(['bar']); + + $this->assertFalse($pool->getItem('i0')->isHit()); + $this->assertTrue($pool->getItem('i1')->isHit()); + $this->assertFalse($pool->getItem('i2')->isHit()); + $this->assertTrue($pool->getItem('i3')->isHit()); + $this->assertTrue($pool->getItem('foo')->isHit()); + + $pool->invalidateTags(['foo']); + + $this->assertFalse($pool->getItem('i1')->isHit()); + $this->assertFalse($pool->getItem('i3')->isHit()); + $this->assertTrue($pool->getItem('foo')->isHit()); + + $anotherPoolInstance = $this->createCachePool(); + + $this->assertFalse($anotherPoolInstance->getItem('i1')->isHit()); + $this->assertFalse($anotherPoolInstance->getItem('i3')->isHit()); + $this->assertTrue($anotherPoolInstance->getItem('foo')->isHit()); + } + + public function testInvalidateCommits() + { + $pool1 = $this->createCachePool(); + + $foo = $pool1->getItem('foo'); + $foo->tag('tag'); + + $pool1->saveDeferred($foo->set('foo')); + $pool1->invalidateTags(['tag']); + + $pool2 = $this->createCachePool(); + $foo = $pool2->getItem('foo'); + + $this->assertTrue($foo->isHit()); + } + + public function testTagsAreCleanedOnSave() + { + $pool = $this->createCachePool(); + + $i = $pool->getItem('k'); + $pool->save($i->tag('foo')); + + $i = $pool->getItem('k'); + $pool->save($i->tag('bar')); + + $pool->invalidateTags(['foo']); + $this->assertTrue($pool->getItem('k')->isHit()); + } + + public function testTagsAreCleanedOnDelete() + { + $pool = $this->createCachePool(); + + $i = $pool->getItem('k'); + $pool->save($i->tag('foo')); + $pool->deleteItem('k'); + + $pool->save($pool->getItem('k')); + $pool->invalidateTags(['foo']); + + $this->assertTrue($pool->getItem('k')->isHit()); + } + + public function testTagItemExpiry() + { + $pool = $this->createCachePool(10); + + $item = $pool->getItem('foo'); + $item->tag(['baz']); + $item->expiresAfter(100); + + $pool->save($item); + $pool->invalidateTags(['baz']); + $this->assertFalse($pool->getItem('foo')->isHit()); + + sleep(20); + + $this->assertFalse($pool->getItem('foo')->isHit()); + } + + public function testGetPreviousTags() + { + $pool = $this->createCachePool(); + + $i = $pool->getItem('k'); + $pool->save($i->tag('foo')); + + $i = $pool->getItem('k'); + $this->assertSame(['foo' => 'foo'], $i->getPreviousTags()); + } + + public function testPrune() + { + $cache = new TagAwareAdapter($this->getPruneableMock()); + $this->assertTrue($cache->prune()); + + $cache = new TagAwareAdapter($this->getNonPruneableMock()); + $this->assertFalse($cache->prune()); + + $cache = new TagAwareAdapter($this->getFailingPruneableMock()); + $this->assertFalse($cache->prune()); + } + + public function testKnownTagVersionsTtl() + { + $itemsPool = new FilesystemAdapter('', 10); + $tagsPool = $this + ->getMockBuilder(AdapterInterface::class) + ->getMock(); + + $pool = new TagAwareAdapter($itemsPool, $tagsPool, 10); + + $item = $pool->getItem('foo'); + $item->tag(['baz']); + $item->expiresAfter(100); + + $tag = $this->getMockBuilder(CacheItemInterface::class)->getMock(); + $tag->expects(self::exactly(2))->method('get')->willReturn(10); + + $tagsPool->expects(self::exactly(2))->method('getItems')->willReturn([ + 'baz'.TagAwareAdapter::TAGS_PREFIX => $tag, + ]); + + $pool->save($item); + $this->assertTrue($pool->getItem('foo')->isHit()); + $this->assertTrue($pool->getItem('foo')->isHit()); + + sleep(20); + + $this->assertTrue($pool->getItem('foo')->isHit()); + + sleep(5); + + $this->assertTrue($pool->getItem('foo')->isHit()); + } + + public function testTagEntryIsCreatedForItemWithoutTags() + { + $pool = $this->createCachePool(); + + $itemKey = 'foo'; + $item = $pool->getItem($itemKey); + $pool->save($item); + + $adapter = new FilesystemAdapter(); + $this->assertTrue($adapter->hasItem(TagAwareAdapter::TAGS_PREFIX.$itemKey)); + } + + public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemTags() + { + $pool = $this->createCachePool(); + + $itemKey = 'foo'; + $item = $pool->getItem($itemKey); + $pool->save($item); + + $anotherPool = $this->createCachePool(); + + $adapter = new FilesystemAdapter(); + $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair + + $this->assertFalse($anotherPool->hasItem($itemKey)); + } + + public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemTags() + { + $pool = $this->createCachePool(); + + $itemKey = 'foo'; + $item = $pool->getItem($itemKey); + $pool->save($item); + + $anotherPool = $this->createCachePool(); + + $adapter = new FilesystemAdapter(); + $adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair + + $item = $anotherPool->getItem($itemKey); + $this->assertFalse($item->isHit()); + } + + public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags() + { + $pool = $this->createCachePool(); + + $itemKey = 'foo'; + $item = $pool->getItem($itemKey); + $pool->save($item); + + $anotherPool = $this->createCachePool(); + + $adapter = new FilesystemAdapter(); + $adapter->deleteItem($itemKey); //simulate losing item but keeping tags + + $this->assertFalse($anotherPool->hasItem($itemKey)); + } + + public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags() + { + $pool = $this->createCachePool(); + + $itemKey = 'foo'; + $item = $pool->getItem($itemKey); + $pool->save($item); + + $anotherPool = $this->createCachePool(); + + $adapter = new FilesystemAdapter(); + $adapter->deleteItem($itemKey); //simulate losing item but keeping tags + + $item = $anotherPool->getItem($itemKey); + $this->assertFalse($item->isHit()); + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(true); + + return $pruneable; + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getFailingPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(false); + + return $pruneable; + } + + /** + * @return MockObject|AdapterInterface + */ + private function getNonPruneableMock() + { + return $this + ->getMockBuilder(AdapterInterface::class) + ->getMock(); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php b/lib/symfony/cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php new file mode 100644 index 000000000..b11c1f287 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php @@ -0,0 +1,38 @@ +getItem('foo'); + $item->tag(['tag1', 'tag2']); + $item->set('bar'); + $cache->save($item); + + $this->assertSame('bar', $cache->getItem('foo')->get()); + } + + public function dataProvider() + { + return [ + [new ArrayAdapter()], + // also testing with a non-AdapterInterface implementation + // because the ProxyAdapter behaves slightly different for those + [new ExternalAdapter()], + ]; + } +} diff --git a/lib/symfony/cache/Tests/Adapter/TraceableAdapterTest.php b/lib/symfony/cache/Tests/Adapter/TraceableAdapterTest.php new file mode 100644 index 000000000..35eba7d77 --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/TraceableAdapterTest.php @@ -0,0 +1,191 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\TraceableAdapter; + +/** + * @group time-sensitive + */ +class TraceableAdapterTest extends AdapterTestCase +{ + protected $skippedTests = [ + 'testPrune' => 'TraceableAdapter just proxies', + ]; + + public function createCachePool($defaultLifetime = 0) + { + return new TraceableAdapter(new FilesystemAdapter('', $defaultLifetime)); + } + + public function testGetItemMissTrace() + { + $pool = $this->createCachePool(); + $pool->getItem('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('getItem', $call->name); + $this->assertSame(['k' => false], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(1, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testGetItemHitTrace() + { + $pool = $this->createCachePool(); + $item = $pool->getItem('k')->set('foo'); + $pool->save($item); + $pool->getItem('k'); + $calls = $pool->getCalls(); + $this->assertCount(3, $calls); + + $call = $calls[2]; + $this->assertSame(1, $call->hits); + $this->assertSame(0, $call->misses); + } + + public function testGetItemsMissTrace() + { + $pool = $this->createCachePool(); + $arg = ['k0', 'k1']; + $items = $pool->getItems($arg); + foreach ($items as $item) { + } + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('getItems', $call->name); + $this->assertSame(['k0' => false, 'k1' => false], $call->result); + $this->assertSame(2, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testHasItemMissTrace() + { + $pool = $this->createCachePool(); + $pool->hasItem('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('hasItem', $call->name); + $this->assertSame(['k' => false], $call->result); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testHasItemHitTrace() + { + $pool = $this->createCachePool(); + $item = $pool->getItem('k')->set('foo'); + $pool->save($item); + $pool->hasItem('k'); + $calls = $pool->getCalls(); + $this->assertCount(3, $calls); + + $call = $calls[2]; + $this->assertSame('hasItem', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testDeleteItemTrace() + { + $pool = $this->createCachePool(); + $pool->deleteItem('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('deleteItem', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testDeleteItemsTrace() + { + $pool = $this->createCachePool(); + $arg = ['k0', 'k1']; + $pool->deleteItems($arg); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('deleteItems', $call->name); + $this->assertSame(['keys' => $arg, 'result' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testSaveTrace() + { + $pool = $this->createCachePool(); + $item = $pool->getItem('k')->set('foo'); + $pool->save($item); + $calls = $pool->getCalls(); + $this->assertCount(2, $calls); + + $call = $calls[1]; + $this->assertSame('save', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testSaveDeferredTrace() + { + $pool = $this->createCachePool(); + $item = $pool->getItem('k')->set('foo'); + $pool->saveDeferred($item); + $calls = $pool->getCalls(); + $this->assertCount(2, $calls); + + $call = $calls[1]; + $this->assertSame('saveDeferred', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testCommitTrace() + { + $pool = $this->createCachePool(); + $pool->commit(); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('commit', $call->name); + $this->assertTrue($call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } +} diff --git a/lib/symfony/cache/Tests/Adapter/TraceableTagAwareAdapterTest.php b/lib/symfony/cache/Tests/Adapter/TraceableTagAwareAdapterTest.php new file mode 100644 index 000000000..5cd4185cb --- /dev/null +++ b/lib/symfony/cache/Tests/Adapter/TraceableTagAwareAdapterTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\TagAwareAdapter; +use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; + +/** + * @group time-sensitive + */ +class TraceableTagAwareAdapterTest extends TraceableAdapterTest +{ + public function testInvalidateTags() + { + $pool = new TraceableTagAwareAdapter(new TagAwareAdapter(new FilesystemAdapter())); + $pool->invalidateTags(['foo']); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('invalidateTags', $call->name); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } +} diff --git a/lib/symfony/cache/Tests/CacheItemTest.php b/lib/symfony/cache/Tests/CacheItemTest.php new file mode 100644 index 000000000..28c681d15 --- /dev/null +++ b/lib/symfony/cache/Tests/CacheItemTest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\CacheItem; + +class CacheItemTest extends TestCase +{ + public function testValidKey() + { + $this->assertSame('foo', CacheItem::validateKey('foo')); + } + + /** + * @dataProvider provideInvalidKey + */ + public function testInvalidKey($key) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Cache key'); + CacheItem::validateKey($key); + } + + public function provideInvalidKey() + { + return [ + [''], + ['{'], + ['}'], + ['('], + [')'], + ['/'], + ['\\'], + ['@'], + [':'], + [true], + [null], + [1], + [1.1], + [[[]]], + [new \Exception('foo')], + ]; + } + + public function testTag() + { + $item = new CacheItem(); + + $this->assertSame($item, $item->tag('foo')); + $this->assertSame($item, $item->tag(['bar', 'baz'])); + + \call_user_func(\Closure::bind(function () use ($item) { + $this->assertSame(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'], $item->tags); + }, $this, CacheItem::class)); + } + + /** + * @dataProvider provideInvalidKey + */ + public function testInvalidTag($tag) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Cache tag'); + $item = new CacheItem(); + $item->tag($tag); + } +} diff --git a/lib/symfony/cache/Tests/DoctrineProviderTest.php b/lib/symfony/cache/Tests/DoctrineProviderTest.php new file mode 100644 index 000000000..91a5516ab --- /dev/null +++ b/lib/symfony/cache/Tests/DoctrineProviderTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests; + +use Doctrine\Common\Cache\CacheProvider; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\DoctrineProvider; + +class DoctrineProviderTest extends TestCase +{ + public function testProvider() + { + $pool = new ArrayAdapter(); + $cache = new DoctrineProvider($pool); + + $this->assertInstanceOf(CacheProvider::class, $cache); + + $key = '{}()/\@:'; + + $this->assertTrue($cache->delete($key)); + $this->assertFalse($cache->contains($key)); + + $this->assertTrue($cache->save($key, 'bar')); + $this->assertTrue($cache->contains($key)); + $this->assertSame('bar', $cache->fetch($key)); + + $this->assertTrue($cache->delete($key)); + $this->assertFalse($cache->fetch($key)); + $this->assertTrue($cache->save($key, 'bar')); + + $cache->flushAll(); + $this->assertFalse($cache->fetch($key)); + $this->assertFalse($cache->contains($key)); + } +} diff --git a/lib/symfony/cache/Tests/Fixtures/ArrayCache.php b/lib/symfony/cache/Tests/Fixtures/ArrayCache.php new file mode 100644 index 000000000..13b4f3306 --- /dev/null +++ b/lib/symfony/cache/Tests/Fixtures/ArrayCache.php @@ -0,0 +1,52 @@ +doContains($id) ? $this->data[$id][0] : false; + } + + protected function doContains($id) + { + if (!isset($this->data[$id])) { + return false; + } + + $expiry = $this->data[$id][1]; + + return !$expiry || time() < $expiry || !$this->doDelete($id); + } + + protected function doSave($id, $data, $lifeTime = 0) + { + $this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false]; + + return true; + } + + protected function doDelete($id) + { + unset($this->data[$id]); + + return true; + } + + protected function doFlush() + { + $this->data = []; + + return true; + } + + protected function doGetStats() + { + return null; + } +} diff --git a/lib/symfony/cache/Tests/Fixtures/ExternalAdapter.php b/lib/symfony/cache/Tests/Fixtures/ExternalAdapter.php new file mode 100644 index 000000000..779a374ec --- /dev/null +++ b/lib/symfony/cache/Tests/Fixtures/ExternalAdapter.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Fixtures; + +use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\ArrayAdapter; + +/** + * Adapter not implementing the {@see \Symfony\Component\Cache\Adapter\AdapterInterface}. + * + * @author Kévin Dunglas + */ +class ExternalAdapter implements CacheItemPoolInterface +{ + private $cache; + + public function __construct() + { + $this->cache = new ArrayAdapter(); + } + + public function getItem($key) + { + return $this->cache->getItem($key); + } + + public function getItems(array $keys = []) + { + return $this->cache->getItems($keys); + } + + public function hasItem($key) + { + return $this->cache->hasItem($key); + } + + public function clear() + { + return $this->cache->clear(); + } + + public function deleteItem($key) + { + return $this->cache->deleteItem($key); + } + + public function deleteItems(array $keys) + { + return $this->cache->deleteItems($keys); + } + + public function save(CacheItemInterface $item) + { + return $this->cache->save($item); + } + + public function saveDeferred(CacheItemInterface $item) + { + return $this->cache->saveDeferred($item); + } + + public function commit() + { + return $this->cache->commit(); + } +} diff --git a/lib/symfony/cache/Tests/Simple/AbstractRedisCacheTest.php b/lib/symfony/cache/Tests/Simple/AbstractRedisCacheTest.php new file mode 100644 index 000000000..e6d10284e --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/AbstractRedisCacheTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\RedisCache; + +abstract class AbstractRedisCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testSetTtl' => 'Testing expiration slows down the test suite', + 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + protected static $redis; + + public function createSimpleCache($defaultLifetime = 0) + { + return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + } + + public static function setUpBeforeClass() + { + if (!\extension_loaded('redis')) { + self::markTestSkipped('Extension redis required.'); + } + if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { + $e = error_get_last(); + self::markTestSkipped($e['message']); + } + } + + public static function tearDownAfterClass() + { + self::$redis = null; + } +} diff --git a/lib/symfony/cache/Tests/Simple/ApcuCacheTest.php b/lib/symfony/cache/Tests/Simple/ApcuCacheTest.php new file mode 100644 index 000000000..f37b95a09 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/ApcuCacheTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\ApcuCache; + +class ApcuCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testSetTtl' => 'Testing expiration slows down the test suite', + 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + public function createSimpleCache($defaultLifetime = 0) + { + if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) { + $this->markTestSkipped('APCu extension is required.'); + } + if ('\\' === \DIRECTORY_SEPARATOR) { + $this->markTestSkipped('Fails transiently on Windows.'); + } + + return new ApcuCache(str_replace('\\', '.', __CLASS__), $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/ArrayCacheTest.php b/lib/symfony/cache/Tests/Simple/ArrayCacheTest.php new file mode 100644 index 000000000..26c3e14d0 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/ArrayCacheTest.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\ArrayCache; + +/** + * @group time-sensitive + */ +class ArrayCacheTest extends CacheTestCase +{ + public function createSimpleCache($defaultLifetime = 0) + { + return new ArrayCache($defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/CacheTestCase.php b/lib/symfony/cache/Tests/Simple/CacheTestCase.php new file mode 100644 index 000000000..ff9944a34 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/CacheTestCase.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Cache\IntegrationTests\SimpleCacheTest; +use Psr\SimpleCache\CacheInterface; +use Symfony\Component\Cache\PruneableInterface; + +abstract class CacheTestCase extends SimpleCacheTest +{ + protected function setUp() + { + parent::setUp(); + + if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) { + $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; + } + } + + public static function validKeys() + { + if (\defined('HHVM_VERSION')) { + return parent::validKeys(); + } + + return array_merge(parent::validKeys(), [["a\0b"]]); + } + + public function testDefaultLifeTime() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createSimpleCache(2); + $cache->clear(); + + $cache->set('key.dlt', 'value'); + sleep(1); + + $this->assertSame('value', $cache->get('key.dlt')); + + sleep(2); + $this->assertNull($cache->get('key.dlt')); + + $cache->clear(); + } + + public function testNotUnserializable() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createSimpleCache(); + $cache->clear(); + + $cache->set('foo', new NotUnserializable()); + + $this->assertNull($cache->get('foo')); + + $cache->setMultiple(['foo' => new NotUnserializable()]); + + foreach ($cache->getMultiple(['foo']) as $value) { + } + $this->assertNull($value); + + $cache->clear(); + } + + public function testPrune() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + if (!method_exists($this, 'isPruned')) { + $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); + } + + /** @var PruneableInterface|CacheInterface $cache */ + $cache = $this->createSimpleCache(); + $cache->clear(); + + $cache->set('foo', 'foo-val', new \DateInterval('PT05S')); + $cache->set('bar', 'bar-val', new \DateInterval('PT10S')); + $cache->set('baz', 'baz-val', new \DateInterval('PT15S')); + $cache->set('qux', 'qux-val', new \DateInterval('PT20S')); + + sleep(30); + $cache->prune(); + $this->assertTrue($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'bar')); + $this->assertTrue($this->isPruned($cache, 'baz')); + $this->assertTrue($this->isPruned($cache, 'qux')); + + $cache->set('foo', 'foo-val'); + $cache->set('bar', 'bar-val', new \DateInterval('PT20S')); + $cache->set('baz', 'baz-val', new \DateInterval('PT40S')); + $cache->set('qux', 'qux-val', new \DateInterval('PT80S')); + + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertFalse($this->isPruned($cache, 'bar')); + $this->assertFalse($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'bar')); + $this->assertFalse($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'baz')); + $this->assertFalse($this->isPruned($cache, 'qux')); + + sleep(30); + $cache->prune(); + $this->assertFalse($this->isPruned($cache, 'foo')); + $this->assertTrue($this->isPruned($cache, 'qux')); + + $cache->clear(); + } +} + +class NotUnserializable implements \Serializable +{ + public function serialize() + { + return serialize(123); + } + + public function unserialize($ser) + { + throw new \Exception(__CLASS__); + } +} diff --git a/lib/symfony/cache/Tests/Simple/ChainCacheTest.php b/lib/symfony/cache/Tests/Simple/ChainCacheTest.php new file mode 100644 index 000000000..f216bc1f3 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/ChainCacheTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use PHPUnit\Framework\MockObject\MockObject; +use Psr\SimpleCache\CacheInterface; +use Symfony\Component\Cache\PruneableInterface; +use Symfony\Component\Cache\Simple\ArrayCache; +use Symfony\Component\Cache\Simple\ChainCache; +use Symfony\Component\Cache\Simple\FilesystemCache; + +/** + * @group time-sensitive + */ +class ChainCacheTest extends CacheTestCase +{ + public function createSimpleCache($defaultLifetime = 0) + { + return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime); + } + + public function testEmptyCachesException() + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('At least one cache must be specified.'); + new ChainCache([]); + } + + public function testInvalidCacheException() + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('The class "stdClass" does not implement'); + new ChainCache([new \stdClass()]); + } + + public function testPrune() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = new ChainCache([ + $this->getPruneableMock(), + $this->getNonPruneableMock(), + $this->getPruneableMock(), + ]); + $this->assertTrue($cache->prune()); + + $cache = new ChainCache([ + $this->getPruneableMock(), + $this->getFailingPruneableMock(), + $this->getPruneableMock(), + ]); + $this->assertFalse($cache->prune()); + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(true); + + return $pruneable; + } + + /** + * @return MockObject|PruneableCacheInterface + */ + private function getFailingPruneableMock() + { + $pruneable = $this + ->getMockBuilder(PruneableCacheInterface::class) + ->getMock(); + + $pruneable + ->expects($this->atLeastOnce()) + ->method('prune') + ->willReturn(false); + + return $pruneable; + } + + /** + * @return MockObject|CacheInterface + */ + private function getNonPruneableMock() + { + return $this + ->getMockBuilder(CacheInterface::class) + ->getMock(); + } +} + +interface PruneableCacheInterface extends PruneableInterface, CacheInterface +{ +} diff --git a/lib/symfony/cache/Tests/Simple/DoctrineCacheTest.php b/lib/symfony/cache/Tests/Simple/DoctrineCacheTest.php new file mode 100644 index 000000000..af4331d69 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/DoctrineCacheTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\DoctrineCache; +use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; + +/** + * @group time-sensitive + */ +class DoctrineCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize', + 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', + ]; + + public function createSimpleCache($defaultLifetime = 0) + { + return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/FilesystemCacheTest.php b/lib/symfony/cache/Tests/Simple/FilesystemCacheTest.php new file mode 100644 index 000000000..620305a58 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/FilesystemCacheTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Psr\SimpleCache\CacheInterface; +use Symfony\Component\Cache\Simple\FilesystemCache; + +/** + * @group time-sensitive + */ +class FilesystemCacheTest extends CacheTestCase +{ + public function createSimpleCache($defaultLifetime = 0) + { + return new FilesystemCache('', $defaultLifetime); + } + + protected function isPruned(CacheInterface $cache, $name) + { + $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); + $getFileMethod->setAccessible(true); + + return !file_exists($getFileMethod->invoke($cache, $name)); + } +} diff --git a/lib/symfony/cache/Tests/Simple/MemcachedCacheTest.php b/lib/symfony/cache/Tests/Simple/MemcachedCacheTest.php new file mode 100644 index 000000000..21332232b --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/MemcachedCacheTest.php @@ -0,0 +1,172 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Simple\MemcachedCache; + +class MemcachedCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testSetTtl' => 'Testing expiration slows down the test suite', + 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', + 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', + ]; + + protected static $client; + + public static function setUpBeforeClass() + { + if (!MemcachedCache::isSupported()) { + self::markTestSkipped('Extension memcached >=2.2.0 required.'); + } + self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')); + self::$client->get('foo'); + $code = self::$client->getResultCode(); + + if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { + self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); + } + } + + public function createSimpleCache($defaultLifetime = 0) + { + $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client; + + return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); + } + + public function testCreatePersistentConnectionShouldNotDupServerList() + { + $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); + $this->assertCount(1, $instance->getServerList()); + + $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); + $this->assertCount(1, $instance->getServerList()); + } + + public function testOptions() + { + $client = MemcachedCache::createConnection([], [ + 'libketama_compatible' => false, + 'distribution' => 'modula', + 'compression' => true, + 'serializer' => 'php', + 'hash' => 'md5', + ]); + + $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); + $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); + $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); + $this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); + $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); + } + + /** + * @dataProvider provideBadOptions + */ + public function testBadOptions($name, $value) + { + $this->expectException('ErrorException'); + $this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::'); + MemcachedCache::createConnection([], [$name => $value]); + } + + public function provideBadOptions() + { + return [ + ['foo', 'bar'], + ['hash', 'zyx'], + ['serializer', 'zyx'], + ['distribution', 'zyx'], + ]; + } + + public function testDefaultOptions() + { + $this->assertTrue(MemcachedCache::isSupported()); + + $client = MemcachedCache::createConnection([]); + + $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); + $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); + $this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); + } + + public function testOptionSerializer() + { + $this->expectException('Symfony\Component\Cache\Exception\CacheException'); + $this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); + if (!\Memcached::HAVE_JSON) { + $this->markTestSkipped('Memcached::HAVE_JSON required'); + } + + new MemcachedCache(MemcachedCache::createConnection([], ['serializer' => 'json'])); + } + + /** + * @dataProvider provideServersSetting + */ + public function testServersSetting($dsn, $host, $port) + { + $client1 = MemcachedCache::createConnection($dsn); + $client2 = MemcachedCache::createConnection([$dsn]); + $client3 = MemcachedCache::createConnection([[$host, $port]]); + $expect = [ + 'host' => $host, + 'port' => $port, + ]; + + $f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; }; + $this->assertSame([$expect], array_map($f, $client1->getServerList())); + $this->assertSame([$expect], array_map($f, $client2->getServerList())); + $this->assertSame([$expect], array_map($f, $client3->getServerList())); + } + + public function provideServersSetting() + { + yield [ + 'memcached://127.0.0.1/50', + '127.0.0.1', + 11211, + ]; + yield [ + 'memcached://localhost:11222?weight=25', + 'localhost', + 11222, + ]; + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + yield [ + 'memcached://user:password@127.0.0.1?weight=50', + '127.0.0.1', + 11211, + ]; + } + yield [ + 'memcached:///var/run/memcached.sock?weight=25', + '/var/run/memcached.sock', + 0, + ]; + yield [ + 'memcached:///var/local/run/memcached.socket?weight=25', + '/var/local/run/memcached.socket', + 0, + ]; + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + yield [ + 'memcached://user:password@/var/local/run/memcached.socket?weight=25', + '/var/local/run/memcached.socket', + 0, + ]; + } + } +} diff --git a/lib/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php b/lib/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php new file mode 100644 index 000000000..13865a609 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Simple\MemcachedCache; + +class MemcachedCacheTextModeTest extends MemcachedCacheTest +{ + public function createSimpleCache($defaultLifetime = 0) + { + $client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); + + return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/NullCacheTest.php b/lib/symfony/cache/Tests/Simple/NullCacheTest.php new file mode 100644 index 000000000..31f42c32b --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/NullCacheTest.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Simple\NullCache; + +/** + * @group time-sensitive + */ +class NullCacheTest extends TestCase +{ + public function createCachePool() + { + return new NullCache(); + } + + public function testGetItem() + { + $cache = $this->createCachePool(); + + $this->assertNull($cache->get('key')); + } + + public function testHas() + { + $this->assertFalse($this->createCachePool()->has('key')); + } + + public function testGetMultiple() + { + $cache = $this->createCachePool(); + + $keys = ['foo', 'bar', 'baz', 'biz']; + + $default = new \stdClass(); + $items = $cache->getMultiple($keys, $default); + $count = 0; + + foreach ($items as $key => $item) { + $this->assertContains($key, $keys, 'Cache key can not change.'); + $this->assertSame($default, $item); + + // Remove $key for $keys + foreach ($keys as $k => $v) { + if ($v === $key) { + unset($keys[$k]); + } + } + + ++$count; + } + + $this->assertSame(4, $count); + } + + public function testClear() + { + $this->assertTrue($this->createCachePool()->clear()); + } + + public function testDelete() + { + $this->assertTrue($this->createCachePool()->delete('key')); + } + + public function testDeleteMultiple() + { + $this->assertTrue($this->createCachePool()->deleteMultiple(['key', 'foo', 'bar'])); + } + + public function testSet() + { + $cache = $this->createCachePool(); + + $this->assertFalse($cache->set('key', 'val')); + $this->assertNull($cache->get('key')); + } + + public function testSetMultiple() + { + $cache = $this->createCachePool(); + + $this->assertFalse($cache->setMultiple(['key' => 'val'])); + $this->assertNull($cache->get('key')); + } +} diff --git a/lib/symfony/cache/Tests/Simple/PdoCacheTest.php b/lib/symfony/cache/Tests/Simple/PdoCacheTest.php new file mode 100644 index 000000000..f5a26341f --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/PdoCacheTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\PdoCache; +use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; + +/** + * @group time-sensitive + */ +class PdoCacheTest extends CacheTestCase +{ + use PdoPruneableTrait; + + protected static $dbFile; + + public static function setUpBeforeClass() + { + if (!\extension_loaded('pdo_sqlite')) { + self::markTestSkipped('Extension pdo_sqlite required.'); + } + + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); + + $pool = new PdoCache('sqlite:'.self::$dbFile); + $pool->createTable(); + } + + public static function tearDownAfterClass() + { + @unlink(self::$dbFile); + } + + public function createSimpleCache($defaultLifetime = 0) + { + return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/PdoDbalCacheTest.php b/lib/symfony/cache/Tests/Simple/PdoDbalCacheTest.php new file mode 100644 index 000000000..4da2b603c --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/PdoDbalCacheTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Doctrine\DBAL\DriverManager; +use Symfony\Component\Cache\Simple\PdoCache; +use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; + +/** + * @group time-sensitive + */ +class PdoDbalCacheTest extends CacheTestCase +{ + use PdoPruneableTrait; + + protected static $dbFile; + + public static function setUpBeforeClass() + { + if (!\extension_loaded('pdo_sqlite')) { + self::markTestSkipped('Extension pdo_sqlite required.'); + } + + self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); + + $pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); + $pool->createTable(); + } + + public static function tearDownAfterClass() + { + @unlink(self::$dbFile); + } + + public function createSimpleCache($defaultLifetime = 0) + { + return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime); + } +} diff --git a/lib/symfony/cache/Tests/Simple/PhpArrayCacheTest.php b/lib/symfony/cache/Tests/Simple/PhpArrayCacheTest.php new file mode 100644 index 000000000..c18f71442 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/PhpArrayCacheTest.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\NullCache; +use Symfony\Component\Cache\Simple\PhpArrayCache; +use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; + +/** + * @group time-sensitive + */ +class PhpArrayCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes', + + 'testDelete' => 'PhpArrayCache does no writes', + 'testDeleteMultiple' => 'PhpArrayCache does no writes', + 'testDeleteMultipleGenerator' => 'PhpArrayCache does no writes', + + 'testSetTtl' => 'PhpArrayCache does no expiration', + 'testSetMultipleTtl' => 'PhpArrayCache does no expiration', + 'testSetExpiredTtl' => 'PhpArrayCache does no expiration', + 'testSetMultipleExpiredTtl' => 'PhpArrayCache does no expiration', + + 'testGetInvalidKeys' => 'PhpArrayCache does no validation', + 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetInvalidKeys' => 'PhpArrayCache does no validation', + 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', + 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetInvalidTtl' => 'PhpArrayCache does no validation', + 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', + 'testHasInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetValidData' => 'PhpArrayCache does no validation', + + 'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.', + 'testPrune' => 'PhpArrayCache just proxies', + ]; + + protected static $file; + + public static function setUpBeforeClass() + { + self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; + } + + protected function tearDown() + { + if (file_exists(sys_get_temp_dir().'/symfony-cache')) { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + } + + public function createSimpleCache() + { + return new PhpArrayCacheWrapper(self::$file, new NullCache()); + } + + public function testStore() + { + $arrayWithRefs = []; + $arrayWithRefs[0] = 123; + $arrayWithRefs[1] = &$arrayWithRefs[0]; + + $object = (object) [ + 'foo' => 'bar', + 'foo2' => 'bar2', + ]; + + $expected = [ + 'null' => null, + 'serializedString' => serialize($object), + 'arrayWithRefs' => $arrayWithRefs, + 'object' => $object, + 'arrayWithObject' => ['bar' => $object], + ]; + + $cache = new PhpArrayCache(self::$file, new NullCache()); + $cache->warmUp($expected); + + foreach ($expected as $key => $value) { + $this->assertSame(serialize($value), serialize($cache->get($key)), 'Warm up should create a PHP file that OPCache can load in memory'); + } + } + + public function testStoredFile() + { + $expected = [ + 'integer' => 42, + 'float' => 42.42, + 'boolean' => true, + 'array_simple' => ['foo', 'bar'], + 'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'], + ]; + + $cache = new PhpArrayCache(self::$file, new NullCache()); + $cache->warmUp($expected); + + $values = eval(substr(file_get_contents(self::$file), 6)); + + $this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory'); + } +} + +class PhpArrayCacheWrapper extends PhpArrayCache +{ + public function set($key, $value, $ttl = null) + { + \call_user_func(\Closure::bind(function () use ($key, $value) { + $this->values[$key] = $value; + $this->warmUp($this->values); + $this->values = eval(substr(file_get_contents($this->file), 6)); + }, $this, PhpArrayCache::class)); + + return true; + } + + public function setMultiple($values, $ttl = null) + { + if (!\is_array($values) && !$values instanceof \Traversable) { + return parent::setMultiple($values, $ttl); + } + \call_user_func(\Closure::bind(function () use ($values) { + foreach ($values as $key => $value) { + $this->values[$key] = $value; + } + $this->warmUp($this->values); + $this->values = eval(substr(file_get_contents($this->file), 6)); + }, $this, PhpArrayCache::class)); + + return true; + } +} diff --git a/lib/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php b/lib/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php new file mode 100644 index 000000000..eba749cec --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\FilesystemCache; +use Symfony\Component\Cache\Simple\PhpArrayCache; +use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; + +/** + * @group time-sensitive + */ +class PhpArrayCacheWithFallbackTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testGetInvalidKeys' => 'PhpArrayCache does no validation', + 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', + 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', + 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', + //'testSetValidData' => 'PhpArrayCache does no validation', + 'testSetInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetInvalidTtl' => 'PhpArrayCache does no validation', + 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', + 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', + 'testHasInvalidKeys' => 'PhpArrayCache does no validation', + 'testPrune' => 'PhpArrayCache just proxies', + ]; + + protected static $file; + + public static function setUpBeforeClass() + { + self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; + } + + protected function tearDown() + { + if (file_exists(sys_get_temp_dir().'/symfony-cache')) { + FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); + } + } + + public function createSimpleCache($defaultLifetime = 0) + { + return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime)); + } +} diff --git a/lib/symfony/cache/Tests/Simple/PhpFilesCacheTest.php b/lib/symfony/cache/Tests/Simple/PhpFilesCacheTest.php new file mode 100644 index 000000000..936f29a43 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/PhpFilesCacheTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Psr\SimpleCache\CacheInterface; +use Symfony\Component\Cache\Simple\PhpFilesCache; + +/** + * @group time-sensitive + */ +class PhpFilesCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.', + ]; + + public function createSimpleCache() + { + if (!PhpFilesCache::isSupported()) { + $this->markTestSkipped('OPcache extension is not enabled.'); + } + + return new PhpFilesCache('sf-cache'); + } + + protected function isPruned(CacheInterface $cache, $name) + { + $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); + $getFileMethod->setAccessible(true); + + return !file_exists($getFileMethod->invoke($cache, $name)); + } +} diff --git a/lib/symfony/cache/Tests/Simple/Psr6CacheTest.php b/lib/symfony/cache/Tests/Simple/Psr6CacheTest.php new file mode 100644 index 000000000..1bc75c906 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/Psr6CacheTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Simple\Psr6Cache; + +/** + * @group time-sensitive + */ +class Psr6CacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testPrune' => 'Psr6Cache just proxies', + ]; + + public function createSimpleCache($defaultLifetime = 0) + { + return new Psr6Cache(new FilesystemAdapter('', $defaultLifetime)); + } +} diff --git a/lib/symfony/cache/Tests/Simple/RedisArrayCacheTest.php b/lib/symfony/cache/Tests/Simple/RedisArrayCacheTest.php new file mode 100644 index 000000000..ec5e4c06e --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/RedisArrayCacheTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +class RedisArrayCacheTest extends AbstractRedisCacheTest +{ + public static function setUpBeforeClass() + { + parent::setupBeforeClass(); + if (!class_exists('RedisArray')) { + self::markTestSkipped('The RedisArray class is required.'); + } + self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); + } +} diff --git a/lib/symfony/cache/Tests/Simple/RedisCacheTest.php b/lib/symfony/cache/Tests/Simple/RedisCacheTest.php new file mode 100644 index 000000000..c2cd31a5b --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/RedisCacheTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\RedisCache; + +class RedisCacheTest extends AbstractRedisCacheTest +{ + public static function setUpBeforeClass() + { + parent::setupBeforeClass(); + self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST')); + } + + public function testCreateConnection() + { + $redisHost = getenv('REDIS_HOST'); + + $redis = RedisCache::createConnection('redis://'.$redisHost); + $this->assertInstanceOf(\Redis::class, $redis); + $this->assertTrue($redis->isConnected()); + $this->assertSame(0, $redis->getDbNum()); + + $redis = RedisCache::createConnection('redis://'.$redisHost.'/2'); + $this->assertSame(2, $redis->getDbNum()); + + $redis = RedisCache::createConnection('redis://'.$redisHost, ['timeout' => 3]); + $this->assertEquals(3, $redis->getTimeout()); + + $redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4'); + $this->assertEquals(4, $redis->getTimeout()); + + $redis = RedisCache::createConnection('redis://'.$redisHost, ['read_timeout' => 5]); + $this->assertEquals(5, $redis->getReadTimeout()); + } + + /** + * @dataProvider provideFailedCreateConnection + */ + public function testFailedCreateConnection($dsn) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Redis connection failed'); + RedisCache::createConnection($dsn); + } + + public function provideFailedCreateConnection() + { + return [ + ['redis://localhost:1234'], + ['redis://foo@localhost'], + ['redis://localhost/123'], + ]; + } + + /** + * @dataProvider provideInvalidCreateConnection + */ + public function testInvalidCreateConnection($dsn) + { + $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectExceptionMessage('Invalid Redis DSN'); + RedisCache::createConnection($dsn); + } + + public function provideInvalidCreateConnection() + { + return [ + ['foo://localhost'], + ['redis://'], + ]; + } +} diff --git a/lib/symfony/cache/Tests/Simple/RedisClusterCacheTest.php b/lib/symfony/cache/Tests/Simple/RedisClusterCacheTest.php new file mode 100644 index 000000000..6b7f8039d --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/RedisClusterCacheTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +class RedisClusterCacheTest extends AbstractRedisCacheTest +{ + public static function setUpBeforeClass() + { + if (!class_exists('RedisCluster')) { + self::markTestSkipped('The RedisCluster class is required.'); + } + if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { + self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + } + + self::$redis = new \RedisCluster(null, explode(' ', $hosts)); + } +} diff --git a/lib/symfony/cache/Tests/Simple/TraceableCacheTest.php b/lib/symfony/cache/Tests/Simple/TraceableCacheTest.php new file mode 100644 index 000000000..e684caf36 --- /dev/null +++ b/lib/symfony/cache/Tests/Simple/TraceableCacheTest.php @@ -0,0 +1,171 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Simple; + +use Symfony\Component\Cache\Simple\FilesystemCache; +use Symfony\Component\Cache\Simple\TraceableCache; + +/** + * @group time-sensitive + */ +class TraceableCacheTest extends CacheTestCase +{ + protected $skippedTests = [ + 'testPrune' => 'TraceableCache just proxies', + ]; + + public function createSimpleCache($defaultLifetime = 0) + { + return new TraceableCache(new FilesystemCache('', $defaultLifetime)); + } + + public function testGetMissTrace() + { + $pool = $this->createSimpleCache(); + $pool->get('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('get', $call->name); + $this->assertSame(['k' => false], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(1, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testGetHitTrace() + { + $pool = $this->createSimpleCache(); + $pool->set('k', 'foo'); + $pool->get('k'); + $calls = $pool->getCalls(); + $this->assertCount(2, $calls); + + $call = $calls[1]; + $this->assertSame(1, $call->hits); + $this->assertSame(0, $call->misses); + } + + public function testGetMultipleMissTrace() + { + $pool = $this->createSimpleCache(); + $pool->set('k1', 123); + $values = $pool->getMultiple(['k0', 'k1']); + foreach ($values as $value) { + } + $calls = $pool->getCalls(); + $this->assertCount(2, $calls); + + $call = $calls[1]; + $this->assertSame('getMultiple', $call->name); + $this->assertSame(['k1' => true, 'k0' => false], $call->result); + $this->assertSame(1, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testHasMissTrace() + { + $pool = $this->createSimpleCache(); + $pool->has('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('has', $call->name); + $this->assertSame(['k' => false], $call->result); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testHasHitTrace() + { + $pool = $this->createSimpleCache(); + $pool->set('k', 'foo'); + $pool->has('k'); + $calls = $pool->getCalls(); + $this->assertCount(2, $calls); + + $call = $calls[1]; + $this->assertSame('has', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testDeleteTrace() + { + $pool = $this->createSimpleCache(); + $pool->delete('k'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('delete', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testDeleteMultipleTrace() + { + $pool = $this->createSimpleCache(); + $arg = ['k0', 'k1']; + $pool->deleteMultiple($arg); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('deleteMultiple', $call->name); + $this->assertSame(['keys' => $arg, 'result' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testTraceSetTrace() + { + $pool = $this->createSimpleCache(); + $pool->set('k', 'foo'); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('set', $call->name); + $this->assertSame(['k' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } + + public function testSetMultipleTrace() + { + $pool = $this->createSimpleCache(); + $pool->setMultiple(['k' => 'foo']); + $calls = $pool->getCalls(); + $this->assertCount(1, $calls); + + $call = $calls[0]; + $this->assertSame('setMultiple', $call->name); + $this->assertSame(['keys' => ['k'], 'result' => true], $call->result); + $this->assertSame(0, $call->hits); + $this->assertSame(0, $call->misses); + $this->assertNotEmpty($call->start); + $this->assertNotEmpty($call->end); + } +} diff --git a/lib/symfony/cache/Tests/Traits/PdoPruneableTrait.php b/lib/symfony/cache/Tests/Traits/PdoPruneableTrait.php new file mode 100644 index 000000000..3b1e1128b --- /dev/null +++ b/lib/symfony/cache/Tests/Traits/PdoPruneableTrait.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Traits; + +trait PdoPruneableTrait +{ + protected function isPruned($cache, $name) + { + $o = new \ReflectionObject($cache); + + if (!$o->hasMethod('getConnection')) { + self::fail('Cache does not have "getConnection()" method.'); + } + + $getPdoConn = $o->getMethod('getConnection'); + $getPdoConn->setAccessible(true); + + /** @var \Doctrine\DBAL\Statement $select */ + $select = $getPdoConn->invoke($cache)->prepare('SELECT 1 FROM cache_items WHERE item_id LIKE :id'); + $select->bindValue(':id', sprintf('%%%s', $name)); + $select->execute(); + + return 0 === \count($select->fetchAll(\PDO::FETCH_COLUMN)); + } +} diff --git a/lib/symfony/class-loader/Tests/ApcClassLoaderTest.php b/lib/symfony/class-loader/Tests/ApcClassLoaderTest.php new file mode 100644 index 000000000..6706acbd3 --- /dev/null +++ b/lib/symfony/class-loader/Tests/ApcClassLoaderTest.php @@ -0,0 +1,200 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\ClassLoader\ApcClassLoader; +use Symfony\Component\ClassLoader\ClassLoader; + +/** + * @group legacy + */ +class ApcClassLoaderTest extends TestCase +{ + protected function setUp() + { + if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) { + $this->markTestSkipped('The apc extension is not enabled.'); + } else { + apcu_clear_cache(); + } + } + + protected function tearDown() + { + if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + apcu_clear_cache(); + } + } + + public function testConstructor() + { + $loader = new ClassLoader(); + $loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + + $loader = new ApcClassLoader('test.prefix.', $loader); + + $this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument'); + } + + /** + * @dataProvider getLoadClassTests + */ + public function testLoadClass($className, $testClassName, $message) + { + $loader = new ClassLoader(); + $loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + + $loader = new ApcClassLoader('test.prefix.', $loader); + $loader->loadClass($testClassName); + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassTests() + { + return [ + ['\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'], + ['Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'], + ]; + } + + /** + * @dataProvider getLoadClassFromFallbackTests + */ + public function testLoadClassFromFallback($className, $testClassName, $message) + { + $loader = new ClassLoader(); + $loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('', [__DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback']); + + $loader = new ApcClassLoader('test.prefix.fallback', $loader); + $loader->loadClass($testClassName); + + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassFromFallbackTests() + { + return [ + ['\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'], + ['Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'], + ['\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'], + ['Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'], + ]; + } + + /** + * @dataProvider getLoadClassNamespaceCollisionTests + */ + public function testLoadClassNamespaceCollision($namespaces, $className, $message) + { + $loader = new ClassLoader(); + $loader->addPrefixes($namespaces); + + $loader = new ApcClassLoader('test.prefix.collision.', $loader); + $loader->loadClass($className); + + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassNamespaceCollisionTests() + { + return [ + [ + [ + 'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', + 'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', + ], + 'Apc\NamespaceCollision\A\Foo', + '->loadClass() loads NamespaceCollision\A\Foo from alpha.', + ], + [ + [ + 'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', + 'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', + ], + 'Apc\NamespaceCollision\A\Bar', + '->loadClass() loads NamespaceCollision\A\Bar from alpha.', + ], + [ + [ + 'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', + 'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', + ], + 'Apc\NamespaceCollision\A\B\Foo', + '->loadClass() loads NamespaceCollision\A\B\Foo from beta.', + ], + [ + [ + 'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', + 'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', + ], + 'Apc\NamespaceCollision\A\B\Bar', + '->loadClass() loads NamespaceCollision\A\B\Bar from beta.', + ], + ]; + } + + /** + * @dataProvider getLoadClassPrefixCollisionTests + */ + public function testLoadClassPrefixCollision($prefixes, $className, $message) + { + $loader = new ClassLoader(); + $loader->addPrefixes($prefixes); + + $loader = new ApcClassLoader('test.prefix.collision.', $loader); + $loader->loadClass($className); + + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassPrefixCollisionTests() + { + return [ + [ + [ + 'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', + 'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', + ], + 'ApcPrefixCollision_A_Foo', + '->loadClass() loads ApcPrefixCollision_A_Foo from alpha.', + ], + [ + [ + 'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', + 'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', + ], + 'ApcPrefixCollision_A_Bar', + '->loadClass() loads ApcPrefixCollision_A_Bar from alpha.', + ], + [ + [ + 'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', + 'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', + ], + 'ApcPrefixCollision_A_B_Foo', + '->loadClass() loads ApcPrefixCollision_A_B_Foo from beta.', + ], + [ + [ + 'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc', + 'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', + ], + 'ApcPrefixCollision_A_B_Bar', + '->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.', + ], + ]; + } +} diff --git a/lib/symfony/class-loader/Tests/ClassCollectionLoaderTest.php b/lib/symfony/class-loader/Tests/ClassCollectionLoaderTest.php new file mode 100644 index 000000000..e1d5f56de --- /dev/null +++ b/lib/symfony/class-loader/Tests/ClassCollectionLoaderTest.php @@ -0,0 +1,317 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\ClassLoader\ClassCollectionLoader; +use Symfony\Component\ClassLoader\Tests\Fixtures\DeclaredClass; +use Symfony\Component\ClassLoader\Tests\Fixtures\WarmedClass; + +require_once __DIR__.'/Fixtures/ClassesWithParents/GInterface.php'; +require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php'; +require_once __DIR__.'/Fixtures/ClassesWithParents/B.php'; +require_once __DIR__.'/Fixtures/ClassesWithParents/A.php'; + +/** + * @group legacy + */ +class ClassCollectionLoaderTest extends TestCase +{ + public function testTraitDependencies() + { + require_once __DIR__.'/Fixtures/deps/traits.php'; + + $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); + $m = $r->getMethod('getOrderedClasses'); + $m->setAccessible(true); + + $ordered = $m->invoke(null, ['CTFoo']); + + $this->assertEquals( + ['TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'], + array_map(function ($class) { return $class->getName(); }, $ordered) + ); + + $ordered = $m->invoke(null, ['CTBar']); + + $this->assertEquals( + ['TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'], + array_map(function ($class) { return $class->getName(); }, $ordered) + ); + } + + /** + * @dataProvider getDifferentOrders + */ + public function testClassReordering(array $classes) + { + $expected = [ + 'ClassesWithParents\\GInterface', + 'ClassesWithParents\\CInterface', + 'ClassesWithParents\\B', + 'ClassesWithParents\\A', + ]; + + $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); + $m = $r->getMethod('getOrderedClasses'); + $m->setAccessible(true); + + $ordered = $m->invoke(null, $classes); + + $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + } + + public function getDifferentOrders() + { + return [ + [[ + 'ClassesWithParents\\A', + 'ClassesWithParents\\CInterface', + 'ClassesWithParents\\GInterface', + 'ClassesWithParents\\B', + ]], + [[ + 'ClassesWithParents\\B', + 'ClassesWithParents\\A', + 'ClassesWithParents\\CInterface', + ]], + [[ + 'ClassesWithParents\\CInterface', + 'ClassesWithParents\\B', + 'ClassesWithParents\\A', + ]], + [[ + 'ClassesWithParents\\A', + ]], + ]; + } + + /** + * @dataProvider getDifferentOrdersForTraits + */ + public function testClassWithTraitsReordering(array $classes) + { + require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/D.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/E.php'; + + $expected = [ + 'ClassesWithParents\\GInterface', + 'ClassesWithParents\\CInterface', + 'ClassesWithParents\\ATrait', + 'ClassesWithParents\\BTrait', + 'ClassesWithParents\\CTrait', + 'ClassesWithParents\\B', + 'ClassesWithParents\\A', + 'ClassesWithParents\\D', + 'ClassesWithParents\\E', + ]; + + $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); + $m = $r->getMethod('getOrderedClasses'); + $m->setAccessible(true); + + $ordered = $m->invoke(null, $classes); + + $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + } + + public function getDifferentOrdersForTraits() + { + return [ + [[ + 'ClassesWithParents\\E', + 'ClassesWithParents\\ATrait', + ]], + [[ + 'ClassesWithParents\\E', + ]], + ]; + } + + public function testFixClassWithTraitsOrdering() + { + require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/F.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/G.php'; + + $classes = [ + 'ClassesWithParents\\F', + 'ClassesWithParents\\G', + ]; + + $expected = [ + 'ClassesWithParents\\CTrait', + 'ClassesWithParents\\F', + 'ClassesWithParents\\G', + ]; + + $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); + $m = $r->getMethod('getOrderedClasses'); + $m->setAccessible(true); + + $ordered = $m->invoke(null, $classes); + + $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + } + + /** + * @dataProvider getFixNamespaceDeclarationsData + */ + public function testFixNamespaceDeclarations($source, $expected) + { + $this->assertEquals('assertEquals('expectException('InvalidArgumentException'); + if (is_file($file = sys_get_temp_dir().'/foo.php')) { + unlink($file); + } + + ClassCollectionLoader::load(['SomeNotExistingClass'], sys_get_temp_dir(), 'foo', false); + } + + public function testCommentStripping() + { + if (is_file($file = __DIR__.'/bar.php')) { + unlink($file); + } + spl_autoload_register($r = function ($class) { + if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) { + @require_once __DIR__.'/Fixtures/'.str_replace(['\\', '_'], '/', $class).'.php'; + } + }); + + $strictTypes = \defined('HHVM_VERSION') ? '' : "\nnamespace {require __DIR__.'/Fixtures/Namespaced/WithStrictTypes.php';}"; + + ClassCollectionLoader::load( + ['Namespaced\\WithComments', 'Pearlike_WithComments', 'Namespaced\\WithDirMagic', 'Namespaced\\WithFileMagic', 'Namespaced\\WithHaltCompiler', $strictTypes ? 'Namespaced\\WithStrictTypes' : 'Namespaced\\WithComments'], + __DIR__, + 'bar', + false + ); + + spl_autoload_unregister($r); + + $this->assertEquals(<<<'EOF' +namespace Namespaced +{ +class WithComments +{ +public static $loaded = true; +} +$string ='string should not be modified {$string}'; +$heredoc = (<<assertTrue(class_exists(WarmedClass::class, true)); + + @unlink($cache = sys_get_temp_dir().'/inline.php'); + + $classes = [WarmedClass::class]; + $excluded = [DeclaredClass::class]; + + ClassCollectionLoader::inline($classes, $cache, $excluded); + + $this->assertSame(<<<'EOTXT' + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\ClassLoader\ClassLoader; + +/** + * @group legacy + */ +class ClassLoaderTest extends TestCase +{ + public function testGetPrefixes() + { + $loader = new ClassLoader(); + $loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Bar', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Bas', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $prefixes = $loader->getPrefixes(); + $this->assertArrayHasKey('Foo', $prefixes); + $this->assertArrayNotHasKey('Foo1', $prefixes); + $this->assertArrayHasKey('Bar', $prefixes); + $this->assertArrayHasKey('Bas', $prefixes); + } + + public function testGetFallbackDirs() + { + $loader = new ClassLoader(); + $loader->addPrefix(null, __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix(null, __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $fallback_dirs = $loader->getFallbackDirs(); + $this->assertCount(2, $fallback_dirs); + } + + /** + * @dataProvider getLoadClassTests + */ + public function testLoadClass($className, $testClassName, $message) + { + $loader = new ClassLoader(); + $loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->loadClass($testClassName); + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassTests() + { + return [ + ['\\Namespaced2\\Foo', 'Namespaced2\\Foo', '->loadClass() loads Namespaced2\Foo class'], + ['\\Pearlike2_Foo', 'Pearlike2_Foo', '->loadClass() loads Pearlike2_Foo class'], + ]; + } + + /** + * @dataProvider getLoadNonexistentClassTests + */ + public function testLoadNonexistentClass($className, $testClassName, $message) + { + $loader = new ClassLoader(); + $loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->loadClass($testClassName); + $this->assertFalse(class_exists($className), $message); + } + + public function getLoadNonexistentClassTests() + { + return [ + ['\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'], + ]; + } + + public function testAddPrefixSingle() + { + $loader = new ClassLoader(); + $loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Foo', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $prefixes = $loader->getPrefixes(); + $this->assertArrayHasKey('Foo', $prefixes); + $this->assertCount(1, $prefixes['Foo']); + } + + public function testAddPrefixesSingle() + { + $loader = new ClassLoader(); + $loader->addPrefixes(['Foo' => ['foo', 'foo']]); + $loader->addPrefixes(['Foo' => ['foo']]); + $prefixes = $loader->getPrefixes(); + $this->assertArrayHasKey('Foo', $prefixes); + $this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true)); + } + + public function testAddPrefixMulti() + { + $loader = new ClassLoader(); + $loader->addPrefix('Foo', 'foo'); + $loader->addPrefix('Foo', 'bar'); + $prefixes = $loader->getPrefixes(); + $this->assertArrayHasKey('Foo', $prefixes); + $this->assertCount(2, $prefixes['Foo']); + $this->assertContains('foo', $prefixes['Foo']); + $this->assertContains('bar', $prefixes['Foo']); + } + + public function testUseIncludePath() + { + $loader = new ClassLoader(); + $this->assertFalse($loader->getUseIncludePath()); + + $this->assertNull($loader->findFile('Foo')); + + $includePath = get_include_path(); + + $loader->setUseIncludePath(true); + $this->assertTrue($loader->getUseIncludePath()); + + set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath); + + $this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'includepath'.\DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo')); + + set_include_path($includePath); + } + + /** + * @dataProvider getLoadClassFromFallbackTests + */ + public function testLoadClassFromFallback($className, $testClassName, $message) + { + $loader = new ClassLoader(); + $loader->addPrefix('Namespaced2\\', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('Pearlike2_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'); + $loader->addPrefix('', [__DIR__.\DIRECTORY_SEPARATOR.'Fixtures/fallback']); + $loader->loadClass($testClassName); + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassFromFallbackTests() + { + return [ + ['\\Namespaced2\\Baz', 'Namespaced2\\Baz', '->loadClass() loads Namespaced2\Baz class'], + ['\\Pearlike2_Baz', 'Pearlike2_Baz', '->loadClass() loads Pearlike2_Baz class'], + ['\\Namespaced2\\FooBar', 'Namespaced2\\FooBar', '->loadClass() loads Namespaced2\Baz class from fallback dir'], + ['\\Pearlike2_FooBar', 'Pearlike2_FooBar', '->loadClass() loads Pearlike2_Baz class from fallback dir'], + ]; + } + + /** + * @dataProvider getLoadClassNamespaceCollisionTests + */ + public function testLoadClassNamespaceCollision($namespaces, $className, $message) + { + $loader = new ClassLoader(); + $loader->addPrefixes($namespaces); + + $loader->loadClass($className); + $this->assertTrue(class_exists($className), $message); + } + + public function getLoadClassNamespaceCollisionTests() + { + return [ + [ + [ + 'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + 'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + ], + 'NamespaceCollision\C\Foo', + '->loadClass() loads NamespaceCollision\C\Foo from alpha.', + ], + [ + [ + 'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + 'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + ], + 'NamespaceCollision\C\Bar', + '->loadClass() loads NamespaceCollision\C\Bar from alpha.', + ], + [ + [ + 'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + 'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + ], + 'NamespaceCollision\C\B\Foo', + '->loadClass() loads NamespaceCollision\C\B\Foo from beta.', + ], + [ + [ + 'NamespaceCollision\\C\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + 'NamespaceCollision\\C' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + ], + 'NamespaceCollision\C\B\Bar', + '->loadClass() loads NamespaceCollision\C\B\Bar from beta.', + ], + [ + [ + 'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + 'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + ], + 'PrefixCollision_C_Foo', + '->loadClass() loads PrefixCollision_C_Foo from alpha.', + ], + [ + [ + 'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + 'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + ], + 'PrefixCollision_C_Bar', + '->loadClass() loads PrefixCollision_C_Bar from alpha.', + ], + [ + [ + 'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + 'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + ], + 'PrefixCollision_C_B_Foo', + '->loadClass() loads PrefixCollision_C_B_Foo from beta.', + ], + [ + [ + 'PrefixCollision_C_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/beta', + 'PrefixCollision_C_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/alpha', + ], + 'PrefixCollision_C_B_Bar', + '->loadClass() loads PrefixCollision_C_B_Bar from beta.', + ], + ]; + } +} diff --git a/lib/symfony/class-loader/Tests/ClassMapGeneratorTest.php b/lib/symfony/class-loader/Tests/ClassMapGeneratorTest.php new file mode 100644 index 000000000..911066018 --- /dev/null +++ b/lib/symfony/class-loader/Tests/ClassMapGeneratorTest.php @@ -0,0 +1,151 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\ClassLoader\ClassMapGenerator; + +/** + * @group legacy + */ +class ClassMapGeneratorTest extends TestCase +{ + /** + * @var string|null + */ + private $workspace = null; + + public function prepare_workspace() + { + $this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand(); + mkdir($this->workspace, 0777, true); + $this->workspace = realpath($this->workspace); + } + + /** + * @param string $file + */ + private function clean($file) + { + if (is_dir($file) && !is_link($file)) { + $dir = new \FilesystemIterator($file); + foreach ($dir as $childFile) { + $this->clean($childFile); + } + + rmdir($file); + } else { + unlink($file); + } + } + + /** + * @dataProvider getTestCreateMapTests + */ + public function testDump($directory) + { + $this->prepare_workspace(); + + $file = $this->workspace.'/file'; + + $generator = new ClassMapGenerator(); + $generator->dump($directory, $file); + $this->assertFileExists($file); + + $this->clean($this->workspace); + } + + /** + * @dataProvider getTestCreateMapTests + */ + public function testCreateMap($directory, $expected) + { + $this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory)); + } + + public function getTestCreateMapTests() + { + $data = [ + [__DIR__.'/Fixtures/Namespaced', [ + 'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php', + 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', + 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', + 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', + 'Namespaced\\WithStrictTypes' => realpath(__DIR__).'/Fixtures/Namespaced/WithStrictTypes.php', + 'Namespaced\\WithHaltCompiler' => realpath(__DIR__).'/Fixtures/Namespaced/WithHaltCompiler.php', + 'Namespaced\\WithDirMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithDirMagic.php', + 'Namespaced\\WithFileMagic' => realpath(__DIR__).'/Fixtures/Namespaced/WithFileMagic.php', + ]], + [__DIR__.'/Fixtures/beta/NamespaceCollision', [ + 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', + 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php', + 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php', + 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php', + ]], + [__DIR__.'/Fixtures/Pearlike', [ + 'Pearlike_Foo' => realpath(__DIR__).'/Fixtures/Pearlike/Foo.php', + 'Pearlike_Bar' => realpath(__DIR__).'/Fixtures/Pearlike/Bar.php', + 'Pearlike_Baz' => realpath(__DIR__).'/Fixtures/Pearlike/Baz.php', + 'Pearlike_WithComments' => realpath(__DIR__).'/Fixtures/Pearlike/WithComments.php', + ]], + [__DIR__.'/Fixtures/classmap', [ + 'Foo\\Bar\\A' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php', + 'Foo\\Bar\\B' => realpath(__DIR__).'/Fixtures/classmap/sameNsMultipleClasses.php', + 'A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', + 'Alpha\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', + 'Alpha\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', + 'Beta\\A' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', + 'Beta\\B' => realpath(__DIR__).'/Fixtures/classmap/multipleNs.php', + 'ClassMap\\SomeInterface' => realpath(__DIR__).'/Fixtures/classmap/SomeInterface.php', + 'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php', + 'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php', + ]], + [__DIR__.'/Fixtures/php5.4', [ + 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', + 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', + 'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php', + 'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php', + 'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php', + 'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php', + ]], + [__DIR__.'/Fixtures/php5.5', [ + 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', + ]], + ]; + + return $data; + } + + public function testCreateMapFinderSupport() + { + $finder = new \Symfony\Component\Finder\Finder(); + $finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision'); + + $this->assertEqualsNormalized([ + 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', + 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php', + 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Bar.php', + 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/C/B/Foo.php', + ], ClassMapGenerator::createMap($finder)); + } + + protected function assertEqualsNormalized($expected, $actual, $message = '') + { + foreach ($expected as $ns => $path) { + $expected[$ns] = str_replace('\\', '/', $path); + } + foreach ($actual as $ns => $path) { + $actual[$ns] = str_replace('\\', '/', $path); + } + $this->assertEquals($expected, $actual, $message); + } +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php new file mode 100644 index 000000000..4259f1451 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Bar.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\Namespaced; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php new file mode 100644 index 000000000..3ddb595e2 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Baz.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\Namespaced; + +class Baz +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php new file mode 100644 index 000000000..cf0a4b741 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\Namespaced; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php new file mode 100644 index 000000000..bbbc81515 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/Namespaced/FooBar.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\Namespaced; + +class FooBar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php new file mode 100644 index 000000000..e774cb9bf --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/Pearlike/Bar.php @@ -0,0 +1,6 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\NamespaceCollision\A; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php new file mode 100644 index 000000000..184a1b1da --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/alpha/Apc/NamespaceCollision/A/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\NamespaceCollision\A; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php new file mode 100644 index 000000000..3892f7068 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/ApcPrefixCollision/A/B/Bar.php @@ -0,0 +1,6 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\NamespaceCollision\A\B; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php new file mode 100644 index 000000000..450eeb50b --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/beta/Apc/NamespaceCollision/A/B/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\NamespaceCollision\A\B; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php b/lib/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php new file mode 100644 index 000000000..96f2f76c6 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Apc/fallback/Apc/Pearlike/FooBar.php @@ -0,0 +1,6 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Apc\Namespaced; + +class FooBar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php b/lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php new file mode 100644 index 000000000..b0f942595 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/ClassesWithParents/A.php @@ -0,0 +1,7 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Namespaced; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php new file mode 100644 index 000000000..0b0bbd057 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Baz.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Namespaced; + +class Baz +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php new file mode 100644 index 000000000..df5e1f4ce --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Namespaced; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php new file mode 100644 index 000000000..361e53de1 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Namespaced/WithComments.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Namespaced; + +class WithComments +{ + /** @Boolean */ + public static $loaded = true; +} + +$string = 'string should not be modified {$string}'; + +$heredoc = (<< + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class Pearlike_WithComments +{ + /** @Boolean */ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php new file mode 100644 index 000000000..7f5f79773 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/Pearlike2/Bar.php @@ -0,0 +1,6 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace NamespaceCollision\A; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php new file mode 100644 index 000000000..aee6a080d --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/A/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace NamespaceCollision\A; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php new file mode 100644 index 000000000..c1b8dd65d --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/alpha/NamespaceCollision/C/Bar.php @@ -0,0 +1,8 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace NamespaceCollision\A\B; + +class Bar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php b/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php new file mode 100644 index 000000000..f5f2d727e --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/A/B/Foo.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace NamespaceCollision\A\B; + +class Foo +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php b/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php new file mode 100644 index 000000000..4bb03dc7f --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/beta/NamespaceCollision/C/B/Bar.php @@ -0,0 +1,8 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ClassMap; + +class SomeClass extends SomeParent implements SomeInterface +{ +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php b/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php new file mode 100644 index 000000000..1fe5e09aa --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeInterface.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ClassMap; + +interface SomeInterface +{ +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php b/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php new file mode 100644 index 000000000..ce2f9fc6c --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/classmap/SomeParent.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ClassMap; + +abstract class SomeParent +{ +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php b/lib/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php new file mode 100644 index 000000000..c7cec646f --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/classmap/multipleNs.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Foo\Bar; + +class A +{ +} +class B +{ +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/deps/traits.php b/lib/symfony/class-loader/Tests/Fixtures/deps/traits.php new file mode 100644 index 000000000..82b30a6f9 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/deps/traits.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Namespaced; + +class FooBar +{ + public static $loaded = true; +} diff --git a/lib/symfony/class-loader/Tests/Fixtures/fallback/Namespaced2/FooBar.php b/lib/symfony/class-loader/Tests/Fixtures/fallback/Namespaced2/FooBar.php new file mode 100644 index 000000000..1036d4359 --- /dev/null +++ b/lib/symfony/class-loader/Tests/Fixtures/fallback/Namespaced2/FooBar.php @@ -0,0 +1,8 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\ClassLoader\Psr4ClassLoader; + +/** + * @group legacy + */ +class Psr4ClassLoaderTest extends TestCase +{ + /** + * @param string $className + * @dataProvider getLoadClassTests + */ + public function testLoadClass($className) + { + $loader = new Psr4ClassLoader(); + $loader->addPrefix( + 'Acme\\DemoLib', + __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'psr-4' + ); + $loader->loadClass($className); + $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className)); + } + + /** + * @return array + */ + public function getLoadClassTests() + { + return [ + ['Acme\\DemoLib\\Foo'], + ['Acme\\DemoLib\\Class_With_Underscores'], + ['Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'], + ['Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'], + ]; + } + + /** + * @param string $className + * @dataProvider getLoadNonexistentClassTests + */ + public function testLoadNonexistentClass($className) + { + $loader = new Psr4ClassLoader(); + $loader->addPrefix( + 'Acme\\DemoLib', + __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'psr-4' + ); + $loader->loadClass($className); + $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className)); + } + + /** + * @return array + */ + public function getLoadNonexistentClassTests() + { + return [ + ['Acme\\DemoLib\\I_Do_Not_Exist'], + ['UnknownVendor\\SomeLib\\I_Do_Not_Exist'], + ]; + } +} diff --git a/lib/symfony/config/Tests/ConfigCacheFactoryTest.php b/lib/symfony/config/Tests/ConfigCacheFactoryTest.php new file mode 100644 index 000000000..6190b9b45 --- /dev/null +++ b/lib/symfony/config/Tests/ConfigCacheFactoryTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\ConfigCacheFactory; + +class ConfigCacheFactoryTest extends TestCase +{ + public function testCacheWithInvalidCallback() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Invalid type for callback argument. Expected callable, but got "object".'); + $cacheFactory = new ConfigCacheFactory(true); + + $cacheFactory->cache('file', new \stdClass()); + } +} diff --git a/lib/symfony/config/Tests/ConfigCacheTest.php b/lib/symfony/config/Tests/ConfigCacheTest.php new file mode 100644 index 000000000..d0b70899b --- /dev/null +++ b/lib/symfony/config/Tests/ConfigCacheTest.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\ConfigCache; +use Symfony\Component\Config\Tests\Resource\ResourceStub; + +class ConfigCacheTest extends TestCase +{ + private $cacheFile = null; + + protected function setUp() + { + $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_'); + } + + protected function tearDown() + { + $files = [$this->cacheFile, $this->cacheFile.'.meta']; + + foreach ($files as $file) { + if (file_exists($file)) { + unlink($file); + } + } + } + + /** + * @dataProvider debugModes + */ + public function testCacheIsNotValidIfNothingHasBeenCached($debug) + { + unlink($this->cacheFile); // remove tempnam() side effect + $cache = new ConfigCache($this->cacheFile, $debug); + + $this->assertFalse($cache->isFresh()); + } + + public function testIsAlwaysFreshInProduction() + { + $staleResource = new ResourceStub(); + $staleResource->setFresh(false); + + $cache = new ConfigCache($this->cacheFile, false); + $cache->write('', [$staleResource]); + + $this->assertTrue($cache->isFresh()); + } + + /** + * @dataProvider debugModes + */ + public function testIsFreshWhenNoResourceProvided($debug) + { + $cache = new ConfigCache($this->cacheFile, $debug); + $cache->write('', []); + $this->assertTrue($cache->isFresh()); + } + + public function testFreshResourceInDebug() + { + $freshResource = new ResourceStub(); + $freshResource->setFresh(true); + + $cache = new ConfigCache($this->cacheFile, true); + $cache->write('', [$freshResource]); + + $this->assertTrue($cache->isFresh()); + } + + public function testStaleResourceInDebug() + { + $staleResource = new ResourceStub(); + $staleResource->setFresh(false); + + $cache = new ConfigCache($this->cacheFile, true); + $cache->write('', [$staleResource]); + + $this->assertFalse($cache->isFresh()); + } + + public function debugModes() + { + return [ + [true], + [false], + ]; + } +} diff --git a/lib/symfony/config/Tests/Definition/ArrayNodeTest.php b/lib/symfony/config/Tests/Definition/ArrayNodeTest.php new file mode 100644 index 000000000..25c2cfc69 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/ArrayNodeTest.php @@ -0,0 +1,237 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; +use Symfony\Component\Config\Definition\ScalarNode; + +class ArrayNodeTest extends TestCase +{ + public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $node = new ArrayNode('root'); + $node->normalize(false); + } + + public function testExceptionThrownOnUnrecognizedChild() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('Unrecognized option "foo" under "root"'); + $node = new ArrayNode('root'); + $node->normalize(['foo' => 'bar']); + } + + public function ignoreAndRemoveMatrixProvider() + { + $unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"'); + + return [ + [true, true, [], 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'], + [true, false, ['foo' => 'bar'], 'extra keys are not removed when ignoreExtraKeys second option is set to false'], + [false, true, $unrecognizedOptionException], + [false, false, $unrecognizedOptionException], + ]; + } + + /** + * @dataProvider ignoreAndRemoveMatrixProvider + */ + public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '') + { + if ($expected instanceof \Exception) { + $this->expectException(\get_class($expected)); + $this->expectExceptionMessage($expected->getMessage()); + } + $node = new ArrayNode('root'); + $node->setIgnoreExtraKeys($ignore, $remove); + $result = $node->normalize(['foo' => 'bar']); + $this->assertSame($expected, $result, $message); + } + + /** + * @dataProvider getPreNormalizationTests + */ + public function testPreNormalize($denormalized, $normalized) + { + $node = new ArrayNode('foo'); + + $r = new \ReflectionMethod($node, 'preNormalize'); + $r->setAccessible(true); + + $this->assertSame($normalized, $r->invoke($node, $denormalized)); + } + + public function getPreNormalizationTests() + { + return [ + [ + ['foo-bar' => 'foo'], + ['foo_bar' => 'foo'], + ], + [ + ['foo-bar_moo' => 'foo'], + ['foo-bar_moo' => 'foo'], + ], + [ + ['anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'], + ['anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'], + ], + [ + ['foo-bar' => null, 'foo_bar' => 'foo'], + ['foo-bar' => null, 'foo_bar' => 'foo'], + ], + ]; + } + + /** + * @dataProvider getZeroNamedNodeExamplesData + */ + public function testNodeNameCanBeZero($denormalized, $normalized) + { + $zeroNode = new ArrayNode(0); + $zeroNode->addChild(new ScalarNode('name')); + $fiveNode = new ArrayNode(5); + $fiveNode->addChild(new ScalarNode(0)); + $fiveNode->addChild(new ScalarNode('new_key')); + $rootNode = new ArrayNode('root'); + $rootNode->addChild($zeroNode); + $rootNode->addChild($fiveNode); + $rootNode->addChild(new ScalarNode('string_key')); + $r = new \ReflectionMethod($rootNode, 'normalizeValue'); + $r->setAccessible(true); + + $this->assertSame($normalized, $r->invoke($rootNode, $denormalized)); + } + + public function getZeroNamedNodeExamplesData() + { + return [ + [ + [ + 0 => [ + 'name' => 'something', + ], + 5 => [ + 0 => 'this won\'t work too', + 'new_key' => 'some other value', + ], + 'string_key' => 'just value', + ], + [ + 0 => [ + 'name' => 'something', + ], + 5 => [ + 0 => 'this won\'t work too', + 'new_key' => 'some other value', + ], + 'string_key' => 'just value', + ], + ], + ]; + } + + /** + * @dataProvider getPreNormalizedNormalizedOrderedData + */ + public function testChildrenOrderIsMaintainedOnNormalizeValue($prenormalized, $normalized) + { + $scalar1 = new ScalarNode('1'); + $scalar2 = new ScalarNode('2'); + $scalar3 = new ScalarNode('3'); + $node = new ArrayNode('foo'); + $node->addChild($scalar1); + $node->addChild($scalar3); + $node->addChild($scalar2); + + $r = new \ReflectionMethod($node, 'normalizeValue'); + $r->setAccessible(true); + + $this->assertSame($normalized, $r->invoke($node, $prenormalized)); + } + + public function getPreNormalizedNormalizedOrderedData() + { + return [ + [ + ['2' => 'two', '1' => 'one', '3' => 'three'], + ['2' => 'two', '1' => 'one', '3' => 'three'], + ], + ]; + } + + public function testAddChildEmptyName() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Child nodes must be named.'); + $node = new ArrayNode('root'); + + $childNode = new ArrayNode(''); + $node->addChild($childNode); + } + + public function testAddChildNameAlreadyExists() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('A child node named "foo" already exists.'); + $node = new ArrayNode('root'); + + $childNode = new ArrayNode('foo'); + $node->addChild($childNode); + + $childNodeWithSameName = new ArrayNode('foo'); + $node->addChild($childNodeWithSameName); + } + + public function testGetDefaultValueWithoutDefaultValue() + { + $this->expectException('RuntimeException'); + $this->expectExceptionMessage('The node at path "foo" has no default value.'); + $node = new ArrayNode('foo'); + $node->getDefaultValue(); + } + + public function testSetDeprecated() + { + $childNode = new ArrayNode('foo'); + $childNode->setDeprecated('"%node%" is deprecated'); + + $this->assertTrue($childNode->isDeprecated()); + $this->assertSame('"foo" is deprecated', $childNode->getDeprecationMessage($childNode->getName(), $childNode->getPath())); + + $node = new ArrayNode('root'); + $node->addChild($childNode); + + $deprecationTriggered = false; + $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { + if (E_USER_DEPRECATED === $level) { + return $deprecationTriggered = true; + } + + return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; + }; + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize([]); + restore_error_handler(); + + $this->assertFalse($deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize(['foo' => []]); + restore_error_handler(); + $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); + } +} diff --git a/lib/symfony/config/Tests/Definition/BooleanNodeTest.php b/lib/symfony/config/Tests/Definition/BooleanNodeTest.php new file mode 100644 index 000000000..8552eeba3 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/BooleanNodeTest.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\BooleanNode; + +class BooleanNodeTest extends TestCase +{ + /** + * @dataProvider getValidValues + */ + public function testNormalize($value) + { + $node = new BooleanNode('test'); + $this->assertSame($value, $node->normalize($value)); + } + + /** + * @dataProvider getValidValues + * + * @param bool $value + */ + public function testValidNonEmptyValues($value) + { + $node = new BooleanNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + + public function getValidValues() + { + return [ + [false], + [true], + ]; + } + + /** + * @dataProvider getInvalidValues + */ + public function testNormalizeThrowsExceptionOnInvalidValues($value) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $node = new BooleanNode('test'); + $node->normalize($value); + } + + public function getInvalidValues() + { + return [ + [null], + [''], + ['foo'], + [0], + [1], + [0.0], + [0.1], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/lib/symfony/config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php new file mode 100644 index 000000000..1123b4159 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -0,0 +1,362 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; +use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition; +use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; +use Symfony\Component\Config\Definition\Processor; + +class ArrayNodeDefinitionTest extends TestCase +{ + public function testAppendingSomeNode() + { + $parent = new ArrayNodeDefinition('root'); + $child = new ScalarNodeDefinition('child'); + + $parent + ->children() + ->scalarNode('foo')->end() + ->scalarNode('bar')->end() + ->end() + ->append($child); + + $this->assertCount(3, $this->getField($parent, 'children')); + $this->assertContains($child, $this->getField($parent, 'children')); + } + + /** + * @dataProvider providePrototypeNodeSpecificCalls + */ + public function testPrototypeNodeSpecificOption($method, $args) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $node = new ArrayNodeDefinition('root'); + + \call_user_func_array([$node, $method], $args); + + $node->getNode(); + } + + public function providePrototypeNodeSpecificCalls() + { + return [ + ['defaultValue', [[]]], + ['addDefaultChildrenIfNoneSet', []], + ['requiresAtLeastOneElement', []], + ['useAttributeAsKey', ['foo']], + ]; + } + + public function testConcreteNodeSpecificOption() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $node = new ArrayNodeDefinition('root'); + $node + ->addDefaultsIfNotSet() + ->prototype('array') + ; + $node->getNode(); + } + + public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $node = new ArrayNodeDefinition('root'); + $node + ->defaultValue([]) + ->addDefaultChildrenIfNoneSet('foo') + ->prototype('array') + ; + $node->getNode(); + } + + public function testPrototypedArrayNodeDefaultWhenUsingDefaultChildren() + { + $node = new ArrayNodeDefinition('root'); + $node + ->addDefaultChildrenIfNoneSet() + ->prototype('array') + ; + $tree = $node->getNode(); + $this->assertEquals([[]], $tree->getDefaultValue()); + } + + /** + * @dataProvider providePrototypedArrayNodeDefaults + */ + public function testPrototypedArrayNodeDefault($args, $shouldThrowWhenUsingAttrAsKey, $shouldThrowWhenNotUsingAttrAsKey, $defaults) + { + $node = new ArrayNodeDefinition('root'); + $node + ->addDefaultChildrenIfNoneSet($args) + ->prototype('array') + ; + + try { + $tree = $node->getNode(); + $this->assertFalse($shouldThrowWhenNotUsingAttrAsKey); + $this->assertEquals($defaults, $tree->getDefaultValue()); + } catch (InvalidDefinitionException $e) { + $this->assertTrue($shouldThrowWhenNotUsingAttrAsKey); + } + + $node = new ArrayNodeDefinition('root'); + $node + ->useAttributeAsKey('attr') + ->addDefaultChildrenIfNoneSet($args) + ->prototype('array') + ; + + try { + $tree = $node->getNode(); + $this->assertFalse($shouldThrowWhenUsingAttrAsKey); + $this->assertEquals($defaults, $tree->getDefaultValue()); + } catch (InvalidDefinitionException $e) { + $this->assertTrue($shouldThrowWhenUsingAttrAsKey); + } + } + + public function providePrototypedArrayNodeDefaults() + { + return [ + [null, true, false, [[]]], + [2, true, false, [[], []]], + ['2', false, true, ['2' => []]], + ['foo', false, true, ['foo' => []]], + [['foo'], false, true, ['foo' => []]], + [['foo', 'bar'], false, true, ['foo' => [], 'bar' => []]], + ]; + } + + public function testNestedPrototypedArrayNodes() + { + $nodeDefinition = new ArrayNodeDefinition('root'); + $nodeDefinition + ->addDefaultChildrenIfNoneSet() + ->prototype('array') + ->prototype('array') + ; + $node = $nodeDefinition->getNode(); + + $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node); + $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node->getPrototype()); + } + + public function testEnabledNodeDefaults() + { + $node = new ArrayNodeDefinition('root'); + $node + ->canBeEnabled() + ->children() + ->scalarNode('foo')->defaultValue('bar')->end() + ; + + $this->assertEquals(['enabled' => false, 'foo' => 'bar'], $node->getNode()->getDefaultValue()); + } + + /** + * @dataProvider getEnableableNodeFixtures + */ + public function testTrueEnableEnabledNode($expected, $config, $message) + { + $processor = new Processor(); + $node = new ArrayNodeDefinition('root'); + $node + ->canBeEnabled() + ->children() + ->scalarNode('foo')->defaultValue('bar')->end() + ; + + $this->assertEquals( + $expected, + $processor->process($node->getNode(), $config), + $message + ); + } + + public function testCanBeDisabled() + { + $node = new ArrayNodeDefinition('root'); + $node->canBeDisabled(); + + $this->assertTrue($this->getField($node, 'addDefaults')); + $this->assertEquals(['enabled' => false], $this->getField($node, 'falseEquivalent')); + $this->assertEquals(['enabled' => true], $this->getField($node, 'trueEquivalent')); + $this->assertEquals(['enabled' => true], $this->getField($node, 'nullEquivalent')); + + $nodeChildren = $this->getField($node, 'children'); + $this->assertArrayHasKey('enabled', $nodeChildren); + + $enabledNode = $nodeChildren['enabled']; + $this->assertTrue($this->getField($enabledNode, 'default')); + $this->assertTrue($this->getField($enabledNode, 'defaultValue')); + } + + public function testIgnoreExtraKeys() + { + $node = new ArrayNodeDefinition('root'); + + $this->assertFalse($this->getField($node, 'ignoreExtraKeys')); + + $result = $node->ignoreExtraKeys(); + + $this->assertEquals($node, $result); + $this->assertTrue($this->getField($node, 'ignoreExtraKeys')); + } + + public function testNormalizeKeys() + { + $node = new ArrayNodeDefinition('root'); + + $this->assertTrue($this->getField($node, 'normalizeKeys')); + + $result = $node->normalizeKeys(false); + + $this->assertEquals($node, $result); + $this->assertFalse($this->getField($node, 'normalizeKeys')); + } + + public function testUnsetChild() + { + $node = new ArrayNodeDefinition('root'); + $node + ->children() + ->scalarNode('value') + ->beforeNormalization() + ->ifTrue(function ($value) { + return empty($value); + }) + ->thenUnset() + ->end() + ->end() + ->end() + ; + + $this->assertSame([], $node->getNode()->normalize(['value' => null])); + } + + public function testPrototypeVariable() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('variable'), $node->variablePrototype()); + } + + public function testPrototypeScalar() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('scalar'), $node->scalarPrototype()); + } + + public function testPrototypeBoolean() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('boolean'), $node->booleanPrototype()); + } + + public function testPrototypeInteger() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('integer'), $node->integerPrototype()); + } + + public function testPrototypeFloat() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('float'), $node->floatPrototype()); + } + + public function testPrototypeArray() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('array'), $node->arrayPrototype()); + } + + public function testPrototypeEnum() + { + $node = new ArrayNodeDefinition('root'); + $this->assertEquals($node->prototype('enum'), $node->enumPrototype()); + } + + public function getEnableableNodeFixtures() + { + return [ + [['enabled' => true, 'foo' => 'bar'], [true], 'true enables an enableable node'], + [['enabled' => true, 'foo' => 'bar'], [null], 'null enables an enableable node'], + [['enabled' => true, 'foo' => 'bar'], [['enabled' => true]], 'An enableable node can be enabled'], + [['enabled' => true, 'foo' => 'baz'], [['foo' => 'baz']], 'any configuration enables an enableable node'], + [['enabled' => false, 'foo' => 'baz'], [['foo' => 'baz', 'enabled' => false]], 'An enableable node can be disabled'], + [['enabled' => false, 'foo' => 'bar'], [false], 'false disables an enableable node'], + ]; + } + + public function testRequiresAtLeastOneElement() + { + $node = new ArrayNodeDefinition('root'); + $node + ->requiresAtLeastOneElement() + ->integerPrototype(); + + $node->getNode()->finalize([1]); + + $this->addToAssertionCount(1); + } + + /** + * @group legacy + * @expectedDeprecation Using Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::cannotBeEmpty() at path "root" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same. + */ + public function testCannotBeEmpty() + { + $node = new ArrayNodeDefinition('root'); + $node + ->cannotBeEmpty() + ->integerPrototype(); + + $node->getNode()->finalize([]); + } + + public function testSetDeprecated() + { + $node = new ArrayNodeDefinition('root'); + $node + ->children() + ->arrayNode('foo')->setDeprecated('The "%path%" node is deprecated.')->end() + ->end() + ; + $deprecatedNode = $node->getNode()->getChildren()['foo']; + + $this->assertTrue($deprecatedNode->isDeprecated()); + $this->assertSame('The "root.foo" node is deprecated.', $deprecatedNode->getDeprecationMessage($deprecatedNode->getName(), $deprecatedNode->getPath())); + } + + /** + * @group legacy + * @expectedDeprecation ->cannotBeEmpty() is not applicable to concrete nodes at path "root". In 4.0 it will throw an exception. + */ + public function testCannotBeEmptyOnConcreteNode() + { + $node = new ArrayNodeDefinition('root'); + $node->cannotBeEmpty(); + + $node->getNode()->finalize([]); + } + + protected function getField($object, $field) + { + $reflection = new \ReflectionProperty($object, $field); + $reflection->setAccessible(true); + + return $reflection->getValue($object); + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php b/lib/symfony/config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php new file mode 100644 index 000000000..6f568a2df --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition; + +class BooleanNodeDefinitionTest extends TestCase +{ + public function testCannotBeEmptyThrowsAnException() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.'); + $def = new BooleanNodeDefinition('foo'); + $def->cannotBeEmpty(); + } + + public function testSetDeprecated() + { + $def = new BooleanNodeDefinition('foo'); + $def->setDeprecated('The "%path%" node is deprecated.'); + + $node = $def->getNode(); + + $this->assertTrue($node->isDeprecated()); + $this->assertSame('The "foo" node is deprecated.', $node->getDeprecationMessage($node->getName(), $node->getPath())); + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/lib/symfony/config/Tests/Definition/Builder/EnumNodeDefinitionTest.php new file mode 100644 index 000000000..2e43a1354 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/EnumNodeDefinitionTest.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition; + +class EnumNodeDefinitionTest extends TestCase +{ + public function testWithOneValue() + { + $def = new EnumNodeDefinition('foo'); + $def->values(['foo']); + + $node = $def->getNode(); + $this->assertEquals(['foo'], $node->getValues()); + } + + public function testWithOneDistinctValue() + { + $def = new EnumNodeDefinition('foo'); + $def->values(['foo', 'foo']); + + $node = $def->getNode(); + $this->assertEquals(['foo'], $node->getValues()); + } + + public function testNoValuesPassed() + { + $this->expectException('RuntimeException'); + $this->expectExceptionMessage('You must call ->values() on enum nodes.'); + $def = new EnumNodeDefinition('foo'); + $def->getNode(); + } + + public function testWithNoValues() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('->values() must be called with at least one value.'); + $def = new EnumNodeDefinition('foo'); + $def->values([]); + } + + public function testGetNode() + { + $def = new EnumNodeDefinition('foo'); + $def->values(['foo', 'bar']); + + $node = $def->getNode(); + $this->assertEquals(['foo', 'bar'], $node->getValues()); + } + + public function testSetDeprecated() + { + $def = new EnumNodeDefinition('foo'); + $def->values(['foo', 'bar']); + $def->setDeprecated('The "%path%" node is deprecated.'); + + $node = $def->getNode(); + + $this->assertTrue($node->isDeprecated()); + $this->assertSame('The "foo" node is deprecated.', $def->getNode()->getDeprecationMessage($node->getName(), $node->getPath())); + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/ExprBuilderTest.php b/lib/symfony/config/Tests/Definition/Builder/ExprBuilderTest.php new file mode 100644 index 000000000..85d0d3631 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/ExprBuilderTest.php @@ -0,0 +1,264 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; + +class ExprBuilderTest extends TestCase +{ + public function testAlwaysExpression() + { + $test = $this->getTestBuilder() + ->always($this->returnClosure('new_value')) + ->end(); + + $this->assertFinalizedValueIs('new_value', $test); + } + + public function testIfTrueExpression() + { + $test = $this->getTestBuilder() + ->ifTrue() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test, ['key' => true]); + + $test = $this->getTestBuilder() + ->ifTrue(function ($v) { return true; }) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + + $test = $this->getTestBuilder() + ->ifTrue(function ($v) { return false; }) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); + } + + public function testIfStringExpression() + { + $test = $this->getTestBuilder() + ->ifString() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + + $test = $this->getTestBuilder() + ->ifString() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs(45, $test, ['key' => 45]); + } + + public function testIfNullExpression() + { + $test = $this->getTestBuilder() + ->ifNull() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test, ['key' => null]); + + $test = $this->getTestBuilder() + ->ifNull() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); + } + + public function testIfEmptyExpression() + { + $test = $this->getTestBuilder() + ->ifEmpty() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test, ['key' => []]); + + $test = $this->getTestBuilder() + ->ifEmpty() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); + } + + public function testIfArrayExpression() + { + $test = $this->getTestBuilder() + ->ifArray() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test, ['key' => []]); + + $test = $this->getTestBuilder() + ->ifArray() + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); + } + + public function testIfInArrayExpression() + { + $test = $this->getTestBuilder() + ->ifInArray(['foo', 'bar', 'value']) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + + $test = $this->getTestBuilder() + ->ifInArray(['foo', 'bar']) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); + } + + public function testIfNotInArrayExpression() + { + $test = $this->getTestBuilder() + ->ifNotInArray(['foo', 'bar']) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + + $test = $this->getTestBuilder() + ->ifNotInArray(['foo', 'bar', 'value_from_config']) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + } + + public function testThenEmptyArrayExpression() + { + $test = $this->getTestBuilder() + ->ifString() + ->thenEmptyArray() + ->end(); + $this->assertFinalizedValueIs([], $test); + } + + /** + * @dataProvider castToArrayValues + */ + public function testcastToArrayExpression($configValue, $expectedValue) + { + $test = $this->getTestBuilder() + ->castToArray() + ->end(); + $this->assertFinalizedValueIs($expectedValue, $test, ['key' => $configValue]); + } + + public function castToArrayValues() + { + yield ['value', ['value']]; + yield [-3.14, [-3.14]]; + yield [null, [null]]; + yield [['value'], ['value']]; + } + + public function testThenInvalid() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $test = $this->getTestBuilder() + ->ifString() + ->thenInvalid('Invalid value') + ->end(); + $this->finalizeTestBuilder($test); + } + + public function testThenUnsetExpression() + { + $test = $this->getTestBuilder() + ->ifString() + ->thenUnset() + ->end(); + $this->assertEquals([], $this->finalizeTestBuilder($test)); + } + + public function testEndIfPartNotSpecified() + { + $this->expectException('RuntimeException'); + $this->expectExceptionMessage('You must specify an if part.'); + $this->getTestBuilder()->end(); + } + + public function testEndThenPartNotSpecified() + { + $this->expectException('RuntimeException'); + $this->expectExceptionMessage('You must specify a then part.'); + $builder = $this->getTestBuilder(); + $builder->ifPart = 'test'; + $builder->end(); + } + + /** + * Create a test treebuilder with a variable node, and init the validation. + * + * @return TreeBuilder + */ + protected function getTestBuilder() + { + $builder = new TreeBuilder(); + + return $builder + ->root('test') + ->children() + ->variableNode('key') + ->validate() + ; + } + + /** + * Close the validation process and finalize with the given config. + * + * @param TreeBuilder $testBuilder The tree builder to finalize + * @param array $config The config you want to use for the finalization, if nothing provided + * a simple ['key'=>'value'] will be used + * + * @return array The finalized config values + */ + protected function finalizeTestBuilder($testBuilder, $config = null) + { + return $testBuilder + ->end() + ->end() + ->end() + ->buildTree() + ->finalize(null === $config ? ['key' => 'value'] : $config) + ; + } + + /** + * Return a closure that will return the given value. + * + * @param mixed $val The value that the closure must return + * + * @return \Closure + */ + protected function returnClosure($val) + { + return function ($v) use ($val) { + return $val; + }; + } + + /** + * Assert that the given test builder, will return the given value. + * + * @param mixed $value The value to test + * @param TreeBuilder $treeBuilder The tree builder to finalize + * @param mixed $config The config values that new to be finalized + */ + protected function assertFinalizedValueIs($value, $treeBuilder, $config = null) + { + $this->assertEquals(['key' => $value], $this->finalizeTestBuilder($treeBuilder, $config)); + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/NodeBuilderTest.php b/lib/symfony/config/Tests/Definition/Builder/NodeBuilderTest.php new file mode 100644 index 000000000..5cc7cfea4 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/NodeBuilderTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder; +use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition; + +class NodeBuilderTest extends TestCase +{ + public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNodeType() + { + $this->expectException('RuntimeException'); + $builder = new BaseNodeBuilder(); + $builder->node('', 'foobar'); + } + + public function testThrowsAnExceptionWhenTheNodeClassIsNotFound() + { + $this->expectException('RuntimeException'); + $builder = new BaseNodeBuilder(); + $builder + ->setNodeClass('noclasstype', '\\foo\\bar\\noclass') + ->node('', 'noclasstype'); + } + + public function testAddingANewNodeType() + { + $class = __NAMESPACE__.'\\SomeNodeDefinition'; + + $builder = new BaseNodeBuilder(); + $node = $builder + ->setNodeClass('newtype', $class) + ->node('', 'newtype'); + + $this->assertInstanceOf($class, $node); + } + + public function testOverridingAnExistingNodeType() + { + $class = __NAMESPACE__.'\\SomeNodeDefinition'; + + $builder = new BaseNodeBuilder(); + $node = $builder + ->setNodeClass('variable', $class) + ->node('', 'variable'); + + $this->assertInstanceOf($class, $node); + } + + public function testNodeTypesAreNotCaseSensitive() + { + $builder = new BaseNodeBuilder(); + + $node1 = $builder->node('', 'VaRiAbLe'); + $node2 = $builder->node('', 'variable'); + + $this->assertInstanceOf(\get_class($node1), $node2); + + $builder->setNodeClass('CuStOm', __NAMESPACE__.'\\SomeNodeDefinition'); + + $node1 = $builder->node('', 'CUSTOM'); + $node2 = $builder->node('', 'custom'); + + $this->assertInstanceOf(\get_class($node1), $node2); + } + + public function testNumericNodeCreation() + { + $builder = new BaseNodeBuilder(); + + $node = $builder->integerNode('foo')->min(3)->max(5); + $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition', $node); + + $node = $builder->floatNode('bar')->min(3.0)->max(5.0); + $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\FloatNodeDefinition', $node); + } +} + +class SomeNodeDefinition extends BaseVariableNodeDefinition +{ +} diff --git a/lib/symfony/config/Tests/Definition/Builder/NumericNodeDefinitionTest.php b/lib/symfony/config/Tests/Definition/Builder/NumericNodeDefinitionTest.php new file mode 100644 index 000000000..aa938bbaa --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/NumericNodeDefinitionTest.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition; +use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition; + +class NumericNodeDefinitionTest extends TestCase +{ + public function testIncoherentMinAssertion() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('You cannot define a min(4) as you already have a max(3)'); + $def = new IntegerNodeDefinition('foo'); + $def->max(3)->min(4); + } + + public function testIncoherentMaxAssertion() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('You cannot define a max(2) as you already have a min(3)'); + $node = new IntegerNodeDefinition('foo'); + $node->min(3)->max(2); + } + + public function testIntegerMinAssertion() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The value 4 is too small for path "foo". Should be greater than or equal to 5'); + $def = new IntegerNodeDefinition('foo'); + $def->min(5)->getNode()->finalize(4); + } + + public function testIntegerMaxAssertion() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The value 4 is too big for path "foo". Should be less than or equal to 3'); + $def = new IntegerNodeDefinition('foo'); + $def->max(3)->getNode()->finalize(4); + } + + public function testIntegerValidMinMaxAssertion() + { + $def = new IntegerNodeDefinition('foo'); + $node = $def->min(3)->max(7)->getNode(); + $this->assertEquals(4, $node->finalize(4)); + } + + public function testFloatMinAssertion() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The value 400 is too small for path "foo". Should be greater than or equal to 500'); + $def = new FloatNodeDefinition('foo'); + $def->min(5E2)->getNode()->finalize(4e2); + } + + public function testFloatMaxAssertion() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The value 4.3 is too big for path "foo". Should be less than or equal to 0.3'); + $def = new FloatNodeDefinition('foo'); + $def->max(0.3)->getNode()->finalize(4.3); + } + + public function testFloatValidMinMaxAssertion() + { + $def = new FloatNodeDefinition('foo'); + $node = $def->min(3.0)->max(7e2)->getNode(); + $this->assertEquals(4.5, $node->finalize(4.5)); + } + + public function testCannotBeEmptyThrowsAnException() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.'); + $def = new IntegerNodeDefinition('foo'); + $def->cannotBeEmpty(); + } +} diff --git a/lib/symfony/config/Tests/Definition/Builder/TreeBuilderTest.php b/lib/symfony/config/Tests/Definition/Builder/TreeBuilderTest.php new file mode 100644 index 000000000..53c9c256b --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Builder/TreeBuilderTest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Builder; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder; + +class TreeBuilderTest extends TestCase +{ + public function testUsingACustomNodeBuilder() + { + $builder = new TreeBuilder(); + $root = $builder->root('custom', 'array', new CustomNodeBuilder()); + + $nodeBuilder = $root->children(); + + $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); + + $nodeBuilder = $nodeBuilder->arrayNode('deeper')->children(); + + $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); + } + + public function testOverrideABuiltInNodeType() + { + $builder = new TreeBuilder(); + $root = $builder->root('override', 'array', new CustomNodeBuilder()); + + $definition = $root->children()->variableNode('variable'); + + $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition', $definition); + } + + public function testAddANodeType() + { + $builder = new TreeBuilder(); + $root = $builder->root('override', 'array', new CustomNodeBuilder()); + + $definition = $root->children()->barNode('variable'); + + $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition', $definition); + } + + public function testCreateABuiltInNodeTypeWithACustomNodeBuilder() + { + $builder = new TreeBuilder(); + $root = $builder->root('builtin', 'array', new CustomNodeBuilder()); + + $definition = $root->children()->booleanNode('boolean'); + + $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition', $definition); + } + + public function testPrototypedArrayNodeUseTheCustomNodeBuilder() + { + $builder = new TreeBuilder(); + $root = $builder->root('override', 'array', new CustomNodeBuilder()); + + $root->prototype('bar')->end(); + + $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\BarNode', $root->getNode(true)->getPrototype()); + } + + public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren() + { + $builder = new TreeBuilder(); + + $builder->root('propagation') + ->children() + ->setNodeClass('extended', 'Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition') + ->node('foo', 'extended')->end() + ->arrayNode('child') + ->children() + ->node('foo', 'extended') + ->end() + ->end() + ->end() + ->end(); + + $node = $builder->buildTree(); + $children = $node->getChildren(); + + $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $children['foo']); + + $childChildren = $children['child']->getChildren(); + + $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $childChildren['foo']); + } + + public function testDefinitionInfoGetsTransferredToNode() + { + $builder = new TreeBuilder(); + + $builder->root('test')->info('root info') + ->children() + ->node('child', 'variable')->info('child info')->defaultValue('default') + ->end() + ->end(); + + $tree = $builder->buildTree(); + $children = $tree->getChildren(); + + $this->assertEquals('root info', $tree->getInfo()); + $this->assertEquals('child info', $children['child']->getInfo()); + } + + public function testDefinitionExampleGetsTransferredToNode() + { + $builder = new TreeBuilder(); + + $builder->root('test') + ->example(['key' => 'value']) + ->children() + ->node('child', 'variable')->info('child info')->defaultValue('default')->example('example') + ->end() + ->end(); + + $tree = $builder->buildTree(); + $children = $tree->getChildren(); + + $this->assertIsArray($tree->getExample()); + $this->assertEquals('example', $children['child']->getExample()); + } +} diff --git a/lib/symfony/config/Tests/Definition/Dumper/XmlReferenceDumperTest.php b/lib/symfony/config/Tests/Definition/Dumper/XmlReferenceDumperTest.php new file mode 100644 index 000000000..5bc961bab --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Dumper/XmlReferenceDumperTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Dumper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper; +use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; + +class XmlReferenceDumperTest extends TestCase +{ + public function testDumper() + { + $configuration = new ExampleConfiguration(); + + $dumper = new XmlReferenceDumper(); + $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); + } + + public function testNamespaceDumper() + { + $configuration = new ExampleConfiguration(); + + $dumper = new XmlReferenceDumper(); + $this->assertEquals(str_replace('http://example.org/schema/dic/acme_root', 'http://symfony.com/schema/dic/symfony', $this->getConfigurationAsString()), $dumper->dump($configuration, 'http://symfony.com/schema/dic/symfony')); + } + + private function getConfigurationAsString() + { + return str_replace("\n", PHP_EOL, <<<'EOL' + + + + + + + + + + + + + + scalar value + + + scalar value + + + + + + + + + + + + + + + + + + + + + + + + +EOL + ); + } +} diff --git a/lib/symfony/config/Tests/Definition/Dumper/YamlReferenceDumperTest.php b/lib/symfony/config/Tests/Definition/Dumper/YamlReferenceDumperTest.php new file mode 100644 index 000000000..3cb9121ba --- /dev/null +++ b/lib/symfony/config/Tests/Definition/Dumper/YamlReferenceDumperTest.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition\Dumper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; +use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; + +class YamlReferenceDumperTest extends TestCase +{ + public function testDumper() + { + $configuration = new ExampleConfiguration(); + + $dumper = new YamlReferenceDumper(); + + $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration)); + } + + public function provideDumpAtPath() + { + return [ + 'Regular node' => ['scalar_true', << ['array', << ['array.child2', << ['cms_pages.page', << ['cms_pages.page.locale', <<assertSame(trim($expected), trim($dumper->dumpAtPath($configuration, $path))); + } + + private function getConfigurationAsString() + { + return <<<'EOL' +acme_root: + boolean: true + scalar_empty: ~ + scalar_null: null + scalar_true: true + scalar_false: false + scalar_default: default + scalar_array_empty: [] + scalar_array_defaults: + + # Defaults: + - elem1 + - elem2 + scalar_required: ~ # Required + scalar_deprecated: ~ # Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.) + scalar_deprecated_with_message: ~ # Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") + node_with_a_looong_name: ~ + enum_with_default: this # One of "this"; "that" + enum: ~ # One of "this"; "that" + + # some info + array: + child1: ~ + child2: ~ + + # this is a long + # multi-line info text + # which should be indented + child3: ~ # Example: example setting + scalar_prototyped: [] + parameters: + + # Prototype: Parameter name + name: ~ + connections: + + # Prototype + - + user: ~ + pass: ~ + cms_pages: + + # Prototype + page: + + # Prototype + locale: + title: ~ # Required + path: ~ # Required + pipou: + + # Prototype + name: [] + +EOL; + } +} diff --git a/lib/symfony/config/Tests/Definition/EnumNodeTest.php b/lib/symfony/config/Tests/Definition/EnumNodeTest.php new file mode 100644 index 000000000..fa89eea23 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/EnumNodeTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\EnumNode; + +class EnumNodeTest extends TestCase +{ + public function testFinalizeValue() + { + $node = new EnumNode('foo', null, ['foo', 'bar']); + $this->assertSame('foo', $node->finalize('foo')); + } + + public function testConstructionWithNoValues() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('$values must contain at least one element.'); + new EnumNode('foo', null, []); + } + + public function testConstructionWithOneValue() + { + $node = new EnumNode('foo', null, ['foo']); + $this->assertSame('foo', $node->finalize('foo')); + } + + public function testConstructionWithOneDistinctValue() + { + $node = new EnumNode('foo', null, ['foo', 'foo']); + $this->assertSame('foo', $node->finalize('foo')); + } + + public function testFinalizeWithInvalidValue() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"'); + $node = new EnumNode('foo', null, ['foo', 'bar']); + $node->finalize('foobar'); + } +} diff --git a/lib/symfony/config/Tests/Definition/FinalizationTest.php b/lib/symfony/config/Tests/Definition/FinalizationTest.php new file mode 100644 index 000000000..be68a27c6 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/FinalizationTest.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\NodeInterface; +use Symfony\Component\Config\Definition\Processor; + +class FinalizationTest extends TestCase +{ + public function testUnsetKeyWithDeepHierarchy() + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('config', 'array') + ->children() + ->node('level1', 'array') + ->canBeUnset() + ->children() + ->node('level2', 'array') + ->canBeUnset() + ->children() + ->node('somevalue', 'scalar')->end() + ->node('anothervalue', 'scalar')->end() + ->end() + ->end() + ->node('level1_scalar', 'scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $a = [ + 'level1' => [ + 'level2' => [ + 'somevalue' => 'foo', + 'anothervalue' => 'bar', + ], + 'level1_scalar' => 'foo', + ], + ]; + + $b = [ + 'level1' => [ + 'level2' => false, + ], + ]; + + $this->assertEquals([ + 'level1' => [ + 'level1_scalar' => 'foo', + ], + ], $this->process($tree, [$a, $b])); + } + + protected function process(NodeInterface $tree, array $configs) + { + $processor = new Processor(); + + return $processor->process($tree, $configs); + } +} diff --git a/lib/symfony/config/Tests/Definition/FloatNodeTest.php b/lib/symfony/config/Tests/Definition/FloatNodeTest.php new file mode 100644 index 000000000..fed9f013d --- /dev/null +++ b/lib/symfony/config/Tests/Definition/FloatNodeTest.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\FloatNode; + +class FloatNodeTest extends TestCase +{ + /** + * @dataProvider getValidValues + */ + public function testNormalize($value) + { + $node = new FloatNode('test'); + $this->assertSame($value, $node->normalize($value)); + } + + /** + * @dataProvider getValidValues + * + * @param int $value + */ + public function testValidNonEmptyValues($value) + { + $node = new FloatNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + + public function getValidValues() + { + return [ + [1798.0], + [-678.987], + [12.56E45], + [0.0], + // Integer are accepted too, they will be cast + [17], + [-10], + [0], + ]; + } + + /** + * @dataProvider getInvalidValues + */ + public function testNormalizeThrowsExceptionOnInvalidValues($value) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $node = new FloatNode('test'); + $node->normalize($value); + } + + public function getInvalidValues() + { + return [ + [null], + [''], + ['foo'], + [true], + [false], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; + } +} diff --git a/lib/symfony/config/Tests/Definition/IntegerNodeTest.php b/lib/symfony/config/Tests/Definition/IntegerNodeTest.php new file mode 100644 index 000000000..3fb1b771e --- /dev/null +++ b/lib/symfony/config/Tests/Definition/IntegerNodeTest.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\IntegerNode; + +class IntegerNodeTest extends TestCase +{ + /** + * @dataProvider getValidValues + */ + public function testNormalize($value) + { + $node = new IntegerNode('test'); + $this->assertSame($value, $node->normalize($value)); + } + + /** + * @dataProvider getValidValues + * + * @param int $value + */ + public function testValidNonEmptyValues($value) + { + $node = new IntegerNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + + public function getValidValues() + { + return [ + [1798], + [-678], + [0], + ]; + } + + /** + * @dataProvider getInvalidValues + */ + public function testNormalizeThrowsExceptionOnInvalidValues($value) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $node = new IntegerNode('test'); + $node->normalize($value); + } + + public function getInvalidValues() + { + return [ + [null], + [''], + ['foo'], + [true], + [false], + [0.0], + [0.1], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; + } +} diff --git a/lib/symfony/config/Tests/Definition/MergeTest.php b/lib/symfony/config/Tests/Definition/MergeTest.php new file mode 100644 index 000000000..8fee2635c --- /dev/null +++ b/lib/symfony/config/Tests/Definition/MergeTest.php @@ -0,0 +1,192 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; + +class MergeTest extends TestCase +{ + public function testForbiddenOverwrite() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException'); + $tb = new TreeBuilder(); + $tree = $tb + ->root('root', 'array') + ->children() + ->node('foo', 'scalar') + ->cannotBeOverwritten() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $a = [ + 'foo' => 'bar', + ]; + + $b = [ + 'foo' => 'moo', + ]; + + $tree->merge($a, $b); + } + + public function testUnsetKey() + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('root', 'array') + ->children() + ->node('foo', 'scalar')->end() + ->node('bar', 'scalar')->end() + ->node('unsettable', 'array') + ->canBeUnset() + ->children() + ->node('foo', 'scalar')->end() + ->node('bar', 'scalar')->end() + ->end() + ->end() + ->node('unsetted', 'array') + ->canBeUnset() + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $a = [ + 'foo' => 'bar', + 'unsettable' => [ + 'foo' => 'a', + 'bar' => 'b', + ], + 'unsetted' => false, + ]; + + $b = [ + 'foo' => 'moo', + 'bar' => 'b', + 'unsettable' => false, + 'unsetted' => ['a', 'b'], + ]; + + $this->assertEquals([ + 'foo' => 'moo', + 'bar' => 'b', + 'unsettable' => false, + 'unsetted' => ['a', 'b'], + ], $tree->merge($a, $b)); + } + + public function testDoesNotAllowNewKeysInSubsequentConfigs() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $tb = new TreeBuilder(); + $tree = $tb + ->root('config', 'array') + ->children() + ->node('test', 'array') + ->disallowNewKeysInSubsequentConfigs() + ->useAttributeAsKey('key') + ->prototype('array') + ->children() + ->node('value', 'scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree(); + + $a = [ + 'test' => [ + 'a' => ['value' => 'foo'], + ], + ]; + + $b = [ + 'test' => [ + 'b' => ['value' => 'foo'], + ], + ]; + + $tree->merge($a, $b); + } + + public function testPerformsNoDeepMerging() + { + $tb = new TreeBuilder(); + + $tree = $tb + ->root('config', 'array') + ->children() + ->node('no_deep_merging', 'array') + ->performNoDeepMerging() + ->children() + ->node('foo', 'scalar')->end() + ->node('bar', 'scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $a = [ + 'no_deep_merging' => [ + 'foo' => 'a', + 'bar' => 'b', + ], + ]; + + $b = [ + 'no_deep_merging' => [ + 'c' => 'd', + ], + ]; + + $this->assertEquals([ + 'no_deep_merging' => [ + 'c' => 'd', + ], + ], $tree->merge($a, $b)); + } + + public function testPrototypeWithoutAKeyAttribute() + { + $tb = new TreeBuilder(); + + $tree = $tb + ->root('config', 'array') + ->children() + ->arrayNode('append_elements') + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $a = [ + 'append_elements' => ['a', 'b'], + ]; + + $b = [ + 'append_elements' => ['c', 'd'], + ]; + + $this->assertEquals(['append_elements' => ['a', 'b', 'c', 'd']], $tree->merge($a, $b)); + } +} diff --git a/lib/symfony/config/Tests/Definition/NormalizationTest.php b/lib/symfony/config/Tests/Definition/NormalizationTest.php new file mode 100644 index 000000000..200a98594 --- /dev/null +++ b/lib/symfony/config/Tests/Definition/NormalizationTest.php @@ -0,0 +1,228 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\NodeInterface; + +class NormalizationTest extends TestCase +{ + /** + * @dataProvider getEncoderTests + */ + public function testNormalizeEncoders($denormalized) + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('root_name', 'array') + ->fixXmlConfig('encoder') + ->children() + ->node('encoders', 'array') + ->useAttributeAsKey('class') + ->prototype('array') + ->beforeNormalization()->ifString()->then(function ($v) { return ['algorithm' => $v]; })->end() + ->children() + ->node('algorithm', 'scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $normalized = [ + 'encoders' => [ + 'foo' => ['algorithm' => 'plaintext'], + ], + ]; + + $this->assertNormalized($tree, $denormalized, $normalized); + } + + public function getEncoderTests() + { + $configs = []; + + // XML + $configs[] = [ + 'encoder' => [ + ['class' => 'foo', 'algorithm' => 'plaintext'], + ], + ]; + + // XML when only one element of this type + $configs[] = [ + 'encoder' => ['class' => 'foo', 'algorithm' => 'plaintext'], + ]; + + // YAML/PHP + $configs[] = [ + 'encoders' => [ + ['class' => 'foo', 'algorithm' => 'plaintext'], + ], + ]; + + // YAML/PHP + $configs[] = [ + 'encoders' => [ + 'foo' => 'plaintext', + ], + ]; + + // YAML/PHP + $configs[] = [ + 'encoders' => [ + 'foo' => ['algorithm' => 'plaintext'], + ], + ]; + + return array_map(function ($v) { + return [$v]; + }, $configs); + } + + /** + * @dataProvider getAnonymousKeysTests + */ + public function testAnonymousKeysArray($denormalized) + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('root', 'array') + ->children() + ->node('logout', 'array') + ->fixXmlConfig('handler') + ->children() + ->node('handlers', 'array') + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $normalized = ['logout' => ['handlers' => ['a', 'b', 'c']]]; + + $this->assertNormalized($tree, $denormalized, $normalized); + } + + public function getAnonymousKeysTests() + { + $configs = []; + + $configs[] = [ + 'logout' => [ + 'handlers' => ['a', 'b', 'c'], + ], + ]; + + $configs[] = [ + 'logout' => [ + 'handler' => ['a', 'b', 'c'], + ], + ]; + + return array_map(function ($v) { return [$v]; }, $configs); + } + + /** + * @dataProvider getNumericKeysTests + */ + public function testNumericKeysAsAttributes($denormalized) + { + $normalized = [ + 'thing' => [42 => ['foo', 'bar'], 1337 => ['baz', 'qux']], + ]; + + $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, $normalized); + } + + public function getNumericKeysTests() + { + $configs = []; + + $configs[] = [ + 'thing' => [ + 42 => ['foo', 'bar'], 1337 => ['baz', 'qux'], + ], + ]; + + $configs[] = [ + 'thing' => [ + ['foo', 'bar', 'id' => 42], ['baz', 'qux', 'id' => 1337], + ], + ]; + + return array_map(function ($v) { return [$v]; }, $configs); + } + + public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet() + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectExceptionMessage('The attribute "id" must be set for path "root.thing".'); + $denormalized = [ + 'thing' => [ + ['foo', 'bar'], ['baz', 'qux'], + ], + ]; + + $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, []); + } + + public function testAssociativeArrayPreserveKeys() + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('root', 'array') + ->prototype('array') + ->children() + ->node('foo', 'scalar')->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + $data = ['first' => ['foo' => 'bar']]; + + $this->assertNormalized($tree, $data, $data); + } + + public static function assertNormalized(NodeInterface $tree, $denormalized, $normalized) + { + self::assertSame($normalized, $tree->normalize($denormalized)); + } + + private function getNumericKeysTestTree() + { + $tb = new TreeBuilder(); + $tree = $tb + ->root('root', 'array') + ->children() + ->node('thing', 'array') + ->useAttributeAsKey('id') + ->prototype('array') + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->buildTree() + ; + + return $tree; + } +} diff --git a/lib/symfony/config/Tests/Definition/PrototypedArrayNodeTest.php b/lib/symfony/config/Tests/Definition/PrototypedArrayNodeTest.php new file mode 100644 index 000000000..7a58ead8d --- /dev/null +++ b/lib/symfony/config/Tests/Definition/PrototypedArrayNodeTest.php @@ -0,0 +1,341 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\PrototypedArrayNode; +use Symfony\Component\Config\Definition\ScalarNode; +use Symfony\Component\Config\Definition\VariableNode; + +class PrototypedArrayNodeTest extends TestCase +{ + public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes() + { + $node = new PrototypedArrayNode('root'); + $prototype = new ArrayNode(null, $node); + $node->setPrototype($prototype); + $this->assertEmpty($node->getDefaultValue()); + } + + public function testGetDefaultValueReturnsDefaultValueForPrototypes() + { + $node = new PrototypedArrayNode('root'); + $prototype = new ArrayNode(null, $node); + $node->setPrototype($prototype); + $node->setDefaultValue(['test']); + $this->assertEquals(['test'], $node->getDefaultValue()); + } + + // a remapped key (e.g. "mapping" -> "mappings") should be unset after being used + public function testRemappedKeysAreUnset() + { + $node = new ArrayNode('root'); + $mappingsNode = new PrototypedArrayNode('mappings'); + $node->addChild($mappingsNode); + + // each item under mappings is just a scalar + $prototype = new ScalarNode(null, $mappingsNode); + $mappingsNode->setPrototype($prototype); + + $remappings = []; + $remappings[] = ['mapping', 'mappings']; + $node->setXmlRemappings($remappings); + + $normalized = $node->normalize(['mapping' => ['foo', 'bar']]); + $this->assertEquals(['mappings' => ['foo', 'bar']], $normalized); + } + + /** + * Tests that when a key attribute is mapped, that key is removed from the array. + * + * + * + * + * The above should finally be mapped to an array that looks like this + * (because "id" is the key attribute). + * + * [ + * 'things' => [ + * 'option1' => 'foo', + * 'option2' => 'bar', + * ] + * ] + */ + public function testMappedAttributeKeyIsRemoved() + { + $node = new PrototypedArrayNode('root'); + $node->setKeyAttribute('id', true); + + // each item under the root is an array, with one scalar item + $prototype = new ArrayNode(null, $node); + $prototype->addChild(new ScalarNode('foo')); + $node->setPrototype($prototype); + + $children = []; + $children[] = ['id' => 'item_name', 'foo' => 'bar']; + $normalized = $node->normalize($children); + + $expected = []; + $expected['item_name'] = ['foo' => 'bar']; + $this->assertEquals($expected, $normalized); + } + + /** + * Tests the opposite of the testMappedAttributeKeyIsRemoved because + * the removal can be toggled with an option. + */ + public function testMappedAttributeKeyNotRemoved() + { + $node = new PrototypedArrayNode('root'); + $node->setKeyAttribute('id', false); + + // each item under the root is an array, with two scalar items + $prototype = new ArrayNode(null, $node); + $prototype->addChild(new ScalarNode('foo')); + $prototype->addChild(new ScalarNode('id')); // the key attribute will remain + $node->setPrototype($prototype); + + $children = []; + $children[] = ['id' => 'item_name', 'foo' => 'bar']; + $normalized = $node->normalize($children); + + $expected = []; + $expected['item_name'] = ['id' => 'item_name', 'foo' => 'bar']; + $this->assertEquals($expected, $normalized); + } + + public function testAddDefaultChildren() + { + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setAddChildrenIfNoneSet(); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals([['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setKeyAttribute('foobar'); + $node->setAddChildrenIfNoneSet(); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals(['defaults' => ['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setKeyAttribute('foobar'); + $node->setAddChildrenIfNoneSet('defaultkey'); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals(['defaultkey' => ['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setKeyAttribute('foobar'); + $node->setAddChildrenIfNoneSet(['defaultkey']); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals(['defaultkey' => ['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setKeyAttribute('foobar'); + $node->setAddChildrenIfNoneSet(['dk1', 'dk2']); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals(['dk1' => ['foo' => 'bar'], 'dk2' => ['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setAddChildrenIfNoneSet([5, 6]); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals([0 => ['foo' => 'bar'], 1 => ['foo' => 'bar']], $node->getDefaultValue()); + + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setAddChildrenIfNoneSet(2); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals([['foo' => 'bar'], ['foo' => 'bar']], $node->getDefaultValue()); + } + + public function testDefaultChildrenWinsOverDefaultValue() + { + $node = $this->getPrototypeNodeWithDefaultChildren(); + $node->setAddChildrenIfNoneSet(); + $node->setDefaultValue(['bar' => 'foo']); + $this->assertTrue($node->hasDefaultValue()); + $this->assertEquals([['foo' => 'bar']], $node->getDefaultValue()); + } + + protected function getPrototypeNodeWithDefaultChildren() + { + $node = new PrototypedArrayNode('root'); + $prototype = new ArrayNode(null, $node); + $child = new ScalarNode('foo'); + $child->setDefaultValue('bar'); + $prototype->addChild($child); + $prototype->setAddIfNotSet(true); + $node->setPrototype($prototype); + + return $node; + } + + /** + * Tests that when a key attribute is mapped, that key is removed from the array. + * And if only 'value' element is left in the array, it will replace its wrapper array. + * + * + * + * + * The above should finally be mapped to an array that looks like this + * (because "id" is the key attribute). + * + * [ + * 'things' => [ + * 'option1' => 'value1' + * ] + * ] + * + * It's also possible to mix 'value-only' and 'non-value-only' elements in the array. + * + * + * + * + * The above should finally be mapped to an array as follows + * + * [ + * 'things' => [ + * 'option1' => 'value1', + * 'option2' => [ + * 'value' => 'value2', + * 'foo' => 'foo2' + * ] + * ] + * ] + * + * The 'value' element can also be ArrayNode: + * + * + * + * + * + * The above should be finally be mapped to an array as follows + * + * [ + * 'things' => [ + * 'option1' => [ + * 'foo' => 'foo1', + * 'bar' => 'bar1' + * ] + * ] + * ] + * + * If using VariableNode for value node, it's also possible to mix different types of value nodes: + * + * + * + * + * + * The above should be finally mapped to an array as follows + * + * [ + * 'things' => [ + * 'option1' => [ + * 'foo' => 'foo1', + * 'bar' => 'bar1' + * ], + * 'option2' => 'value2' + * ] + * ] + * + * @dataProvider getDataForKeyRemovedLeftValueOnly + */ + public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, $expected) + { + $node = new PrototypedArrayNode('root'); + $node->setKeyAttribute('id', true); + + // each item under the root is an array, with one scalar item + $prototype = new ArrayNode(null, $node); + $prototype->addChild(new ScalarNode('id')); + $prototype->addChild(new ScalarNode('foo')); + $prototype->addChild($value); + $node->setPrototype($prototype); + + $normalized = $node->normalize($children); + $this->assertEquals($expected, $normalized); + } + + public function getDataForKeyRemovedLeftValueOnly() + { + $scalarValue = new ScalarNode('value'); + + $arrayValue = new ArrayNode('value'); + $arrayValue->addChild(new ScalarNode('foo')); + $arrayValue->addChild(new ScalarNode('bar')); + + $variableValue = new VariableNode('value'); + + return [ + [ + $scalarValue, + [ + ['id' => 'option1', 'value' => 'value1'], + ], + ['option1' => 'value1'], + ], + + [ + $scalarValue, + [ + ['id' => 'option1', 'value' => 'value1'], + ['id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'], + ], + [ + 'option1' => 'value1', + 'option2' => ['value' => 'value2', 'foo' => 'foo2'], + ], + ], + + [ + $arrayValue, + [ + [ + 'id' => 'option1', + 'value' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ], + [ + 'option1' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ], + + [$variableValue, + [ + [ + 'id' => 'option1', 'value' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ['id' => 'option2', 'value' => 'value2'], + ], + [ + 'option1' => ['foo' => 'foo1', 'bar' => 'bar1'], + 'option2' => 'value2', + ], + ], + ]; + } +} diff --git a/lib/symfony/config/Tests/Definition/ScalarNodeTest.php b/lib/symfony/config/Tests/Definition/ScalarNodeTest.php new file mode 100644 index 000000000..4413baf3c --- /dev/null +++ b/lib/symfony/config/Tests/Definition/ScalarNodeTest.php @@ -0,0 +1,161 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Definition; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\ScalarNode; + +class ScalarNodeTest extends TestCase +{ + /** + * @dataProvider getValidValues + */ + public function testNormalize($value) + { + $node = new ScalarNode('test'); + $this->assertSame($value, $node->normalize($value)); + } + + public function getValidValues() + { + return [ + [false], + [true], + [null], + [''], + ['foo'], + [0], + [1], + [0.0], + [0.1], + ]; + } + + public function testSetDeprecated() + { + $childNode = new ScalarNode('foo'); + $childNode->setDeprecated('"%node%" is deprecated'); + + $this->assertTrue($childNode->isDeprecated()); + $this->assertSame('"foo" is deprecated', $childNode->getDeprecationMessage($childNode->getName(), $childNode->getPath())); + + $node = new ArrayNode('root'); + $node->addChild($childNode); + + $deprecationTriggered = 0; + $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { + if (E_USER_DEPRECATED === $level) { + return ++$deprecationTriggered; + } + + return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; + }; + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize([]); + restore_error_handler(); + $this->assertSame(0, $deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize(['foo' => '']); + restore_error_handler(); + $this->assertSame(1, $deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); + } + + /** + * @dataProvider getInvalidValues + */ + public function testNormalizeThrowsExceptionOnInvalidValues($value) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $node = new ScalarNode('test'); + $node->normalize($value); + } + + public function getInvalidValues() + { + return [ + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; + } + + public function testNormalizeThrowsExceptionWithoutHint() + { + $node = new ScalarNode('test'); + + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.'); + + $node->normalize([]); + } + + public function testNormalizeThrowsExceptionWithErrorMessage() + { + $node = new ScalarNode('test'); + $node->setInfo('"the test value"'); + + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); + + $node->normalize([]); + } + + /** + * @dataProvider getValidNonEmptyValues + * + * @param mixed $value + */ + public function testValidNonEmptyValues($value) + { + $node = new ScalarNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + + public function getValidNonEmptyValues() + { + return [ + [false], + [true], + ['foo'], + [0], + [1], + [0.0], + [0.1], + ]; + } + + /** + * @dataProvider getEmptyValues + * + * @param mixed $value + */ + public function testNotAllowedEmptyValuesThrowException($value) + { + $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $node = new ScalarNode('test'); + $node->setAllowEmptyValue(false); + $node->finalize($value); + } + + public function getEmptyValues() + { + return [ + [null], + [''], + ]; + } +} diff --git a/lib/symfony/config/Tests/DependencyInjection/ConfigCachePassTest.php b/lib/symfony/config/Tests/DependencyInjection/ConfigCachePassTest.php new file mode 100644 index 000000000..c2b95195d --- /dev/null +++ b/lib/symfony/config/Tests/DependencyInjection/ConfigCachePassTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\DependencyInjection\ConfigCachePass; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * @group legacy + */ +class ConfigCachePassTest extends TestCase +{ + public function testThatCheckersAreProcessedInPriorityOrder() + { + $container = new ContainerBuilder(); + + $definition = $container->register('config_cache_factory')->addArgument(null); + $container->register('checker_2')->addTag('config_cache.resource_checker', ['priority' => 100]); + $container->register('checker_1')->addTag('config_cache.resource_checker', ['priority' => 200]); + $container->register('checker_3')->addTag('config_cache.resource_checker'); + + $pass = new ConfigCachePass(); + $pass->process($container); + + $expected = new IteratorArgument([ + new Reference('checker_1'), + new Reference('checker_2'), + new Reference('checker_3'), + ]); + $this->assertEquals($expected, $definition->getArgument(0)); + } + + public function testThatCheckersCanBeMissing() + { + $container = new ContainerBuilder(); + + $definitionsBefore = \count($container->getDefinitions()); + $aliasesBefore = \count($container->getAliases()); + + $pass = new ConfigCachePass(); + $pass->process($container); + + // the container is untouched (i.e. no new definitions or aliases) + $this->assertCount($definitionsBefore, $container->getDefinitions()); + $this->assertCount($aliasesBefore, $container->getAliases()); + } +} diff --git a/lib/symfony/config/Tests/Exception/FileLoaderLoadExceptionTest.php b/lib/symfony/config/Tests/Exception/FileLoaderLoadExceptionTest.php new file mode 100644 index 000000000..8363084c1 --- /dev/null +++ b/lib/symfony/config/Tests/Exception/FileLoaderLoadExceptionTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Exception; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Exception\FileLoaderLoadException; + +class FileLoaderLoadExceptionTest extends TestCase +{ + public function testMessageCannotLoadResource() + { + $exception = new FileLoaderLoadException('resource', null); + $this->assertEquals('Cannot load resource "resource".', $exception->getMessage()); + } + + public function testMessageCannotLoadResourceWithType() + { + $exception = new FileLoaderLoadException('resource', null, null, null, 'foobar'); + $this->assertEquals('Cannot load resource "resource". Make sure there is a loader supporting the "foobar" type.', $exception->getMessage()); + } + + public function testMessageCannotLoadResourceWithAnnotationType() + { + $exception = new FileLoaderLoadException('resource', null, null, null, 'annotation'); + $this->assertEquals('Cannot load resource "resource". Make sure annotations are installed and enabled.', $exception->getMessage()); + } + + public function testMessageCannotImportResourceFromSource() + { + $exception = new FileLoaderLoadException('resource', 'sourceResource'); + $this->assertEquals('Cannot import resource "resource" from "sourceResource".', $exception->getMessage()); + } + + public function testMessageCannotImportBundleResource() + { + $exception = new FileLoaderLoadException('@resource', 'sourceResource'); + $this->assertEquals( + 'Cannot import resource "@resource" from "sourceResource". '. + 'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '. + 'If the bundle is registered, make sure the bundle path "@resource" is not empty.', + $exception->getMessage() + ); + } + + public function testMessageHasPreviousErrorWithDotAndUnableToLoad() + { + $exception = new FileLoaderLoadException( + 'resource', + null, + null, + new \Exception('There was a previous error with an ending dot.') + ); + $this->assertEquals( + 'There was a previous error with an ending dot in resource (which is loaded in resource "resource").', + $exception->getMessage() + ); + } + + public function testMessageHasPreviousErrorWithoutDotAndUnableToLoad() + { + $exception = new FileLoaderLoadException( + 'resource', + null, + null, + new \Exception('There was a previous error with no ending dot') + ); + $this->assertEquals( + 'There was a previous error with no ending dot in resource (which is loaded in resource "resource").', + $exception->getMessage() + ); + } + + public function testMessageHasPreviousErrorAndUnableToLoadBundle() + { + $exception = new FileLoaderLoadException( + '@resource', + null, + null, + new \Exception('There was a previous error with an ending dot.') + ); + $this->assertEquals( + 'There was a previous error with an ending dot in @resource '. + '(which is loaded in resource "@resource"). '. + 'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '. + 'If the bundle is registered, make sure the bundle path "@resource" is not empty.', + $exception->getMessage() + ); + } +} diff --git a/lib/symfony/config/Tests/FileLocatorTest.php b/lib/symfony/config/Tests/FileLocatorTest.php new file mode 100644 index 000000000..e931916af --- /dev/null +++ b/lib/symfony/config/Tests/FileLocatorTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\FileLocator; + +class FileLocatorTest extends TestCase +{ + /** + * @dataProvider getIsAbsolutePathTests + */ + public function testIsAbsolutePath($path) + { + $loader = new FileLocator([]); + $r = new \ReflectionObject($loader); + $m = $r->getMethod('isAbsolutePath'); + $m->setAccessible(true); + + $this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for an absolute path'); + } + + public function getIsAbsolutePathTests() + { + return [ + ['/foo.xml'], + ['c:\\\\foo.xml'], + ['c:/foo.xml'], + ['\\server\\foo.xml'], + ['https://server/foo.xml'], + ['phar://server/foo.xml'], + ]; + } + + public function testLocate() + { + $loader = new FileLocator(__DIR__.'/Fixtures'); + + $this->assertEquals( + __DIR__.\DIRECTORY_SEPARATOR.'FileLocatorTest.php', + $loader->locate('FileLocatorTest.php', __DIR__), + '->locate() returns the absolute filename if the file exists in the given path' + ); + + $this->assertEquals( + __DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', + $loader->locate('foo.xml', __DIR__), + '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' + ); + + $this->assertEquals( + __DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', + $loader->locate(__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__), + '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' + ); + + $loader = new FileLocator([__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again']); + + $this->assertEquals( + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], + $loader->locate('foo.xml', __DIR__, false), + '->locate() returns an array of absolute filenames' + ); + + $this->assertEquals( + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], + $loader->locate('foo.xml', __DIR__.'/Fixtures', false), + '->locate() returns an array of absolute filenames' + ); + + $loader = new FileLocator(__DIR__.'/Fixtures/Again'); + + $this->assertEquals( + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], + $loader->locate('foo.xml', __DIR__.'/Fixtures', false), + '->locate() returns an array of absolute filenames' + ); + } + + public function testLocateThrowsAnExceptionIfTheFileDoesNotExists() + { + $this->expectException('Symfony\Component\Config\Exception\FileLocatorFileNotFoundException'); + $this->expectExceptionMessage('The file "foobar.xml" does not exist'); + $loader = new FileLocator([__DIR__.'/Fixtures']); + + $loader->locate('foobar.xml', __DIR__); + } + + public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath() + { + $this->expectException('Symfony\Component\Config\Exception\FileLocatorFileNotFoundException'); + $loader = new FileLocator([__DIR__.'/Fixtures']); + + $loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__); + } + + public function testLocateEmpty() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('An empty file name is not valid to be located.'); + $loader = new FileLocator([__DIR__.'/Fixtures']); + + $loader->locate(null, __DIR__); + } +} diff --git a/lib/symfony/config/Tests/Fixtures/Again/foo.xml b/lib/symfony/config/Tests/Fixtures/Again/foo.xml new file mode 100644 index 000000000..e69de29bb diff --git a/lib/symfony/config/Tests/Fixtures/BadParent.php b/lib/symfony/config/Tests/Fixtures/BadParent.php new file mode 100644 index 000000000..68d7296ed --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/BadParent.php @@ -0,0 +1,7 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures; + +use Symfony\Component\Config\Definition\ArrayNode; + +class BarNode extends ArrayNode +{ +} diff --git a/lib/symfony/config/Tests/Fixtures/Builder/BarNodeDefinition.php b/lib/symfony/config/Tests/Fixtures/Builder/BarNodeDefinition.php new file mode 100644 index 000000000..b9c62e537 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Builder/BarNodeDefinition.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures\Builder; + +use Symfony\Component\Config\Definition\Builder\NodeDefinition; +use Symfony\Component\Config\Tests\Fixtures\BarNode; + +class BarNodeDefinition extends NodeDefinition +{ + protected function createNode() + { + return new BarNode($this->name); + } +} diff --git a/lib/symfony/config/Tests/Fixtures/Builder/NodeBuilder.php b/lib/symfony/config/Tests/Fixtures/Builder/NodeBuilder.php new file mode 100644 index 000000000..22b8b32fb --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Builder/NodeBuilder.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures\Builder; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder; + +class NodeBuilder extends BaseNodeBuilder +{ + public function barNode($name) + { + return $this->node($name, 'bar'); + } + + protected function getNodeClass($type) + { + switch ($type) { + case 'variable': + return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition'; + case 'bar': + return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition'; + default: + return parent::getNodeClass($type); + } + } +} diff --git a/lib/symfony/config/Tests/Fixtures/Builder/VariableNodeDefinition.php b/lib/symfony/config/Tests/Fixtures/Builder/VariableNodeDefinition.php new file mode 100644 index 000000000..6126ed434 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Builder/VariableNodeDefinition.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures\Builder; + +use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition; + +class VariableNodeDefinition extends BaseVariableNodeDefinition +{ +} diff --git a/lib/symfony/config/Tests/Fixtures/Configuration/ExampleConfiguration.php b/lib/symfony/config/Tests/Fixtures/Configuration/ExampleConfiguration.php new file mode 100644 index 000000000..3f02700a1 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Configuration/ExampleConfiguration.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Fixtures\Configuration; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class ExampleConfiguration implements ConfigurationInterface +{ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('acme_root'); + + $rootNode + ->fixXmlConfig('parameter') + ->fixXmlConfig('connection') + ->fixXmlConfig('cms_page') + ->children() + ->booleanNode('boolean')->defaultTrue()->end() + ->scalarNode('scalar_empty')->end() + ->scalarNode('scalar_null')->defaultNull()->end() + ->scalarNode('scalar_true')->defaultTrue()->end() + ->scalarNode('scalar_false')->defaultFalse()->end() + ->scalarNode('scalar_default')->defaultValue('default')->end() + ->scalarNode('scalar_array_empty')->defaultValue([])->end() + ->scalarNode('scalar_array_defaults')->defaultValue(['elem1', 'elem2'])->end() + ->scalarNode('scalar_required')->isRequired()->end() + ->scalarNode('scalar_deprecated')->setDeprecated()->end() + ->scalarNode('scalar_deprecated_with_message')->setDeprecated('Deprecation custom message for "%node%" at "%path%"')->end() + ->scalarNode('node_with_a_looong_name')->end() + ->enumNode('enum_with_default')->values(['this', 'that'])->defaultValue('this')->end() + ->enumNode('enum')->values(['this', 'that'])->end() + ->arrayNode('array') + ->info('some info') + ->canBeUnset() + ->children() + ->scalarNode('child1')->end() + ->scalarNode('child2')->end() + ->scalarNode('child3') + ->info( + "this is a long\n". + "multi-line info text\n". + 'which should be indented' + ) + ->example('example setting') + ->end() + ->end() + ->end() + ->arrayNode('scalar_prototyped') + ->prototype('scalar')->end() + ->end() + ->arrayNode('parameters') + ->useAttributeAsKey('name') + ->prototype('scalar')->info('Parameter name')->end() + ->end() + ->arrayNode('connections') + ->prototype('array') + ->children() + ->scalarNode('user')->end() + ->scalarNode('pass')->end() + ->end() + ->end() + ->end() + ->arrayNode('cms_pages') + ->useAttributeAsKey('page') + ->prototype('array') + ->useAttributeAsKey('locale') + ->prototype('array') + ->children() + ->scalarNode('title')->isRequired()->end() + ->scalarNode('path')->isRequired()->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('pipou') + ->useAttributeAsKey('name') + ->prototype('array') + ->prototype('array') + ->children() + ->scalarNode('didou') + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ; + + return $treeBuilder; + } +} diff --git a/lib/symfony/config/Tests/Fixtures/Resource/.hiddenFile b/lib/symfony/config/Tests/Fixtures/Resource/.hiddenFile new file mode 100644 index 000000000..e69de29bb diff --git a/lib/symfony/config/Tests/Fixtures/Resource/ConditionalClass.php b/lib/symfony/config/Tests/Fixtures/Resource/ConditionalClass.php new file mode 100644 index 000000000..2ba48c5b0 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Resource/ConditionalClass.php @@ -0,0 +1,9 @@ + +]> + diff --git a/lib/symfony/config/Tests/Fixtures/Util/invalid.xml b/lib/symfony/config/Tests/Fixtures/Util/invalid.xml new file mode 100644 index 000000000..a07af9fd8 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Util/invalid.xml @@ -0,0 +1,2 @@ + + diff --git a/lib/symfony/config/Tests/Fixtures/Util/invalid_schema.xml b/lib/symfony/config/Tests/Fixtures/Util/invalid_schema.xml new file mode 100644 index 000000000..e2725a2c2 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Util/invalid_schema.xml @@ -0,0 +1,2 @@ + + diff --git a/lib/symfony/config/Tests/Fixtures/Util/schema.xsd b/lib/symfony/config/Tests/Fixtures/Util/schema.xsd new file mode 100644 index 000000000..e56820f69 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Util/schema.xsd @@ -0,0 +1,9 @@ + + + + + + diff --git a/lib/symfony/config/Tests/Fixtures/Util/valid.xml b/lib/symfony/config/Tests/Fixtures/Util/valid.xml new file mode 100644 index 000000000..a96bb3826 --- /dev/null +++ b/lib/symfony/config/Tests/Fixtures/Util/valid.xml @@ -0,0 +1,3 @@ + + + diff --git a/lib/symfony/config/Tests/Fixtures/foo.xml b/lib/symfony/config/Tests/Fixtures/foo.xml new file mode 100644 index 000000000..e69de29bb diff --git a/lib/symfony/config/Tests/Loader/DelegatingLoaderTest.php b/lib/symfony/config/Tests/Loader/DelegatingLoaderTest.php new file mode 100644 index 000000000..38ae6ff7b --- /dev/null +++ b/lib/symfony/config/Tests/Loader/DelegatingLoaderTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Loader; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Loader\DelegatingLoader; +use Symfony\Component\Config\Loader\LoaderResolver; + +class DelegatingLoaderTest extends TestCase +{ + public function testConstructor() + { + new DelegatingLoader($resolver = new LoaderResolver()); + $this->assertTrue(true, '__construct() takes a loader resolver as its first argument'); + } + + public function testGetSetResolver() + { + $resolver = new LoaderResolver(); + $loader = new DelegatingLoader($resolver); + $this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader'); + $loader->setResolver($resolver = new LoaderResolver()); + $this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader'); + } + + public function testSupports() + { + $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader1->expects($this->once())->method('supports')->willReturn(true); + $loader = new DelegatingLoader(new LoaderResolver([$loader1])); + $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); + + $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader1->expects($this->once())->method('supports')->willReturn(false); + $loader = new DelegatingLoader(new LoaderResolver([$loader1])); + $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); + } + + public function testLoad() + { + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader->expects($this->once())->method('supports')->willReturn(true); + $loader->expects($this->once())->method('load'); + $resolver = new LoaderResolver([$loader]); + $loader = new DelegatingLoader($resolver); + + $loader->load('foo'); + } + + public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() + { + $this->expectException('Symfony\Component\Config\Exception\FileLoaderLoadException'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader->expects($this->once())->method('supports')->willReturn(false); + $resolver = new LoaderResolver([$loader]); + $loader = new DelegatingLoader($resolver); + + $loader->load('foo'); + } +} diff --git a/lib/symfony/config/Tests/Loader/FileLoaderTest.php b/lib/symfony/config/Tests/Loader/FileLoaderTest.php new file mode 100644 index 000000000..b59ace46f --- /dev/null +++ b/lib/symfony/config/Tests/Loader/FileLoaderTest.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Loader; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\Loader\FileLoader; +use Symfony\Component\Config\Loader\LoaderResolver; + +class FileLoaderTest extends TestCase +{ + public function testImportWithFileLocatorDelegation() + { + $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + + $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( + ['path/to/file1'], // Default + ['path/to/file1', 'path/to/file2'], // First is imported + ['path/to/file1', 'path/to/file2'], // Second is imported + ['path/to/file1'], // Exception + ['path/to/file1', 'path/to/file2'] // Exception + )); + + $fileLoader = new TestFileLoader($locatorMock); + $fileLoader->setSupports(false); + $fileLoader->setCurrentDir('.'); + + $additionalLoader = new TestFileLoader($locatorMockForAdditionalLoader); + $additionalLoader->setCurrentDir('.'); + + $fileLoader->setResolver($loaderResolver = new LoaderResolver([$fileLoader, $additionalLoader])); + + // Default case + $this->assertSame('path/to/file1', $fileLoader->import('my_resource')); + + // Check first file is imported if not already loading + $this->assertSame('path/to/file1', $fileLoader->import('my_resource')); + + // Check second file is imported if first is already loading + $fileLoader->addLoading('path/to/file1'); + $this->assertSame('path/to/file2', $fileLoader->import('my_resource')); + + // Check exception throws if first (and only available) file is already loading + try { + $fileLoader->import('my_resource'); + $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + } + + // Check exception throws if all files are already loading + try { + $fileLoader->addLoading('path/to/file2'); + $fileLoader->import('my_resource'); + $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + } + } + + public function testImportWithGlobLikeResource() + { + $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $loader = new TestFileLoader($locatorMock); + + $this->assertSame('[foo]', $loader->import('[foo]')); + } + + public function testImportWithNoGlobMatch() + { + $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $loader = new TestFileLoader($locatorMock); + + $this->assertNull($loader->import('./*.abc')); + } + + public function testImportWithSimpleGlob() + { + $loader = new TestFileLoader(new FileLocator(__DIR__)); + + $this->assertSame(__FILE__, strtr($loader->import('FileLoaderTest.*'), '/', \DIRECTORY_SEPARATOR)); + } +} + +class TestFileLoader extends FileLoader +{ + private $supports = true; + + public function load($resource, $type = null) + { + return $resource; + } + + public function supports($resource, $type = null) + { + return $this->supports; + } + + public function addLoading($resource) + { + self::$loading[$resource] = true; + } + + public function removeLoading($resource) + { + unset(self::$loading[$resource]); + } + + public function clearLoading() + { + self::$loading = []; + } + + public function setSupports($supports) + { + $this->supports = $supports; + } +} diff --git a/lib/symfony/config/Tests/Loader/LoaderResolverTest.php b/lib/symfony/config/Tests/Loader/LoaderResolverTest.php new file mode 100644 index 000000000..aabc2a600 --- /dev/null +++ b/lib/symfony/config/Tests/Loader/LoaderResolverTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Loader; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Loader\LoaderResolver; + +class LoaderResolverTest extends TestCase +{ + public function testConstructor() + { + $resolver = new LoaderResolver([ + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(), + ]); + + $this->assertEquals([$loader], $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); + } + + public function testResolve() + { + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolver = new LoaderResolver([$loader]); + $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); + + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader->expects($this->once())->method('supports')->willReturn(true); + $resolver = new LoaderResolver([$loader]); + $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); + } + + public function testLoaders() + { + $resolver = new LoaderResolver(); + $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock()); + + $this->assertEquals([$loader], $resolver->getLoaders(), 'addLoader() adds a loader'); + } +} diff --git a/lib/symfony/config/Tests/Loader/LoaderTest.php b/lib/symfony/config/Tests/Loader/LoaderTest.php new file mode 100644 index 000000000..35a911ef3 --- /dev/null +++ b/lib/symfony/config/Tests/Loader/LoaderTest.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Loader; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Loader\Loader; + +class LoaderTest extends TestCase +{ + public function testGetSetResolver() + { + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + + $loader = new ProjectLoader1(); + $loader->setResolver($resolver); + + $this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader'); + } + + public function testResolve() + { + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver->expects($this->once()) + ->method('resolve') + ->with('foo.xml') + ->willReturn($resolvedLoader); + + $loader = new ProjectLoader1(); + $loader->setResolver($resolver); + + $this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader'); + $this->assertSame($resolvedLoader, $loader->resolve('foo.xml'), '->resolve() finds a loader'); + } + + public function testResolveWhenResolverCannotFindLoader() + { + $this->expectException('Symfony\Component\Config\Exception\FileLoaderLoadException'); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver->expects($this->once()) + ->method('resolve') + ->with('FOOBAR') + ->willReturn(false); + + $loader = new ProjectLoader1(); + $loader->setResolver($resolver); + + $loader->resolve('FOOBAR'); + } + + public function testImport() + { + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolvedLoader->expects($this->once()) + ->method('load') + ->with('foo') + ->willReturn('yes'); + + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver->expects($this->once()) + ->method('resolve') + ->with('foo') + ->willReturn($resolvedLoader); + + $loader = new ProjectLoader1(); + $loader->setResolver($resolver); + + $this->assertEquals('yes', $loader->import('foo')); + } + + public function testImportWithType() + { + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolvedLoader->expects($this->once()) + ->method('load') + ->with('foo', 'bar') + ->willReturn('yes'); + + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver->expects($this->once()) + ->method('resolve') + ->with('foo', 'bar') + ->willReturn($resolvedLoader); + + $loader = new ProjectLoader1(); + $loader->setResolver($resolver); + + $this->assertEquals('yes', $loader->import('foo', 'bar')); + } +} + +class ProjectLoader1 extends Loader +{ + public function load($resource, $type = null) + { + } + + public function supports($resource, $type = null) + { + return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION); + } + + public function getType() + { + } +} diff --git a/lib/symfony/config/Tests/Resource/ClassExistenceResourceTest.php b/lib/symfony/config/Tests/Resource/ClassExistenceResourceTest.php new file mode 100644 index 000000000..b7ae81eaa --- /dev/null +++ b/lib/symfony/config/Tests/Resource/ClassExistenceResourceTest.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\ClassExistenceResource; +use Symfony\Component\Config\Tests\Fixtures\BadParent; +use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass; + +class ClassExistenceResourceTest extends TestCase +{ + public function testToString() + { + $res = new ClassExistenceResource('BarClass'); + $this->assertSame('BarClass', (string) $res); + } + + public function testGetResource() + { + $res = new ClassExistenceResource('BarClass'); + $this->assertSame('BarClass', $res->getResource()); + } + + public function testIsFreshWhenClassDoesNotExist() + { + $res = new ClassExistenceResource('Symfony\Component\Config\Tests\Fixtures\BarClass'); + + $this->assertTrue($res->isFresh(time())); + + eval(<<assertFalse($res->isFresh(time())); + } + + public function testIsFreshWhenClassExists() + { + $res = new ClassExistenceResource('Symfony\Component\Config\Tests\Resource\ClassExistenceResourceTest'); + + $this->assertTrue($res->isFresh(time())); + } + + public function testExistsKo() + { + spl_autoload_register($autoloader = function ($class) use (&$loadedClass) { $loadedClass = $class; }); + + try { + $res = new ClassExistenceResource('MissingFooClass'); + $this->assertTrue($res->isFresh(0)); + + $this->assertSame('MissingFooClass', $loadedClass); + + $loadedClass = 123; + + new ClassExistenceResource('MissingFooClass', false); + + $this->assertSame(123, $loadedClass); + } finally { + spl_autoload_unregister($autoloader); + } + } + + public function testBadParentWithTimestamp() + { + $res = new ClassExistenceResource(BadParent::class, false); + $this->assertTrue($res->isFresh(time())); + } + + public function testBadParentWithNoTimestamp() + { + $this->expectException('ReflectionException'); + $this->expectExceptionMessage('Class "Symfony\Component\Config\Tests\Fixtures\MissingParent" not found while loading "Symfony\Component\Config\Tests\Fixtures\BadParent".'); + + $res = new ClassExistenceResource(BadParent::class, false); + $res->isFresh(0); + } + + public function testConditionalClass() + { + $res = new ClassExistenceResource(ConditionalClass::class, false); + + $this->assertFalse($res->isFresh(0)); + } +} diff --git a/lib/symfony/config/Tests/Resource/ComposerResourceTest.php b/lib/symfony/config/Tests/Resource/ComposerResourceTest.php new file mode 100644 index 000000000..6857c766d --- /dev/null +++ b/lib/symfony/config/Tests/Resource/ComposerResourceTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use Composer\Autoload\ClassLoader; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\ComposerResource; + +class ComposerResourceTest extends TestCase +{ + public function testGetVendor() + { + $res = new ComposerResource(); + + $r = new \ReflectionClass(ClassLoader::class); + $found = false; + + foreach ($res->getVendors() as $vendor) { + if ($vendor && 0 === strpos($r->getFileName(), $vendor)) { + $found = true; + break; + } + } + + $this->assertTrue($found); + } + + public function testSerializeUnserialize() + { + $res = new ComposerResource(); + $ser = unserialize(serialize($res)); + + $this->assertTrue($res->isFresh(0)); + $this->assertTrue($ser->isFresh(0)); + + $this->assertEquals($res, $ser); + } +} diff --git a/lib/symfony/config/Tests/Resource/DirectoryResourceTest.php b/lib/symfony/config/Tests/Resource/DirectoryResourceTest.php new file mode 100644 index 000000000..40b179010 --- /dev/null +++ b/lib/symfony/config/Tests/Resource/DirectoryResourceTest.php @@ -0,0 +1,181 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\DirectoryResource; + +class DirectoryResourceTest extends TestCase +{ + protected $directory; + + protected function setUp() + { + $this->directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfonyDirectoryIterator'; + if (!file_exists($this->directory)) { + mkdir($this->directory); + } + touch($this->directory.'/tmp.xml'); + } + + protected function tearDown() + { + if (!is_dir($this->directory)) { + return; + } + $this->removeDirectory($this->directory); + } + + protected function removeDirectory($directory) + { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST); + foreach ($iterator as $path) { + if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) { + continue; + } + if ($path->isDir()) { + rmdir($path->__toString()); + } else { + unlink($path->__toString()); + } + } + rmdir($directory); + } + + public function testGetResource() + { + $resource = new DirectoryResource($this->directory); + $this->assertSame(realpath($this->directory), $resource->getResource(), '->getResource() returns the path to the resource'); + } + + public function testGetPattern() + { + $resource = new DirectoryResource($this->directory, 'bar'); + $this->assertEquals('bar', $resource->getPattern()); + } + + public function testResourceDoesNotExist() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessageRegExp('/The directory ".*" does not exist./'); + new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999)); + } + + public function testIsFresh() + { + $resource = new DirectoryResource($this->directory); + $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed'); + $this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated'); + } + + public function testIsFreshForDeletedResources() + { + $resource = new DirectoryResource($this->directory); + $this->removeDirectory($this->directory); + + $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist'); + } + + public function testIsFreshUpdateFile() + { + $resource = new DirectoryResource($this->directory); + touch($this->directory.'/tmp.xml', time() + 20); + $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified'); + } + + public function testIsFreshNewFile() + { + $resource = new DirectoryResource($this->directory); + touch($this->directory.'/new.xml', time() + 20); + $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added'); + } + + public function testIsFreshNewFileWithDifferentPattern() + { + $resource = new DirectoryResource($this->directory, '/.xml$/'); + touch($this->directory.'/new.yaml', time() + 20); + $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file with a non-matching pattern is added'); + } + + public function testIsFreshDeleteFile() + { + $resource = new DirectoryResource($this->directory); + $time = time(); + sleep(1); + unlink($this->directory.'/tmp.xml'); + $this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed'); + } + + public function testIsFreshDeleteDirectory() + { + $resource = new DirectoryResource($this->directory); + $this->removeDirectory($this->directory); + $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed'); + } + + public function testIsFreshCreateFileInSubdirectory() + { + $subdirectory = $this->directory.'/subdirectory'; + mkdir($subdirectory); + + $resource = new DirectoryResource($this->directory); + $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists'); + + touch($subdirectory.'/newfile.xml', time() + 20); + $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added'); + } + + public function testIsFreshModifySubdirectory() + { + $resource = new DirectoryResource($this->directory); + + $subdirectory = $this->directory.'/subdirectory'; + mkdir($subdirectory); + touch($subdirectory, time() + 20); + + $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)'); + } + + public function testFilterRegexListNoMatch() + { + $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); + + touch($this->directory.'/new.bar', time() + 20); + $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created'); + } + + public function testFilterRegexListMatch() + { + $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); + + touch($this->directory.'/new.xml', time() + 20); + $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created '); + } + + public function testSerializeUnserialize() + { + $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/'); + + unserialize(serialize($resource)); + + $this->assertSame(realpath($this->directory), $resource->getResource()); + $this->assertSame('/\.(foo|xml)$/', $resource->getPattern()); + } + + public function testResourcesWithDifferentPatternsAreDifferent() + { + $resourceA = new DirectoryResource($this->directory, '/.xml$/'); + $resourceB = new DirectoryResource($this->directory, '/.yaml$/'); + + $this->assertCount(2, array_unique([$resourceA, $resourceB])); + } +} diff --git a/lib/symfony/config/Tests/Resource/FileExistenceResourceTest.php b/lib/symfony/config/Tests/Resource/FileExistenceResourceTest.php new file mode 100644 index 000000000..433f65e82 --- /dev/null +++ b/lib/symfony/config/Tests/Resource/FileExistenceResourceTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\FileExistenceResource; + +class FileExistenceResourceTest extends TestCase +{ + protected $resource; + protected $file; + protected $time; + + protected function setUp() + { + $this->file = realpath(sys_get_temp_dir()).'/tmp.xml'; + $this->time = time(); + $this->resource = new FileExistenceResource($this->file); + } + + protected function tearDown() + { + if (file_exists($this->file)) { + unlink($this->file); + } + } + + public function testToString() + { + $this->assertSame($this->file, (string) $this->resource); + } + + public function testGetResource() + { + $this->assertSame($this->file, $this->resource->getResource(), '->getResource() returns the path to the resource'); + } + + public function testIsFreshWithExistingResource() + { + touch($this->file, $this->time); + $serialized = serialize(new FileExistenceResource($this->file)); + + $resource = unserialize($serialized); + $this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still present'); + + unlink($this->file); + $resource = unserialize($serialized); + $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been deleted'); + } + + public function testIsFreshWithAbsentResource() + { + $serialized = serialize(new FileExistenceResource($this->file)); + + $resource = unserialize($serialized); + $this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still absent'); + + touch($this->file, $this->time); + $resource = unserialize($serialized); + $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been created'); + } +} diff --git a/lib/symfony/config/Tests/Resource/FileResourceTest.php b/lib/symfony/config/Tests/Resource/FileResourceTest.php new file mode 100644 index 000000000..968c7e926 --- /dev/null +++ b/lib/symfony/config/Tests/Resource/FileResourceTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\FileResource; + +class FileResourceTest extends TestCase +{ + protected $resource; + protected $file; + protected $time; + + protected function setUp() + { + $this->file = sys_get_temp_dir().'/tmp.xml'; + $this->time = time(); + touch($this->file, $this->time); + $this->resource = new FileResource($this->file); + } + + protected function tearDown() + { + if (!file_exists($this->file)) { + return; + } + + unlink($this->file); + } + + public function testGetResource() + { + $this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource'); + } + + public function testGetResourceWithScheme() + { + $resource = new FileResource('file://'.$this->file); + $this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource'); + } + + public function testToString() + { + $this->assertSame(realpath($this->file), (string) $this->resource); + } + + public function testResourceDoesNotExist() + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessageRegExp('/The file ".*" does not exist./'); + new FileResource('/____foo/foobar'.mt_rand(1, 999999)); + } + + public function testIsFresh() + { + $this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second'); + $this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed'); + $this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated'); + } + + public function testIsFreshForDeletedResources() + { + unlink($this->file); + + $this->assertFalse($this->resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); + } + + public function testSerializeUnserialize() + { + unserialize(serialize($this->resource)); + + $this->assertSame(realpath($this->file), $this->resource->getResource()); + } +} diff --git a/lib/symfony/config/Tests/Resource/GlobResourceTest.php b/lib/symfony/config/Tests/Resource/GlobResourceTest.php new file mode 100644 index 000000000..cfbfd2b45 --- /dev/null +++ b/lib/symfony/config/Tests/Resource/GlobResourceTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\GlobResource; + +class GlobResourceTest extends TestCase +{ + protected function tearDown() + { + $dir = \dirname(__DIR__).'/Fixtures'; + @rmdir($dir.'/TmpGlob'); + @unlink($dir.'/TmpGlob'); + @unlink($dir.'/Resource/TmpGlob'); + touch($dir.'/Resource/.hiddenFile'); + } + + public function testIterator() + { + $dir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; + $resource = new GlobResource($dir, '/Resource', true); + + $paths = iterator_to_array($resource); + + $file = $dir.'/Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; + $this->assertEquals([$file => new \SplFileInfo($file)], $paths); + $this->assertInstanceOf('SplFileInfo', current($paths)); + $this->assertSame($dir, $resource->getPrefix()); + + $resource = new GlobResource($dir, '/**/Resource', true); + + $paths = iterator_to_array($resource); + + $file = $dir.\DIRECTORY_SEPARATOR.'Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; + $this->assertEquals([$file => $file], $paths); + $this->assertInstanceOf('SplFileInfo', current($paths)); + $this->assertSame($dir, $resource->getPrefix()); + } + + public function testIsFreshNonRecursiveDetectsNewFile() + { + $dir = \dirname(__DIR__).'/Fixtures'; + $resource = new GlobResource($dir, '/*', false); + + $this->assertTrue($resource->isFresh(0)); + + mkdir($dir.'/TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + rmdir($dir.'/TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + touch($dir.'/TmpGlob'); + $this->assertFalse($resource->isFresh(0)); + + unlink($dir.'/TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + } + + public function testIsFreshNonRecursiveDetectsRemovedFile() + { + $dir = \dirname(__DIR__).'/Fixtures'; + $resource = new GlobResource($dir, '/*', false); + + touch($dir.'/TmpGlob'); + touch($dir.'/.TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + unlink($dir.'/.TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + unlink($dir.'/TmpGlob'); + $this->assertFalse($resource->isFresh(0)); + } + + public function testIsFreshRecursiveDetectsRemovedFile() + { + $dir = \dirname(__DIR__).'/Fixtures'; + $resource = new GlobResource($dir, '/*', true); + + touch($dir.'/Resource/TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + unlink($dir.'/Resource/TmpGlob'); + $this->assertFalse($resource->isFresh(0)); + + touch($dir.'/Resource/TmpGlob'); + $this->assertTrue($resource->isFresh(0)); + + unlink($dir.'/Resource/.hiddenFile'); + $this->assertTrue($resource->isFresh(0)); + } + + public function testIsFreshRecursiveDetectsNewFile() + { + $dir = \dirname(__DIR__).'/Fixtures'; + $resource = new GlobResource($dir, '/*', true); + + $this->assertTrue($resource->isFresh(0)); + + touch($dir.'/Resource/TmpGlob'); + $this->assertFalse($resource->isFresh(0)); + } +} diff --git a/lib/symfony/config/Tests/Resource/ReflectionClassResourceTest.php b/lib/symfony/config/Tests/Resource/ReflectionClassResourceTest.php new file mode 100644 index 000000000..74ed6b3ed --- /dev/null +++ b/lib/symfony/config/Tests/Resource/ReflectionClassResourceTest.php @@ -0,0 +1,223 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\ReflectionClassResource; +use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class ReflectionClassResourceTest extends TestCase +{ + public function testToString() + { + $res = new ReflectionClassResource(new \ReflectionClass('ErrorException')); + + $this->assertSame('reflection.ErrorException', (string) $res); + } + + public function testSerializeUnserialize() + { + $res = new ReflectionClassResource(new \ReflectionClass(DummyInterface::class)); + $ser = unserialize(serialize($res)); + + $this->assertTrue($res->isFresh(0)); + $this->assertTrue($ser->isFresh(0)); + + $this->assertSame((string) $res, (string) $ser); + } + + public function testIsFresh() + { + $res = new ReflectionClassResource(new \ReflectionClass(__CLASS__)); + $mtime = filemtime(__FILE__); + + $this->assertTrue($res->isFresh($mtime), '->isFresh() returns true if the resource has not changed in same second'); + $this->assertTrue($res->isFresh($mtime + 10), '->isFresh() returns true if the resource has not changed'); + $this->assertTrue($res->isFresh($mtime - 86400), '->isFresh() returns true if the resource has not changed'); + } + + public function testIsFreshForDeletedResources() + { + $now = time(); + $tmp = sys_get_temp_dir().'/tmp.php'; + file_put_contents($tmp, 'assertTrue($res->isFresh($now)); + + unlink($tmp); + $this->assertFalse($res->isFresh($now), '->isFresh() returns false if the resource does not exist'); + } + + /** + * @dataProvider provideHashedSignature + */ + public function testHashedSignature($changeExpected, $changedLine, $changedCode, $setContext = null) + { + if ($setContext) { + $setContext(); + } + + $code = <<<'EOPHP' +/* 0*/ +/* 1*/ class %s extends ErrorException +/* 2*/ { +/* 3*/ const FOO = 123; +/* 4*/ +/* 5*/ public $pub = []; +/* 6*/ +/* 7*/ protected $prot; +/* 8*/ +/* 9*/ private $priv; +/*10*/ +/*11*/ public function pub($arg = null) {} +/*12*/ +/*13*/ protected function prot($a = []) {} +/*14*/ +/*15*/ private function priv() {} +/*16*/ +/*17*/ public function ccc($bar = A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC) {} +/*18*/ } +EOPHP; + + static $expectedSignature, $generateSignature; + + if (null === $expectedSignature) { + eval(sprintf($code, $class = 'Foo'.str_replace('.', '_', uniqid('', true)))); + $r = new \ReflectionClass(ReflectionClassResource::class); + $generateSignature = $r->getMethod('generateSignature'); + $generateSignature->setAccessible(true); + $generateSignature = $generateSignature->getClosure($r->newInstanceWithoutConstructor()); + $expectedSignature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class)))); + } + + $code = explode("\n", $code); + if (null !== $changedCode) { + $code[$changedLine] = $changedCode; + } + eval(sprintf(implode("\n", $code), $class = 'Foo'.str_replace('.', '_', uniqid('', true)))); + $signature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class)))); + + if ($changeExpected) { + $this->assertNotSame($expectedSignature, $signature); + } else { + $this->assertSame($expectedSignature, $signature); + } + } + + public function provideHashedSignature() + { + yield [0, 0, "// line change\n\n"]; + yield [1, 0, '/** class docblock */']; + yield [1, 1, 'abstract class %s']; + yield [1, 1, 'final class %s']; + yield [1, 1, 'class %s extends Exception']; + yield [1, 1, 'class %s implements '.DummyInterface::class]; + yield [1, 3, 'const FOO = 456;']; + yield [1, 3, 'const BAR = 123;']; + yield [1, 4, '/** pub docblock */']; + yield [1, 5, 'protected $pub = [];']; + yield [1, 5, 'public $pub = [123];']; + yield [1, 6, '/** prot docblock */']; + yield [1, 7, 'private $prot;']; + yield [0, 8, '/** priv docblock */']; + yield [0, 9, 'private $priv = 123;']; + yield [1, 10, '/** pub docblock */']; + if (\PHP_VERSION_ID >= 50600) { + yield [1, 11, 'public function pub(...$arg) {}']; + } + if (\PHP_VERSION_ID >= 70000) { + yield [1, 11, 'public function pub($arg = null): Foo {}']; + } + yield [0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"]; + yield [1, 12, '/** prot docblock */']; + yield [1, 13, 'protected function prot($a = [123]) {}']; + yield [0, 14, '/** priv docblock */']; + yield [0, 15, '']; + + if (\PHP_VERSION_ID >= 70400) { + // PHP7.4 typed properties without default value are + // undefined, make sure this doesn't throw an error + yield [1, 5, 'public array $pub;']; + yield [0, 7, 'protected int $prot;']; + yield [0, 9, 'private string $priv;']; + } + + yield [1, 17, 'public function ccc($bar = 187) {}']; + yield [1, 17, 'public function ccc($bar = ANOTHER_ONE_THAT_WILL_NEVER_BE_DEFINED_CCCCCCCCC) {}']; + yield [1, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }]; + } + + public function testEventSubscriber() + { + $res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class)); + $this->assertTrue($res->isFresh(0)); + + TestEventSubscriber::$subscribedEvents = [123]; + $this->assertFalse($res->isFresh(0)); + + $res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class)); + $this->assertTrue($res->isFresh(0)); + } + + public function testServiceSubscriber() + { + $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); + $this->assertTrue($res->isFresh(0)); + + TestServiceSubscriber::$subscribedServices = [123]; + $this->assertFalse($res->isFresh(0)); + + $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); + $this->assertTrue($res->isFresh(0)); + } + + public function testIgnoresObjectsInSignature() + { + $res = new ReflectionClassResource(new \ReflectionClass(TestServiceWithStaticProperty::class)); + $this->assertTrue($res->isFresh(0)); + + TestServiceWithStaticProperty::$initializedObject = new TestServiceWithStaticProperty(); + $this->assertTrue($res->isFresh(0)); + } +} + +interface DummyInterface +{ +} + +class TestEventSubscriber implements EventSubscriberInterface +{ + public static $subscribedEvents = []; + + public static function getSubscribedEvents() + { + return self::$subscribedEvents; + } +} + +class TestServiceSubscriber implements ServiceSubscriberInterface +{ + public static $subscribedServices = []; + + public static function getSubscribedServices() + { + return self::$subscribedServices; + } +} + +class TestServiceWithStaticProperty +{ + public static $initializedObject; +} diff --git a/lib/symfony/config/Tests/Resource/ResourceStub.php b/lib/symfony/config/Tests/Resource/ResourceStub.php new file mode 100644 index 000000000..b01729cbf --- /dev/null +++ b/lib/symfony/config/Tests/Resource/ResourceStub.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Resource; + +use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; + +class ResourceStub implements SelfCheckingResourceInterface +{ + private $fresh = true; + + public function setFresh($isFresh) + { + $this->fresh = $isFresh; + } + + public function __toString() + { + return 'stub'; + } + + public function isFresh($timestamp) + { + return $this->fresh; + } +} diff --git a/lib/symfony/config/Tests/ResourceCheckerConfigCacheTest.php b/lib/symfony/config/Tests/ResourceCheckerConfigCacheTest.php new file mode 100644 index 000000000..a2c2eeb81 --- /dev/null +++ b/lib/symfony/config/Tests/ResourceCheckerConfigCacheTest.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Config\ResourceCheckerConfigCache; +use Symfony\Component\Config\Tests\Resource\ResourceStub; + +class ResourceCheckerConfigCacheTest extends TestCase +{ + private $cacheFile = null; + + protected function setUp() + { + $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_'); + } + + protected function tearDown() + { + $files = [$this->cacheFile, "{$this->cacheFile}.meta"]; + + foreach ($files as $file) { + if (file_exists($file)) { + unlink($file); + } + } + } + + public function testGetPath() + { + $cache = new ResourceCheckerConfigCache($this->cacheFile); + + $this->assertSame($this->cacheFile, $cache->getPath()); + } + + public function testCacheIsNotFreshIfEmpty() + { + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock() + ->expects($this->never())->method('supports'); + + /* If there is nothing in the cache, it needs to be filled (and thus it's not fresh). + It does not matter if you provide checkers or not. */ + + unlink($this->cacheFile); // remove tempnam() side effect + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + + $this->assertFalse($cache->isFresh()); + } + + public function testCacheIsFreshIfNoCheckerProvided() + { + /* For example in prod mode, you may choose not to run any checkers + at all. In that case, the cache should always be considered fresh. */ + $cache = new ResourceCheckerConfigCache($this->cacheFile); + $this->assertTrue($cache->isFresh()); + } + + public function testCacheIsFreshIfEmptyCheckerIteratorProvided() + { + $cache = new ResourceCheckerConfigCache($this->cacheFile, new \ArrayIterator([])); + $this->assertTrue($cache->isFresh()); + } + + public function testResourcesWithoutcheckersAreIgnoredAndConsideredFresh() + { + /* As in the previous test, but this time we have a resource. */ + $cache = new ResourceCheckerConfigCache($this->cacheFile); + $cache->write('', [new ResourceStub()]); + + $this->assertTrue($cache->isFresh()); // no (matching) ResourceChecker passed + } + + public function testIsFreshWithchecker() + { + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); + + $checker->expects($this->once()) + ->method('supports') + ->willReturn(true); + + $checker->expects($this->once()) + ->method('isFresh') + ->willReturn(true); + + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('', [new ResourceStub()]); + + $this->assertTrue($cache->isFresh()); + } + + public function testIsNotFreshWithchecker() + { + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); + + $checker->expects($this->once()) + ->method('supports') + ->willReturn(true); + + $checker->expects($this->once()) + ->method('isFresh') + ->willReturn(false); + + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('', [new ResourceStub()]); + + $this->assertFalse($cache->isFresh()); + } + + public function testCacheIsNotFreshWhenUnserializeFails() + { + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('foo', [new FileResource(__FILE__)]); + + $metaFile = "{$this->cacheFile}.meta"; + file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile))); + + $this->assertFalse($cache->isFresh()); + } + + public function testCacheKeepsContent() + { + $cache = new ResourceCheckerConfigCache($this->cacheFile); + $cache->write('FOOBAR'); + + $this->assertSame('FOOBAR', file_get_contents($cache->getPath())); + } + + public function testCacheIsNotFreshIfNotExistsMetaFile() + { + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('foo', [new FileResource(__FILE__)]); + + $metaFile = "{$this->cacheFile}.meta"; + unlink($metaFile); + + $this->assertFalse($cache->isFresh()); + } +} diff --git a/lib/symfony/config/Tests/Util/XmlUtilsTest.php b/lib/symfony/config/Tests/Util/XmlUtilsTest.php new file mode 100644 index 000000000..4653c8d7c --- /dev/null +++ b/lib/symfony/config/Tests/Util/XmlUtilsTest.php @@ -0,0 +1,211 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Config\Tests\Util; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Util\XmlUtils; + +class XmlUtilsTest extends TestCase +{ + public function testLoadFile() + { + $fixtures = __DIR__.'/../Fixtures/Util/'; + + try { + XmlUtils::loadFile($fixtures.'invalid.xml'); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('ERROR 77', $e->getMessage()); + } + + try { + XmlUtils::loadFile($fixtures.'document_type.xml'); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('Document types are not allowed', $e->getMessage()); + } + + try { + XmlUtils::loadFile($fixtures.'invalid_schema.xml', $fixtures.'schema.xsd'); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('ERROR 1845', $e->getMessage()); + } + + try { + XmlUtils::loadFile($fixtures.'invalid_schema.xml', 'invalid_callback_or_file'); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('XSD file or callable', $e->getMessage()); + } + + $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); + $mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true)); + + try { + XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertRegExp('/The XML file ".+" is not valid\./', $e->getMessage()); + } + + $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate'])); + $this->assertSame([], libxml_get_errors()); + } + + public function testParseWithInvalidValidatorCallable() + { + $this->expectException('Symfony\Component\Config\Util\Exception\InvalidXmlException'); + $this->expectExceptionMessage('The XML is not valid'); + $fixtures = __DIR__.'/../Fixtures/Util/'; + + $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); + $mock->expects($this->once())->method('validate')->willReturn(false); + + XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), [$mock, 'validate']); + } + + public function testLoadFileWithInternalErrorsEnabled() + { + $internalErrors = libxml_use_internal_errors(true); + + $this->assertSame([], libxml_get_errors()); + $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); + $this->assertSame([], libxml_get_errors()); + + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** + * @dataProvider getDataForConvertDomToArray + */ + public function testConvertDomToArray($expected, $xml, $root = false, $checkPrefix = true) + { + $dom = new \DOMDocument(); + $dom->loadXML($root ? $xml : ''.$xml.''); + + $this->assertSame($expected, XmlUtils::convertDomElementToArray($dom->documentElement, $checkPrefix)); + } + + public function getDataForConvertDomToArray() + { + return [ + [null, ''], + ['bar', 'bar'], + [['bar' => 'foobar'], '', true], + [['foo' => null], ''], + [['foo' => 'bar'], 'bar'], + [['foo' => ['foo' => 'bar']], ''], + [['foo' => ['foo' => 0]], '0'], + [['foo' => ['foo' => 'bar']], 'bar'], + [['foo' => ['foo' => 'bar', 'value' => 'text']], 'text'], + [['foo' => ['attr' => 'bar', 'foo' => 'text']], 'text'], + [['foo' => ['bar', 'text']], 'bartext'], + [['foo' => [['foo' => 'bar'], ['foo' => 'text']]], ''], + [['foo' => ['foo' => ['bar', 'text']]], 'text'], + [['foo' => 'bar'], 'bar'], + [['foo' => 'text'], 'text'], + [['foo' => ['bar' => 'bar', 'value' => 'text']], 'text', false, false], + [['attr' => 1, 'b' => 'hello'], 'hello2', true], + ]; + } + + /** + * @dataProvider getDataForPhpize + */ + public function testPhpize($expected, $value) + { + $this->assertSame($expected, XmlUtils::phpize($value)); + } + + public function getDataForPhpize() + { + return [ + ['', ''], + [null, 'null'], + [true, 'true'], + [false, 'false'], + [null, 'Null'], + [true, 'True'], + [false, 'False'], + [0, '0'], + [1, '1'], + [-1, '-1'], + [0777, '0777'], + [255, '0xFF'], + [100.0, '1e2'], + [-120.0, '-1.2E2'], + [-10100.1, '-10100.1'], + ['-10,100.1', '-10,100.1'], + ['1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'], + ['1,2,3,4', '1,2,3,4'], + ['11,22,33,44', '11,22,33,44'], + ['11,222,333,4', '11,222,333,4'], + ['1,222,333,444', '1,222,333,444'], + ['11,222,333,444', '11,222,333,444'], + ['111,222,333,444', '111,222,333,444'], + ['1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'], + ['foo', 'foo'], + [6, '0b0110'], + ]; + } + + public function testLoadEmptyXmlFile() + { + $file = __DIR__.'/../Fixtures/foo.xml'; + + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file)); + + XmlUtils::loadFile($file); + } + + // test for issue https://github.com/symfony/symfony/issues/9731 + public function testLoadWrongEmptyXMLWithErrorHandler() + { + $originalDisableEntities = libxml_disable_entity_loader(false); + $errorReporting = error_reporting(-1); + + set_error_handler(function ($errno, $errstr) { + throw new \Exception($errstr, $errno); + }); + + $file = __DIR__.'/../Fixtures/foo.xml'; + try { + try { + XmlUtils::loadFile($file); + $this->fail('An exception should have been raised'); + } catch (\InvalidArgumentException $e) { + $this->assertEquals(sprintf('File %s does not contain valid XML, it is empty.', $file), $e->getMessage()); + } + } finally { + restore_error_handler(); + error_reporting($errorReporting); + } + + $disableEntities = libxml_disable_entity_loader(true); + libxml_disable_entity_loader($disableEntities); + + libxml_disable_entity_loader($originalDisableEntities); + + $this->assertFalse($disableEntities); + + // should not throw an exception + XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/valid.xml', __DIR__.'/../Fixtures/Util/schema.xsd'); + } +} + +interface Validator +{ + public function validate(); +} diff --git a/lib/symfony/console/Tests/ApplicationTest.php b/lib/symfony/console/Tests/ApplicationTest.php new file mode 100644 index 000000000..1ef2ed3d7 --- /dev/null +++ b/lib/symfony/console/Tests/ApplicationTest.php @@ -0,0 +1,1744 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\CommandLoader\FactoryCommandLoader; +use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; +use Symfony\Component\Console\Event\ConsoleCommandEvent; +use Symfony\Component\Console\Event\ConsoleErrorEvent; +use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\Console\Exception\CommandNotFoundException; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Console\Tester\ApplicationTester; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\EventDispatcher\EventDispatcher; + +class ApplicationTest extends TestCase +{ + protected static $fixturesPath; + + private $colSize; + + protected function setUp() + { + $this->colSize = getenv('COLUMNS'); + } + + protected function tearDown() + { + putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS'); + putenv('SHELL_VERBOSITY'); + unset($_ENV['SHELL_VERBOSITY']); + unset($_SERVER['SHELL_VERBOSITY']); + } + + public static function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/Fixtures/'); + require_once self::$fixturesPath.'/FooCommand.php'; + require_once self::$fixturesPath.'/FooOptCommand.php'; + require_once self::$fixturesPath.'/Foo1Command.php'; + require_once self::$fixturesPath.'/Foo2Command.php'; + require_once self::$fixturesPath.'/Foo3Command.php'; + require_once self::$fixturesPath.'/Foo4Command.php'; + require_once self::$fixturesPath.'/Foo5Command.php'; + require_once self::$fixturesPath.'/FooSameCaseUppercaseCommand.php'; + require_once self::$fixturesPath.'/FooSameCaseLowercaseCommand.php'; + require_once self::$fixturesPath.'/FoobarCommand.php'; + require_once self::$fixturesPath.'/BarBucCommand.php'; + require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; + require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; + require_once self::$fixturesPath.'/TestAmbiguousCommandRegistering.php'; + require_once self::$fixturesPath.'/TestAmbiguousCommandRegistering2.php'; + require_once self::$fixturesPath.'/FooHiddenCommand.php'; + } + + protected function normalizeLineBreaks($text) + { + return str_replace(PHP_EOL, "\n", $text); + } + + /** + * Replaces the dynamic placeholders of the command help text with a static version. + * The placeholder %command.full_name% includes the script path that is not predictable + * and can not be tested against. + */ + protected function ensureStaticCommandHelp(Application $application) + { + foreach ($application->all() as $command) { + $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp())); + } + } + + public function testConstructor() + { + $application = new Application('foo', 'bar'); + $this->assertEquals('foo', $application->getName(), '__construct() takes the application name as its first argument'); + $this->assertEquals('bar', $application->getVersion(), '__construct() takes the application version as its second argument'); + $this->assertEquals(['help', 'list'], array_keys($application->all()), '__construct() registered the help and list commands by default'); + } + + public function testSetGetName() + { + $application = new Application(); + $application->setName('foo'); + $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application'); + } + + public function testSetGetVersion() + { + $application = new Application(); + $application->setVersion('bar'); + $this->assertEquals('bar', $application->getVersion(), '->setVersion() sets the version of the application'); + } + + public function testGetLongVersion() + { + $application = new Application('foo', 'bar'); + $this->assertEquals('foo bar', $application->getLongVersion(), '->getLongVersion() returns the long version of the application'); + } + + public function testHelp() + { + $application = new Application(); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); + } + + public function testAll() + { + $application = new Application(); + $commands = $application->all(); + $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); + + $application->add(new \FooCommand()); + $commands = $application->all('foo'); + $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); + } + + public function testAllWithCommandLoader() + { + $application = new Application(); + $commands = $application->all(); + $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); + + $application->add(new \FooCommand()); + $commands = $application->all('foo'); + $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); + + $application->setCommandLoader(new FactoryCommandLoader([ + 'foo:bar1' => function () { return new \Foo1Command(); }, + ])); + $commands = $application->all('foo'); + $this->assertCount(2, $commands, '->all() takes a namespace as its first argument'); + $this->assertInstanceOf(\FooCommand::class, $commands['foo:bar'], '->all() returns the registered commands'); + $this->assertInstanceOf(\Foo1Command::class, $commands['foo:bar1'], '->all() returns the registered commands'); + } + + public function testRegister() + { + $application = new Application(); + $command = $application->register('foo'); + $this->assertEquals('foo', $command->getName(), '->register() registers a new command'); + } + + public function testRegisterAmbiguous() + { + $code = function (InputInterface $input, OutputInterface $output) { + $output->writeln('It works!'); + }; + + $application = new Application(); + $application->setAutoExit(false); + $application + ->register('test-foo') + ->setAliases(['test']) + ->setCode($code); + + $application + ->register('test-bar') + ->setCode($code); + + $tester = new ApplicationTester($application); + $tester->run(['test']); + $this->assertStringContainsString('It works!', $tester->getDisplay(true)); + } + + public function testAdd() + { + $application = new Application(); + $application->add($foo = new \FooCommand()); + $commands = $application->all(); + $this->assertEquals($foo, $commands['foo:bar'], '->add() registers a command'); + + $application = new Application(); + $application->addCommands([$foo = new \FooCommand(), $foo1 = new \Foo1Command()]); + $commands = $application->all(); + $this->assertEquals([$foo, $foo1], [$commands['foo:bar'], $commands['foo:bar1']], '->addCommands() registers an array of commands'); + } + + public function testAddCommandWithEmptyConstructor() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('Command class "Foo5Command" is not correctly initialized. You probably forgot to call the parent constructor.'); + $application = new Application(); + $application->add(new \Foo5Command()); + } + + public function testHasGet() + { + $application = new Application(); + $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered'); + $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered'); + + $application->add($foo = new \FooCommand()); + $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered'); + $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); + $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); + + $application = new Application(); + $application->add($foo = new \FooCommand()); + // simulate --help + $r = new \ReflectionObject($application); + $p = $r->getProperty('wantHelps'); + $p->setAccessible(true); + $p->setValue($application, true); + $command = $application->get('foo:bar'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); + } + + public function testHasGetWithCommandLoader() + { + $application = new Application(); + $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered'); + $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered'); + + $application->add($foo = new \FooCommand()); + $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered'); + $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); + $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); + + $application->setCommandLoader(new FactoryCommandLoader([ + 'foo:bar1' => function () { return new \Foo1Command(); }, + ])); + + $this->assertTrue($application->has('afoobar'), '->has() returns true if an instance is registered for an alias even with command loader'); + $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns an instance by name even with command loader'); + $this->assertEquals($foo, $application->get('afoobar'), '->get() returns an instance by alias even with command loader'); + $this->assertTrue($application->has('foo:bar1'), '->has() returns true for commands registered in the loader'); + $this->assertInstanceOf(\Foo1Command::class, $foo1 = $application->get('foo:bar1'), '->get() returns a command by name from the command loader'); + $this->assertTrue($application->has('afoobar1'), '->has() returns true for commands registered in the loader'); + $this->assertEquals($foo1, $application->get('afoobar1'), '->get() returns a command by name from the command loader'); + } + + public function testSilentHelp() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $tester = new ApplicationTester($application); + $tester->run(['-h' => true, '-q' => true], ['decorated' => false]); + + $this->assertEmpty($tester->getDisplay(true)); + } + + public function testGetInvalidCommand() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('The command "foofoo" does not exist.'); + $application = new Application(); + $application->get('foofoo'); + } + + public function testGetNamespaces() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $this->assertEquals(['foo'], $application->getNamespaces(), '->getNamespaces() returns an array of unique used namespaces'); + } + + public function testFindNamespace() + { + $application = new Application(); + $application->add(new \FooCommand()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); + $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); + $application->add(new \Foo2Command()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); + } + + public function testFindNamespaceWithSubnamespaces() + { + $application = new Application(); + $application->add(new \FooSubnamespaced1Command()); + $application->add(new \FooSubnamespaced2Command()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns commands even if the commands are only contained in subnamespaces'); + } + + public function testFindAmbiguousNamespace() + { + $application = new Application(); + $application->add(new \BarBucCommand()); + $application->add(new \FooCommand()); + $application->add(new \Foo2Command()); + + $expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1"; + + $this->expectException(CommandNotFoundException::class); + $this->expectExceptionMessage($expectedMsg); + + $application->findNamespace('f'); + } + + public function testFindNonAmbiguous() + { + $application = new Application(); + $application->add(new \TestAmbiguousCommandRegistering()); + $application->add(new \TestAmbiguousCommandRegistering2()); + $this->assertEquals('test-ambiguous', $application->find('test')->getName()); + } + + public function testFindInvalidNamespace() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('There are no commands defined in the "bar" namespace.'); + $application = new Application(); + $application->findNamespace('bar'); + } + + public function testFindUniqueNameButNamespaceName() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('Command "foo1" is not defined'); + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + $application->find($commandName = 'foo1'); + } + + public function testFind() + { + $application = new Application(); + $application->add(new \FooCommand()); + + $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + } + + public function testFindCaseSensitiveFirst() + { + $application = new Application(); + $application->add(new \FooSameCaseUppercaseCommand()); + $application->add(new \FooSameCaseLowercaseCommand()); + + $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:B'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:BAR'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation is the correct case'); + } + + public function testFindCaseInsensitiveAsFallback() + { + $application = new Application(); + $application->add(new \FooSameCaseLowercaseCommand()); + + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:B'), '->find() will fallback to case insensitivity'); + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will fallback to case insensitivity'); + } + + public function testFindCaseInsensitiveSuggestions() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('Command "FoO:BaR" is ambiguous'); + $application = new Application(); + $application->add(new \FooSameCaseLowercaseCommand()); + $application->add(new \FooSameCaseUppercaseCommand()); + + $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will find two suggestions with case insensitivity'); + } + + public function testFindWithCommandLoader() + { + $application = new Application(); + $application->setCommandLoader(new FactoryCommandLoader([ + 'foo:bar' => $f = function () { return new \FooCommand(); }, + ])); + + $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + } + + /** + * @dataProvider provideAmbiguousAbbreviations + */ + public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) + { + putenv('COLUMNS=120'); + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage($expectedExceptionMessage); + + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + $application->find($abbreviation); + } + + public function provideAmbiguousAbbreviations() + { + return [ + ['f', 'Command "f" is not defined.'], + [ + 'a', + "Command \"a\" is ambiguous.\nDid you mean one of these?\n". + " afoobar The foo:bar command\n". + " afoobar1 The foo:bar1 command\n". + ' afoobar2 The foo1:bar command', + ], + [ + 'foo:b', + "Command \"foo:b\" is ambiguous.\nDid you mean one of these?\n". + " foo:bar The foo:bar command\n". + " foo:bar1 The foo:bar1 command\n". + ' foo1:bar The foo1:bar command', + ], + ]; + } + + public function testFindCommandEqualNamespace() + { + $application = new Application(); + $application->add(new \Foo3Command()); + $application->add(new \Foo4Command()); + + $this->assertInstanceOf('Foo3Command', $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); + $this->assertInstanceOf('Foo4Command', $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); + } + + public function testFindCommandWithAmbiguousNamespacesButUniqueName() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \FoobarCommand()); + + $this->assertInstanceOf('FoobarCommand', $application->find('f:f')); + } + + public function testFindCommandWithMissingNamespace() + { + $application = new Application(); + $application->add(new \Foo4Command()); + + $this->assertInstanceOf('Foo4Command', $application->find('f::t')); + } + + /** + * @dataProvider provideInvalidCommandNamesSingle + */ + public function testFindAlternativeExceptionMessageSingle($name) + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('Did you mean this'); + $application = new Application(); + $application->add(new \Foo3Command()); + $application->find($name); + } + + public function provideInvalidCommandNamesSingle() + { + return [ + ['foo3:barr'], + ['fooo3:bar'], + ]; + } + + public function testFindAlternativeExceptionMessageMultiple() + { + putenv('COLUMNS=120'); + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + // Command + plural + try { + $application->find('foo:baR'); + $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertRegExp('/foo1:bar/', $e->getMessage()); + $this->assertRegExp('/foo:bar/', $e->getMessage()); + } + + // Namespace + plural + try { + $application->find('foo2:bar'); + $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertRegExp('/foo1/', $e->getMessage()); + } + + $application->add(new \Foo3Command()); + $application->add(new \Foo4Command()); + + // Subnamespace + plural + try { + $application->find('foo3:'); + $this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e); + $this->assertRegExp('/foo3:bar/', $e->getMessage()); + $this->assertRegExp('/foo3:bar:toh/', $e->getMessage()); + } + } + + public function testFindAlternativeCommands() + { + $application = new Application(); + + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + try { + $application->find($commandName = 'Unknown command'); + $this->fail('->find() throws a CommandNotFoundException if command does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); + $this->assertSame([], $e->getAlternatives()); + $this->assertEquals(sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives'); + } + + // Test if "bar1" command throw a "CommandNotFoundException" and does not contain + // "foo:bar" as alternative because "bar1" is too far from "foo:bar" + try { + $application->find($commandName = 'bar1'); + $this->fail('->find() throws a CommandNotFoundException if command does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); + $this->assertSame(['afoobar1', 'foo:bar1'], $e->getAlternatives()); + $this->assertRegExp(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertRegExp('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"'); + $this->assertRegExp('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"'); + $this->assertNotRegExp('/foo:bar(?>!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative'); + } + } + + public function testFindAlternativeCommandsWithAnAlias() + { + $fooCommand = new \FooCommand(); + $fooCommand->setAliases(['foo2']); + + $application = new Application(); + $application->add($fooCommand); + + $result = $application->find('foo'); + + $this->assertSame($fooCommand, $result); + } + + public function testFindAlternativeNamespace() + { + $application = new Application(); + + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + $application->add(new \Foo3Command()); + + try { + $application->find('Unknown-namespace:Unknown-command'); + $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist'); + $this->assertSame([], $e->getAlternatives()); + $this->assertEquals('There are no commands defined in the "Unknown-namespace" namespace.', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, without alternatives'); + } + + try { + $application->find('foo2:command'); + $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist'); + $this->assertCount(3, $e->getAlternatives()); + $this->assertContains('foo', $e->getAlternatives()); + $this->assertContains('foo1', $e->getAlternatives()); + $this->assertContains('foo3', $e->getAlternatives()); + $this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative'); + $this->assertRegExp('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"'); + $this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"'); + $this->assertRegExp('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"'); + } + } + + public function testFindAlternativesOutput() + { + $application = new Application(); + + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + $application->add(new \Foo3Command()); + $application->add(new \FooHiddenCommand()); + + $expectedAlternatives = [ + 'afoobar', + 'afoobar1', + 'afoobar2', + 'foo1:bar', + 'foo3:bar', + 'foo:bar', + 'foo:bar1', + ]; + + try { + $application->find('foo'); + $this->fail('->find() throws a CommandNotFoundException if command is not defined'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command is not defined'); + $this->assertSame($expectedAlternatives, $e->getAlternatives()); + + $this->assertRegExp('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage()); + } + } + + public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() + { + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock(); + $application->expects($this->once()) + ->method('getNamespaces') + ->willReturn(['foo:sublong', 'bar:sub']); + + $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); + } + + public function testFindWithDoubleColonInNameThrowsException() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectExceptionMessage('Command "foo::bar" is not defined.'); + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo4Command()); + $application->find('foo::bar'); + } + + public function testSetCatchExceptions() + { + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=120'); + $tester = new ApplicationTester($application); + + $application->setCatchExceptions(true); + $this->assertTrue($application->areExceptionsCaught()); + + $tester->run(['command' => 'foo'], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); + + $tester->run(['command' => 'foo'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getErrorOutput(true), '->setCatchExceptions() sets the catch exception flag'); + $this->assertSame('', $tester->getDisplay(true)); + + $application->setCatchExceptions(false); + try { + $tester->run(['command' => 'foo'], ['decorated' => false]); + $this->fail('->setCatchExceptions() sets the catch exception flag'); + } catch (\Exception $e) { + $this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag'); + $this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag'); + } + } + + public function testAutoExitSetting() + { + $application = new Application(); + $this->assertTrue($application->isAutoExitEnabled()); + + $application->setAutoExit(false); + $this->assertFalse($application->isAutoExitEnabled()); + } + + public function testRenderException() + { + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=120'); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exception'); + + $tester->run(['command' => 'foo'], ['decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE, 'capture_stderr_separately' => true]); + $this->assertStringContainsString('Exception trace', $tester->getErrorOutput(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); + + $tester->run(['command' => 'list', '--foo' => true], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getErrorOutput(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); + + $application->add(new \Foo3Command()); + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo3:bar'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $tester->run(['command' => 'foo3:bar'], ['decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]); + $this->assertRegExp('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose'); + $this->assertRegExp('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose'); + $this->assertRegExp('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose'); + + $tester->run(['command' => 'foo3:bar'], ['decorated' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $tester->run(['command' => 'foo3:bar'], ['decorated' => true, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=32'); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getErrorOutput(true), '->renderException() wraps messages when they are bigger than the terminal'); + putenv('COLUMNS=120'); + } + + public function testRenderExceptionWithDoubleWidthCharacters() + { + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=120'); + $application->register('foo')->setCode(function () { + throw new \Exception('エラーメッセージ'); + }); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $tester->run(['command' => 'foo'], ['decorated' => true, 'capture_stderr_separately' => true]); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=32'); + $application->register('foo')->setCode(function () { + throw new \Exception('コマンドの実行中にエラーが発生しました。'); + }); + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo'], ['decorated' => false, 'capture_stderr_separately' => true]); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getErrorOutput(true), '->renderException() wraps messages when they are bigger than the terminal'); + putenv('COLUMNS=120'); + } + + public function testRenderExceptionEscapesLines() + { + $application = new Application(); + $application->setAutoExit(false); + putenv('COLUMNS=22'); + $application->register('foo')->setCode(function () { + throw new \Exception('dont break here !'); + }); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo'], ['decorated' => false]); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_escapeslines.txt', $tester->getDisplay(true), '->renderException() escapes lines containing formatting'); + putenv('COLUMNS=120'); + } + + public function testRenderExceptionLineBreaks() + { + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getTerminalWidth'])->getMock(); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->willReturn(120); + $application->register('foo')->setCode(function () { + throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); + }); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo'], ['decorated' => false]); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_linebreaks.txt', $tester->getDisplay(true), '->renderException() keep multiple line breaks'); + } + + public function testRenderExceptionStackTraceContainsRootException() + { + $application = new Application(); + $application->setAutoExit(false); + $application->register('foo')->setCode(function () { + throw new \Exception('Verbose exception'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo'], ['decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]); + + $this->assertStringContainsString(sprintf('() at %s:', __FILE__), $tester->getDisplay()); + } + + public function testRun() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add($command = new \Foo1Command()); + $_SERVER['argv'] = ['cli.php', 'foo:bar1']; + + ob_start(); + $application->run(); + ob_end_clean(); + + $this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given'); + $this->assertInstanceOf('Symfony\Component\Console\Output\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $this->ensureStaticCommandHelp($application); + $tester = new ApplicationTester($application); + + $tester->run([], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); + + $tester->run(['--help' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); + + $tester->run(['-h' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); + + $tester->run(['command' => 'list', '--help' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); + + $tester->run(['command' => 'list', '-h' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); + + $tester->run(['--ansi' => true]); + $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed'); + + $tester->run(['--no-ansi' => true]); + $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed'); + + $tester->run(['--version' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); + + $tester->run(['-V' => true], ['decorated' => false]); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); + + $tester->run(['command' => 'list', '--quiet' => true]); + $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); + $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed'); + + $tester->run(['command' => 'list', '-q' => true]); + $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed'); + $this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed'); + + $tester->run(['command' => 'list', '--verbose' => true]); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed'); + + $tester->run(['command' => 'list', '--verbose' => 1]); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose=1 is passed'); + + $tester->run(['command' => 'list', '--verbose' => 2]); + $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to very verbose if --verbose=2 is passed'); + + $tester->run(['command' => 'list', '--verbose' => 3]); + $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to debug if --verbose=3 is passed'); + + $tester->run(['command' => 'list', '--verbose' => 4]); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if unknown --verbose level is passed'); + + $tester->run(['command' => 'list', '-v' => true]); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $tester->run(['command' => 'list', '-vv' => true]); + $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $tester->run(['command' => 'list', '-vvv' => true]); + $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add(new \FooCommand()); + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'foo:bar', '--no-interaction' => true], ['decorated' => false]); + $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); + + $tester->run(['command' => 'foo:bar', '-n' => true], ['decorated' => false]); + $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); + } + + public function testRunWithGlobalOptionAndNoCommand() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->getDefinition()->addOption(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)); + + $output = new StreamOutput(fopen('php://memory', 'w', false)); + $input = new ArgvInput(['cli.php', '--foo', 'bar']); + + $this->assertSame(0, $application->run($input, $output)); + } + + /** + * Issue #9285. + * + * If the "verbose" option is just before an argument in ArgvInput, + * an argument value should not be treated as verbosity value. + * This test will fail with "Not enough arguments." if broken + */ + public function testVerboseValueNotBreakArguments() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add(new \FooCommand()); + + $output = new StreamOutput(fopen('php://memory', 'w', false)); + + $input = new ArgvInput(['cli.php', '-v', 'foo:bar']); + $application->run($input, $output); + + $this->addToAssertionCount(1); + + $input = new ArgvInput(['cli.php', '--verbose', 'foo:bar']); + $application->run($input, $output); + + $this->addToAssertionCount(1); + } + + public function testRunReturnsIntegerExitCode() + { + $exception = new \Exception('', 4); + + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['doRun'])->getMock(); + $application->setAutoExit(false); + $application->expects($this->once()) + ->method('doRun') + ->willThrowException($exception); + + $exitCode = $application->run(new ArrayInput([]), new NullOutput()); + + $this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception'); + } + + public function testRunDispatchesIntegerExitCode() + { + $passedRightValue = false; + + // We can assume here that some other test asserts that the event is dispatched at all + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { + $passedRightValue = (4 === $event->getExitCode()); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \Exception('', 4); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'test']); + + $this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event'); + } + + public function testRunReturnsExitCodeOneForExceptionCodeZero() + { + $exception = new \Exception('', 0); + + $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['doRun'])->getMock(); + $application->setAutoExit(false); + $application->expects($this->once()) + ->method('doRun') + ->willThrowException($exception); + + $exitCode = $application->run(new ArrayInput([]), new NullOutput()); + + $this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0'); + } + + public function testRunDispatchesExitCodeOneForExceptionCodeZero() + { + $passedRightValue = false; + + // We can assume here that some other test asserts that the event is dispatched at all + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { + $passedRightValue = (1 === $event->getExitCode()); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \Exception(); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'test']); + + $this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event'); + } + + public function testAddingOptionWithDuplicateShortcut() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('An option with shortcut "e" already exists.'); + $dispatcher = new EventDispatcher(); + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->setDispatcher($dispatcher); + + $application->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'Environment')); + + $application + ->register('foo') + ->setAliases(['f']) + ->setDefinition([new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')]) + ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ; + + $input = new ArrayInput(['command' => 'foo']); + $output = new NullOutput(); + + $application->run($input, $output); + } + + /** + * @dataProvider getAddingAlreadySetDefinitionElementData + */ + public function testAddingAlreadySetDefinitionElementData($def) + { + $this->expectException('LogicException'); + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application + ->register('foo') + ->setDefinition([$def]) + ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ; + + $input = new ArrayInput(['command' => 'foo']); + $output = new NullOutput(); + $application->run($input, $output); + } + + public function getAddingAlreadySetDefinitionElementData() + { + return [ + [new InputArgument('command', InputArgument::REQUIRED)], + [new InputOption('quiet', '', InputOption::VALUE_NONE)], + [new InputOption('query', 'q', InputOption::VALUE_NONE)], + ]; + } + + public function testGetDefaultHelperSetReturnsDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + } + + public function testAddingSingleHelperSetOverwritesDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setHelperSet(new HelperSet([new FormatterHelper()])); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + + // no other default helper set should be returned + $this->assertFalse($helperSet->has('dialog')); + $this->assertFalse($helperSet->has('progress')); + } + + public function testOverwritingDefaultHelperSetOverwritesDefaultValues() + { + $application = new CustomApplication(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setHelperSet(new HelperSet([new FormatterHelper()])); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + + // no other default helper set should be returned + $this->assertFalse($helperSet->has('dialog')); + $this->assertFalse($helperSet->has('progress')); + } + + public function testGetDefaultInputDefinitionReturnsDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $inputDefinition = $application->getDefinition(); + + $this->assertTrue($inputDefinition->hasArgument('command')); + + $this->assertTrue($inputDefinition->hasOption('help')); + $this->assertTrue($inputDefinition->hasOption('quiet')); + $this->assertTrue($inputDefinition->hasOption('verbose')); + $this->assertTrue($inputDefinition->hasOption('version')); + $this->assertTrue($inputDefinition->hasOption('ansi')); + $this->assertTrue($inputDefinition->hasOption('no-ansi')); + $this->assertTrue($inputDefinition->hasOption('no-interaction')); + } + + public function testOverwritingDefaultInputDefinitionOverwritesDefaultValues() + { + $application = new CustomApplication(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $inputDefinition = $application->getDefinition(); + + // check whether the default arguments and options are not returned any more + $this->assertFalse($inputDefinition->hasArgument('command')); + + $this->assertFalse($inputDefinition->hasOption('help')); + $this->assertFalse($inputDefinition->hasOption('quiet')); + $this->assertFalse($inputDefinition->hasOption('verbose')); + $this->assertFalse($inputDefinition->hasOption('version')); + $this->assertFalse($inputDefinition->hasOption('ansi')); + $this->assertFalse($inputDefinition->hasOption('no-ansi')); + $this->assertFalse($inputDefinition->hasOption('no-interaction')); + + $this->assertTrue($inputDefinition->hasOption('custom')); + } + + public function testSettingCustomInputDefinitionOverwritesDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setDefinition(new InputDefinition([new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.')])); + + $inputDefinition = $application->getDefinition(); + + // check whether the default arguments and options are not returned any more + $this->assertFalse($inputDefinition->hasArgument('command')); + + $this->assertFalse($inputDefinition->hasOption('help')); + $this->assertFalse($inputDefinition->hasOption('quiet')); + $this->assertFalse($inputDefinition->hasOption('verbose')); + $this->assertFalse($inputDefinition->hasOption('version')); + $this->assertFalse($inputDefinition->hasOption('ansi')); + $this->assertFalse($inputDefinition->hasOption('no-ansi')); + $this->assertFalse($inputDefinition->hasOption('no-interaction')); + + $this->assertTrue($inputDefinition->hasOption('custom')); + } + + public function testRunWithDispatcher() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setDispatcher($this->getDispatcher()); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + $this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay()); + } + + public function testRunWithExceptionAndDispatcher() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('error'); + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \RuntimeException('foo'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + } + + public function testRunDispatchesAllEventsWithException() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + + throw new \RuntimeException('foo'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + $this->assertStringContainsString('before.foo.error.after.', $tester->getDisplay()); + } + + public function testRunDispatchesAllEventsWithExceptionInListener() + { + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.command', function () { + throw new \RuntimeException('foo'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + $this->assertStringContainsString('before.error.after.', $tester->getDisplay()); + } + + /** + * @requires PHP 7 + */ + public function testRunWithError() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dym.'); + + throw new \Error('dymerr'); + }); + + $tester = new ApplicationTester($application); + + try { + $tester->run(['command' => 'dym']); + $this->fail('Error expected.'); + } catch (\Error $e) { + $this->assertSame('dymerr', $e->getMessage()); + } + } + + public function testRunAllowsErrorListenersToSilenceTheException() + { + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $event->getOutput()->write('silenced.'); + + $event->setExitCode(0); + }); + + $dispatcher->addListener('console.command', function () { + throw new \RuntimeException('foo'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + $this->assertStringContainsString('before.error.silenced.after.', $tester->getDisplay()); + $this->assertEquals(ConsoleCommandEvent::RETURN_CODE_DISABLED, $tester->getStatusCode()); + } + + public function testConsoleErrorEventIsTriggeredOnCommandNotFound() + { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $this->assertNull($event->getCommand()); + $this->assertInstanceOf(CommandNotFoundException::class, $event->getError()); + $event->getOutput()->write('silenced command not found'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'unknown']); + $this->assertStringContainsString('silenced command not found', $tester->getDisplay()); + $this->assertEquals(1, $tester->getStatusCode()); + } + + /** + * @group legacy + * @expectedDeprecation The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead. + */ + public function testLegacyExceptionListenersAreStillTriggered() + { + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { + $event->getOutput()->write('caught.'); + + $event->setException(new \RuntimeException('replaced in caught.')); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \RuntimeException('foo'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + $this->assertStringContainsString('before.caught.error.after.', $tester->getDisplay()); + $this->assertStringContainsString('replaced in caught.', $tester->getDisplay()); + } + + /** + * @requires PHP 7 + */ + public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->setDispatcher(new EventDispatcher()); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + new \UnknownClass(); + }); + + $tester = new ApplicationTester($application); + + try { + $tester->run(['command' => 'dym']); + $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); + } catch (\Error $e) { + $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); + } + } + + /** + * @requires PHP 7 + */ + public function testRunWithErrorAndDispatcher() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('error'); + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dym.'); + + throw new \Error('dymerr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'dym']); + $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + } + + /** + * @requires PHP 7 + */ + public function testRunDispatchesAllEventsWithError() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dym.'); + + throw new \Error('dymerr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'dym']); + $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + } + + /** + * @requires PHP 7 + */ + public function testRunWithErrorFailingStatusCode() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('dus.'); + + throw new \Error('duserr'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'dus']); + $this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1'); + } + + public function testRunWithDispatcherSkippingCommand() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher(true)); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $exitCode = $tester->run(['command' => 'foo']); + $this->assertStringContainsString('before.after.', $tester->getDisplay()); + $this->assertEquals(ConsoleCommandEvent::RETURN_CODE_DISABLED, $exitCode); + } + + public function testRunWithDispatcherAccessingInputOptions() + { + $noInteractionValue = null; + $quietValue = null; + + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { + $input = $event->getInput(); + + $noInteractionValue = $input->getOption('no-interaction'); + $quietValue = $input->getOption('quiet'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo', '--no-interaction' => true]); + + $this->assertTrue($noInteractionValue); + $this->assertFalse($quietValue); + } + + public function testRunWithDispatcherAddingInputOptions() + { + $extraValue = null; + + $dispatcher = $this->getDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { + $definition = $event->getCommand()->getDefinition(); + $input = $event->getInput(); + + $definition->addOption(new InputOption('extra', null, InputOption::VALUE_REQUIRED)); + $input->bind($definition); + + $extraValue = $input->getOption('extra'); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo', '--extra' => 'some test value']); + + $this->assertEquals('some test value', $extraValue); + } + + /** + * @group legacy + */ + public function testTerminalDimensions() + { + $application = new Application(); + $originalDimensions = $application->getTerminalDimensions(); + $this->assertCount(2, $originalDimensions); + + $width = 80; + if ($originalDimensions[0] == $width) { + $width = 100; + } + + $application->setTerminalDimensions($width, 80); + $this->assertSame([$width, 80], $application->getTerminalDimensions()); + } + + public function testSetRunCustomDefaultCommand() + { + $command = new \FooCommand(); + + $application = new Application(); + $application->setAutoExit(false); + $application->add($command); + $application->setDefaultCommand($command->getName()); + + $tester = new ApplicationTester($application); + $tester->run([], ['interactive' => false]); + $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + + $application = new CustomDefaultCommandApplication(); + $application->setAutoExit(false); + + $tester = new ApplicationTester($application); + $tester->run([], ['interactive' => false]); + + $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + } + + public function testSetRunCustomDefaultCommandWithOption() + { + $command = new \FooOptCommand(); + + $application = new Application(); + $application->setAutoExit(false); + $application->add($command); + $application->setDefaultCommand($command->getName()); + + $tester = new ApplicationTester($application); + $tester->run(['--fooopt' => 'opt'], ['interactive' => false]); + + $this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + } + + public function testSetRunCustomSingleCommand() + { + $command = new \FooCommand(); + + $application = new Application(); + $application->setAutoExit(false); + $application->add($command); + $application->setDefaultCommand($command->getName(), true); + + $tester = new ApplicationTester($application); + + $tester->run([]); + $this->assertStringContainsString('called', $tester->getDisplay()); + + $tester->run(['--help' => true]); + $this->assertStringContainsString('The foo:bar command', $tester->getDisplay()); + } + + public function testRunLazyCommandService() + { + $container = new ContainerBuilder(); + $container->addCompilerPass(new AddConsoleCommandPass()); + $container + ->register('lazy-command', LazyCommand::class) + ->addTag('console.command', ['command' => 'lazy:command']) + ->addTag('console.command', ['command' => 'lazy:alias']) + ->addTag('console.command', ['command' => 'lazy:alias2']); + $container->compile(); + + $application = new Application(); + $application->setCommandLoader($container->get('console.command_loader')); + $application->setAutoExit(false); + + $tester = new ApplicationTester($application); + + $tester->run(['command' => 'lazy:command']); + $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); + + $tester->run(['command' => 'lazy:alias']); + $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); + + $tester->run(['command' => 'lazy:alias2']); + $this->assertSame("lazy-command called\n", $tester->getDisplay(true)); + + $command = $application->get('lazy:command'); + $this->assertSame(['lazy:alias', 'lazy:alias2'], $command->getAliases()); + } + + public function testGetDisabledLazyCommand() + { + $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $application = new Application(); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => function () { return new DisabledCommand(); }])); + $application->get('disabled'); + } + + public function testHasReturnsFalseForDisabledLazyCommand() + { + $application = new Application(); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => function () { return new DisabledCommand(); }])); + $this->assertFalse($application->has('disabled')); + } + + public function testAllExcludesDisabledLazyCommand() + { + $application = new Application(); + $application->setCommandLoader(new FactoryCommandLoader(['disabled' => function () { return new DisabledCommand(); }])); + $this->assertArrayNotHasKey('disabled', $application->all()); + } + + protected function getDispatcher($skipCommand = false) + { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { + $event->getOutput()->write('before.'); + + if ($skipCommand) { + $event->disableCommand(); + } + }); + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { + $event->getOutput()->writeln('after.'); + + if (!$skipCommand) { + $event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED); + } + }); + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { + $event->getOutput()->write('error.'); + + $event->setError(new \LogicException('error.', $event->getExitCode(), $event->getError())); + }); + + return $dispatcher; + } + + /** + * @requires PHP 7 + */ + public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setDispatcher(new EventDispatcher()); + + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { + new \UnknownClass(); + }); + + $tester = new ApplicationTester($application); + + try { + $tester->run(['command' => 'dym']); + $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); + } catch (\Error $e) { + $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); + } + } +} + +class CustomApplication extends Application +{ + /** + * Overwrites the default input definition. + * + * @return InputDefinition An InputDefinition instance + */ + protected function getDefaultInputDefinition() + { + return new InputDefinition([new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.')]); + } + + /** + * Gets the default helper set with the helpers that should always be available. + * + * @return HelperSet A HelperSet instance + */ + protected function getDefaultHelperSet() + { + return new HelperSet([new FormatterHelper()]); + } +} + +class CustomDefaultCommandApplication extends Application +{ + /** + * Overwrites the constructor in order to set a different default command. + */ + public function __construct() + { + parent::__construct(); + + $command = new \FooCommand(); + $this->add($command); + $this->setDefaultCommand($command->getName()); + } +} + +class LazyCommand extends Command +{ + public function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('lazy-command called'); + } +} + +class DisabledCommand extends Command +{ + public function isEnabled() + { + return false; + } +} diff --git a/lib/symfony/console/Tests/Command/CommandTest.php b/lib/symfony/console/Tests/Command/CommandTest.php new file mode 100644 index 000000000..207302fdf --- /dev/null +++ b/lib/symfony/console/Tests/Command/CommandTest.php @@ -0,0 +1,430 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\StringInput; +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Tester\CommandTester; + +class CommandTest extends TestCase +{ + protected static $fixturesPath; + + public static function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../Fixtures/'; + require_once self::$fixturesPath.'/TestCommand.php'; + } + + public function testConstructor() + { + $command = new Command('foo:bar'); + $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); + } + + public function testCommandNameCannotBeEmpty() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.'); + (new Application())->add(new Command()); + } + + public function testSetApplication() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); + $this->assertEquals($application->getHelperSet(), $command->getHelperSet()); + } + + public function testSetApplicationNull() + { + $command = new \TestCommand(); + $command->setApplication(null); + $this->assertNull($command->getHelperSet()); + } + + public function testSetGetDefinition() + { + $command = new \TestCommand(); + $ret = $command->setDefinition($definition = new InputDefinition()); + $this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface'); + $this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance'); + $command->setDefinition([new InputArgument('foo'), new InputOption('bar')]); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $command->setDefinition(new InputDefinition()); + } + + public function testAddArgument() + { + $command = new \TestCommand(); + $ret = $command->addArgument('foo'); + $this->assertEquals($command, $ret, '->addArgument() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); + } + + public function testAddOption() + { + $command = new \TestCommand(); + $ret = $command->addOption('foo'); + $this->assertEquals($command, $ret, '->addOption() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); + } + + public function testSetHidden() + { + $command = new \TestCommand(); + $command->setHidden(true); + $this->assertTrue($command->isHidden()); + } + + public function testGetNamespaceGetNameSetName() + { + $command = new \TestCommand(); + $this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name'); + $command->setName('foo'); + $this->assertEquals('foo', $command->getName(), '->setName() sets the command name'); + + $ret = $command->setName('foobar:bar'); + $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); + $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); + } + + /** + * @dataProvider provideInvalidCommandNames + */ + public function testInvalidCommandNames($name) + { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name)); + + $command = new \TestCommand(); + $command->setName($name); + } + + public function provideInvalidCommandNames() + { + return [ + [''], + ['foo:'], + ]; + } + + public function testGetSetDescription() + { + $command = new \TestCommand(); + $this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description'); + $ret = $command->setDescription('description1'); + $this->assertEquals($command, $ret, '->setDescription() implements a fluent interface'); + $this->assertEquals('description1', $command->getDescription(), '->setDescription() sets the description'); + } + + public function testGetSetHelp() + { + $command = new \TestCommand(); + $this->assertEquals('help', $command->getHelp(), '->getHelp() returns the help'); + $ret = $command->setHelp('help1'); + $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); + $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); + $command->setHelp(''); + $this->assertEquals('', $command->getHelp(), '->getHelp() does not fall back to the description'); + } + + public function testGetProcessedHelp() + { + $command = new \TestCommand(); + $command->setHelp('The %command.name% command does... Example: php %command.full_name%.'); + $this->assertStringContainsString('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly'); + $this->assertStringNotContainsString('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%'); + + $command = new \TestCommand(); + $command->setHelp(''); + $this->assertStringContainsString('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description'); + + $command = new \TestCommand(); + $command->setHelp('The %command.name% command does... Example: php %command.full_name%.'); + $application = new Application(); + $application->add($command); + $application->setDefaultCommand('namespace:name', true); + $this->assertStringContainsString('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly in single command applications'); + $this->assertStringNotContainsString('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name% in single command applications'); + } + + public function testGetSetAliases() + { + $command = new \TestCommand(); + $this->assertEquals(['name'], $command->getAliases(), '->getAliases() returns the aliases'); + $ret = $command->setAliases(['name1']); + $this->assertEquals($command, $ret, '->setAliases() implements a fluent interface'); + $this->assertEquals(['name1'], $command->getAliases(), '->setAliases() sets the aliases'); + } + + public function testSetAliasesNull() + { + $command = new \TestCommand(); + $this->expectException('InvalidArgumentException'); + $command->setAliases(null); + } + + public function testGetSynopsis() + { + $command = new \TestCommand(); + $command->addOption('foo'); + $command->addArgument('bar'); + $this->assertEquals('namespace:name [--foo] [--] []', $command->getSynopsis(), '->getSynopsis() returns the synopsis'); + } + + public function testAddGetUsages() + { + $command = new \TestCommand(); + $command->addUsage('foo1'); + $command->addUsage('foo2'); + $this->assertContains('namespace:name foo1', $command->getUsages()); + $this->assertContains('namespace:name foo2', $command->getUsages()); + } + + public function testGetHelper() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $formatterHelper = new FormatterHelper(); + $this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper'); + } + + public function testGetHelperWithoutHelperSet() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('Cannot retrieve helper "formatter" because there is no HelperSet defined.'); + $command = new \TestCommand(); + $command->getHelper('formatter'); + } + + public function testMergeApplicationDefinition() + { + $application1 = new Application(); + $application1->getDefinition()->addArguments([new InputArgument('foo')]); + $application1->getDefinition()->addOptions([new InputOption('bar')]); + $command = new \TestCommand(); + $command->setApplication($application1); + $command->setDefinition($definition = new InputDefinition([new InputArgument('bar'), new InputOption('foo')])); + + $r = new \ReflectionObject($command); + $m = $r->getMethod('mergeApplicationDefinition'); + $m->setAccessible(true); + $m->invoke($command); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); + + $m->invoke($command); + $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); + } + + public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs() + { + $application1 = new Application(); + $application1->getDefinition()->addArguments([new InputArgument('foo')]); + $application1->getDefinition()->addOptions([new InputOption('bar')]); + $command = new \TestCommand(); + $command->setApplication($application1); + $command->setDefinition($definition = new InputDefinition([])); + + $r = new \ReflectionObject($command); + $m = $r->getMethod('mergeApplicationDefinition'); + $m->setAccessible(true); + $m->invoke($command, false); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the command options'); + $this->assertFalse($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments'); + + $m->invoke($command, true); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments'); + + $m->invoke($command); + $this->assertEquals(2, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments'); + } + + public function testRunInteractive() + { + $tester = new CommandTester(new \TestCommand()); + + $tester->execute([], ['interactive' => true]); + + $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + } + + public function testRunNonInteractive() + { + $tester = new CommandTester(new \TestCommand()); + + $tester->execute([], ['interactive' => false]); + + $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + } + + public function testExecuteMethodNeedsToBeOverridden() + { + $this->expectException('LogicException'); + $this->expectExceptionMessage('You must override the execute() method in the concrete command class.'); + $command = new Command('foo'); + $command->run(new StringInput(''), new NullOutput()); + } + + public function testRunWithInvalidOption() + { + $this->expectException('Symfony\Component\Console\Exception\InvalidOptionException'); + $this->expectExceptionMessage('The "--bar" option does not exist.'); + $command = new \TestCommand(); + $tester = new CommandTester($command); + $tester->execute(['--bar' => true]); + } + + public function testRunReturnsIntegerExitCode() + { + $command = new \TestCommand(); + $exitCode = $command->run(new StringInput(''), new NullOutput()); + $this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); + + $command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock(); + $command->expects($this->once()) + ->method('execute') + ->willReturn('2.3'); + $exitCode = $command->run(new StringInput(''), new NullOutput()); + $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); + } + + public function testRunWithApplication() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $exitCode = $command->run(new StringInput(''), new NullOutput()); + + $this->assertSame(0, $exitCode, '->run() returns an integer exit code'); + } + + public function testRunReturnsAlwaysInteger() + { + $command = new \TestCommand(); + + $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); + } + + public function testRunWithProcessTitle() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $command->setProcessTitle('foo'); + $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); + if (\function_exists('cli_set_process_title')) { + if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { + $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } + $this->assertEquals('foo', cli_get_process_title()); + } + } + + public function testSetCode() + { + $command = new \TestCommand(); + $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { + $output->writeln('from the code...'); + }); + $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); + $tester = new CommandTester($command); + $tester->execute([]); + $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + } + + public function getSetCodeBindToClosureTests() + { + return [ + [true, 'not bound to the command'], + [false, 'bound to the command'], + ]; + } + + /** + * @dataProvider getSetCodeBindToClosureTests + */ + public function testSetCodeBindToClosure($previouslyBound, $expected) + { + $code = createClosure(); + if ($previouslyBound) { + $code = $code->bindTo($this); + } + + $command = new \TestCommand(); + $command->setCode($code); + $tester = new CommandTester($command); + $tester->execute([]); + $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); + } + + public function testSetCodeWithStaticClosure() + { + $command = new \TestCommand(); + $command->setCode(self::createClosure()); + $tester = new CommandTester($command); + $tester->execute([]); + + if (\PHP_VERSION_ID < 70000) { + // Cannot bind static closures in PHP 5 + $this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay()); + } else { + // Can bind static closures in PHP 7 + $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); + } + } + + private static function createClosure() + { + return function (InputInterface $input, OutputInterface $output) { + $output->writeln(isset($this) ? 'bound' : 'not bound'); + }; + } + + public function testSetCodeWithNonClosureCallable() + { + $command = new \TestCommand(); + $ret = $command->setCode([$this, 'callableMethodCommand']); + $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); + $tester = new CommandTester($command); + $tester->execute([]); + $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + } + + public function callableMethodCommand(InputInterface $input, OutputInterface $output) + { + $output->writeln('from the code...'); + } +} + +// In order to get an unbound closure, we should create it outside a class +// scope. +function createClosure() +{ + return function (InputInterface $input, OutputInterface $output) { + $output->writeln($this instanceof Command ? 'bound to the command' : 'not bound to the command'); + }; +} diff --git a/lib/symfony/console/Tests/Command/HelpCommandTest.php b/lib/symfony/console/Tests/Command/HelpCommandTest.php new file mode 100644 index 000000000..5b25550a6 --- /dev/null +++ b/lib/symfony/console/Tests/Command/HelpCommandTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\HelpCommand; +use Symfony\Component\Console\Command\ListCommand; +use Symfony\Component\Console\Tester\CommandTester; + +class HelpCommandTest extends TestCase +{ + public function testExecuteForCommandAlias() + { + $command = new HelpCommand(); + $command->setApplication(new Application()); + $commandTester = new CommandTester($command); + $commandTester->execute(['command_name' => 'li'], ['decorated' => false]); + $this->assertStringContainsString('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + $this->assertStringContainsString('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + $this->assertStringContainsString('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + } + + public function testExecuteForCommand() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); + $command->setCommand(new ListCommand()); + $commandTester->execute([], ['decorated' => false]); + $this->assertStringContainsString('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertStringContainsString('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertStringContainsString('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + + public function testExecuteForCommandWithXmlOption() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); + $command->setCommand(new ListCommand()); + $commandTester->execute(['--format' => 'xml']); + $this->assertStringContainsString('getDisplay(), '->execute() returns an XML help text if --xml is passed'); + } + + public function testExecuteForApplicationCommand() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); + $commandTester->execute(['command_name' => 'list']); + $this->assertStringContainsString('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertStringContainsString('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertStringContainsString('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + + public function testExecuteForApplicationCommandWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); + $commandTester->execute(['command_name' => 'list', '--format' => 'xml']); + $this->assertStringContainsString('list [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertStringContainsString('getDisplay(), '->execute() returns an XML help text if --format=xml is passed'); + } +} diff --git a/lib/symfony/console/Tests/Command/ListCommandTest.php b/lib/symfony/console/Tests/Command/ListCommandTest.php new file mode 100644 index 000000000..57687d4c6 --- /dev/null +++ b/lib/symfony/console/Tests/Command/ListCommandTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; + +class ListCommandTest extends TestCase +{ + public function testExecuteListsCommands() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(['command' => $command->getName()], ['decorated' => false]); + + $this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + } + + public function testExecuteListsCommandsWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(['command' => $command->getName(), '--format' => 'xml']); + $this->assertRegExp('/