From af3db2c6d5cc119c229ba830ec683440e0531f8e Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Tue, 19 Dec 2023 18:32:17 +0100 Subject: [PATCH] [test] add phpunit tests --- .github/workflows/continuous-integration.yml | 7 +- .gitignore | 2 + .php-cs-fixer.dist.php | 4 +- composer.json | 9 +- lib/autoload/sfCoreAutoload.class.php | 5 + lib/cache/sfAPCCache.class.php | 18 +- lib/cache/sfEAcceleratorCache.class.php | 2 + lib/cache/sfFileCache.class.php | 12 +- lib/cache/sfSQLiteCache.class.php | 10 +- lib/cache/sfXCacheCache.class.php | 2 + lib/command/sfCommandOption.class.php | 2 +- lib/database/sfMySQLDatabase.class.php | 18 + lib/form/sfForm.class.php | 13 +- lib/i18n/sfI18N.class.php | 4 +- lib/i18n/sfMessageSource_XLIFF.class.php | 4 +- lib/mailer/sfMailer.class.php | 2 +- lib/plugin/sfPearConfig.class.php | 4 +- lib/plugin/sfPluginManager.class.php | 3 +- lib/request/sfWebRequest.class.php | 2 +- lib/response/sfResponse.class.php | 2 +- ...sfServiceContainerDumperGraphviz.class.php | 1 + lib/test/Symfony1ApplicationTestCase.php | 58 + lib/test/Symfony1ProjectTestCase.php | 42 + ...TestCaseDrivenApplicationConfiguration.php | 34 + .../TestCaseDrivenConfigurationInterface.php | 14 + .../TestCaseDrivenProjectConfiguration.php | 26 + lib/util/sfClassManipulator.class.php | 2 +- lib/validator/sfValidatorDate.class.php | 4 + lib/validator/sfValidatorError.class.php | 2 +- lib/validator/sfValidatorFile.class.php | 6 +- .../sfValidatorFromDescription.class.php | 1 + lib/validator/sfValidatorIp.class.php | 2 +- lib/validator/sfValidatorSchema.class.php | 4 + .../sfValidatorSchemaCompare.class.php | 13 +- lib/validator/sfValidatorString.class.php | 4 + lib/validator/sfValidatorTime.class.php | 15 +- lib/vendor/lime/lime.php | 1 + lib/view/sfViewCacheManager.class.php | 2 +- lib/yaml/sfYamlInline.class.php | 10 +- phpunit.xml.dist | 31 + tests/PhpUnitSfTestHelperTrait.php | 65 + tests/action/sfComponentTest.php | 77 + tests/addon/sfPagerTest.php | 42 + tests/autoload/sfCoreAutoloadTest.php | 26 + tests/autoload/sfSimpleAutoloadTest.php | 28 + tests/bootstrap.php | 67 + tests/cache/CacheDriverTestCase.php | 189 ++ tests/cache/sfAPCCacheTest.php | 25 + tests/cache/sfCacheTest.php | 29 + tests/cache/sfFileCacheTest.php | 47 + tests/cache/sfFunctionCacheTest.php | 66 + tests/cache/sfMemcacheCacheTest.php | 70 + tests/cache/sfNoCacheTest.php | 68 + tests/cache/sfSQLiteCacheFileTest.php | 35 + tests/cache/sfSQLiteCacheMemoryTest.php | 24 + tests/command/sfCommandArgumentSetTest.php | 157 ++ tests/command/sfCommandArgumentTest.php | 95 + tests/command/sfCommandManagerTest.php | 173 ++ tests/command/sfCommandOptionSetTest.php | 158 ++ tests/command/sfCommandOptionTest.php | 146 ++ tests/config/sfCompileConfigHandlerTest.php | 35 + tests/config/sfConfigHandlerTest.php | 69 + tests/config/sfConfigTest.php | 68 + .../sfDefineEnvironmentConfigHandlerTest.php | 42 + tests/config/sfFilterConfigHandlerTest.php | 127 ++ tests/config/sfGeneratorConfigHandlerTest.php | 114 ++ tests/config/sfPluginConfigurationTest.php | 98 + ...jectConfigurationNonExistentPluginTest.php | 31 + tests/config/sfProjectConfigurationTest.php | 52 + .../config/sfSimpleYamlConfigHandlerTest.php | 43 + tests/config/sfViewConfigHandlerTest.php | 337 ++++ tests/config/sfYamlConfigHandlerTest.php | 65 + tests/controller/sfControllerTest.php | 31 + tests/controller/sfWebControllerTest.php | 230 +++ tests/database/sfDatabaseTest.php | 27 + tests/debug/sfDebugTest.php | 29 + tests/debug/sfTimerTest.php | 42 + tests/debug/sfWebDebugInjectTest.php | 62 + .../sfOutputEscaperArrayDecoratorTest.php | 86 + .../sfOutputEscaperObjectDecoratorTest.php | 73 + tests/escaper/sfOutputEscaperSafeTest.php | 81 + tests/escaper/sfOutputEscaperTest.php | 160 ++ tests/event/sfEventDispatcherTest.php | 113 ++ tests/event/sfEventTest.php | 73 + tests/exception/sfExceptionsTest.php | 47 + tests/filter/sfFilterTest.php | 58 + tests/fixtures/A.php | 14 + tests/fixtures/ApplicationTask.php | 39 + tests/fixtures/ArgumentsTest1Task.php | 20 + tests/fixtures/ArgumentsTest2Task.php | 19 + tests/fixtures/BaseForm.php | 17 + tests/fixtures/BaseTestTask.php | 27 + tests/fixtures/BytesValidatorSchema.php | 17 + tests/fixtures/CompileCheckRoute.php | 9 + .../fixtures/DetailedDescriptionTestTask.php | 19 + tests/fixtures/EnglishSentence.php | 17 + tests/fixtures/FakeValidator.php | 17 + tests/fixtures/Foo.php | 11 + tests/fixtures/Foo2.php | 17 + tests/fixtures/FooCountable.php | 18 + tests/fixtures/FormFormatterMock.php | 23 + tests/fixtures/FormFormatterStub.php | 19 + tests/fixtures/FormListener.php | 31 + tests/fixtures/FormTest.php | 14 + tests/fixtures/Listener.php | 46 + tests/fixtures/MethodFilterer.php | 32 + tests/fixtures/MyClass.php | 17 + tests/fixtures/MyFalseClass.php | 17 + tests/fixtures/MyFormatter.php | 26 + tests/fixtures/MyFormatter2.php | 11 + tests/fixtures/MyRoute.php | 39 + tests/fixtures/MySessionStorage.php | 19 + tests/fixtures/MyTestPartialView.php | 21 + tests/fixtures/MyValidator.php | 17 + tests/fixtures/MyWidget.php | 24 + tests/fixtures/MyWidget2.php | 32 + tests/fixtures/MyWidget3.php | 27 + tests/fixtures/MyWidget4.php | 22 + tests/fixtures/MyWidgetForm.php | 22 + tests/fixtures/MyWidgetWithRequired.php | 17 + tests/fixtures/NotSerializable.php | 35 + tests/fixtures/NumericFieldsForm.php | 18 + tests/fixtures/OptionsTest1Task.php | 22 + tests/fixtures/OutputEscaperTest.php | 27 + tests/fixtures/OutputEscaperTestClass.php | 26 + .../fixtures/OutputEscaperTestClassChild.php | 13 + tests/fixtures/Post1Validator.php | 19 + tests/fixtures/PostValidator.php | 21 + tests/fixtures/PreValidator.php | 21 + tests/fixtures/ProjectDumper.php | 11 + tests/fixtures/ProjectLoader.php | 19 + tests/fixtures/ProjectLoader2.php | 17 + tests/fixtures/ProjectServiceContainer.php | 40 + tests/fixtures/TestClass1.php | 14 + tests/fixtures/TestClass2.php | 17 + tests/fixtures/TestClass3.php | 15 + tests/fixtures/TestConfiguration.php | 17 + tests/fixtures/TestForm.php | 20 + tests/fixtures/TestForm1.php | 34 + tests/fixtures/TestForm2.php | 32 + tests/fixtures/TestForm3.php | 14 + tests/fixtures/TestForm4.php | 14 + tests/fixtures/TestLogger.php | 22 + tests/fixtures/TestTask.php | 24 + tests/fixtures/TrimTest.php | 22 + tests/fixtures/ValidatorChoiceTestIsEmpty.php | 17 + tests/fixtures/ValidatorIdentity.php | 28 + .../ValidatorIdentityWithRequired.php | 22 + tests/fixtures/WidgetFormStub.php | 19 + tests/fixtures/config_routing.yml.php | 11 + tests/fixtures/configuredView.php | 21 + tests/fixtures/fakeCache.php | 11 + tests/fixtures/fakeRequest.php | 11 + tests/fixtures/fakeStorage.php | 11 + tests/fixtures/finder/finder/FILE5.txt | 0 .../finder/finder/dir1/dir2/dir3/file31 | 0 .../finder/finder/dir1/dir2/dir4/file41 | 0 .../finder/finder/dir1/dir2/file21.php | 0 tests/fixtures/finder/finder/dir1/dir2/file22 | 0 tests/fixtures/finder/finder/dir1/dir2/file23 | 0 tests/fixtures/finder/finder/dir1/dir2/file24 | 0 tests/fixtures/finder/finder/dir1/file11 | 0 tests/fixtures/finder/finder/dir1/file12.php | 0 tests/fixtures/finder/finder/dir1/file13 | 0 tests/fixtures/finder/finder/file1 | 7 + tests/fixtures/finder/finder/file2.txt | 0 .../finder/finder_permissions/secret/passwd | 1 + .../fixtures/mailer/TestMailMessage.class.php | 16 + .../mailer/TestMailerTransport.class.php | 73 + tests/fixtures/mailer/TestSpool.class.php | 56 + tests/fixtures/messages/messages.fr.xml | 23 + tests/fixtures/messages/messages.fr_BE.xml | 15 + tests/fixtures/messages/messages_bis.fr.xml | 11 + tests/fixtures/myCache.php | 28 + tests/fixtures/myCache2.php | 66 + tests/fixtures/myClickBrowser.php | 42 + tests/fixtures/myComponent.php | 14 + tests/fixtures/myConfigHandler.php | 14 + tests/fixtures/myContext.php | 14 + tests/fixtures/myController.php | 14 + tests/fixtures/myController2.php | 17 + tests/fixtures/myController3.php | 19 + tests/fixtures/myController4.php | 11 + tests/fixtures/myDatabase.php | 16 + tests/fixtures/myEventDispatcherTest.php | 22 + tests/fixtures/myException.php | 17 + tests/fixtures/myFilesystem.php | 22 + tests/fixtures/myFilter.php | 17 + tests/fixtures/myForm.php | 22 + tests/fixtures/myGenerator.php | 14 + tests/fixtures/myI18n.php | 17 + tests/fixtures/myI18nExtractTest.php | 27 + tests/fixtures/myLogger.php | 19 + tests/fixtures/myLogger2.php | 19 + tests/fixtures/myLoggerWrapper.php | 17 + tests/fixtures/myObjectRoute.php | 16 + tests/fixtures/myPager.php | 23 + tests/fixtures/myPatternRouting.php | 42 + tests/fixtures/myPluginManager.php | 60 + tests/fixtures/myRequest.php | 29 + tests/fixtures/myRequest2.php | 27 + tests/fixtures/myRequest3.php | 17 + tests/fixtures/myRequest4.php | 46 + tests/fixtures/myRequest5.php | 17 + tests/fixtures/myRequest6.php | 34 + tests/fixtures/myResponse.php | 18 + tests/fixtures/myResponse2.php | 20 + tests/fixtures/myRouting.php | 19 + tests/fixtures/mySfUser.php | 27 + tests/fixtures/myStorage.php | 22 + tests/fixtures/myValidatedFile.php | 11 + tests/fixtures/myView.php | 20 + tests/fixtures/myViewCacheManager.php | 14 + tests/fixtures/myViewConfigHandler.php | 22 + tests/fixtures/myWebResponse.php | 16 + tests/fixtures/myWebResponse2.php | 22 + tests/fixtures/myYamlConfigHandler.php | 36 + tests/fixtures/notaLogger.php | 11 + .../REST/p/sffooplugin/info.xml | 11 + .../REST/p/sftestplugin/info.xml | 11 + .../REST/r/sffooplugin/1.0.0.xml | 16 + .../REST/r/sffooplugin/allreleases.xml | 6 + .../REST/r/sffooplugin/deps.1.0.0.txt | 1 + .../REST/r/sftestplugin/1.0.0.xml | 16 + .../REST/r/sftestplugin/1.0.3.xml | 16 + .../REST/r/sftestplugin/1.0.4.xml | 16 + .../REST/r/sftestplugin/1.1.3.xml | 16 + .../REST/r/sftestplugin/1.1.4.xml | 16 + .../REST/r/sftestplugin/allreleases.xml | 10 + .../REST/r/sftestplugin/deps.1.0.0.txt | 1 + .../REST/r/sftestplugin/deps.1.0.3.txt | 1 + .../REST/r/sftestplugin/deps.1.0.4.txt | 1 + .../REST/r/sftestplugin/deps.1.1.3.txt | 1 + .../REST/r/sftestplugin/deps.1.1.4.txt | 1 + .../plugin/http/pear.example.com/channel.xml | 14 + .../get/sfFooPlugin/sfFooPlugin-1.0.0.tgz | Bin 0 -> 835 bytes .../get/sfTestPlugin/sfTestPlugin-1.0.0.tgz | Bin 0 -> 816 bytes .../get/sfTestPlugin/sfTestPlugin-1.0.3.tgz | Bin 0 -> 819 bytes .../get/sfTestPlugin/sfTestPlugin-1.0.4.tgz | Bin 0 -> 815 bytes .../get/sfTestPlugin/sfTestPlugin-1.1.3.tgz | Bin 0 -> 825 bytes .../get/sfTestPlugin/sfTestPlugin-1.1.4.tgz | Bin 0 -> 823 bytes tests/fixtures/plugin/sfFooPlugin/package.xml | 60 + .../sfFooPlugin/sfFooPlugin-1.0.0/VERSION | 1 + .../sfTestPlugin-1.0.0/package.xml | 53 + .../sfTestPlugin-1.0.0/VERSION | 1 + .../sfTestPlugin-1.0.3/package.xml | 53 + .../sfTestPlugin-1.0.3/VERSION | 1 + .../sfTestPlugin-1.0.4/package.xml | 53 + .../sfTestPlugin-1.0.4/VERSION | 1 + .../sfTestPlugin-1.1.3/package.xml | 53 + .../sfTestPlugin-1.1.3/VERSION | 1 + .../sfTestPlugin-1.1.4/package.xml | 53 + .../sfTestPlugin-1.1.4/VERSION | 1 + .../service/containers/container10.php | 18 + .../service/containers/container8.php | 18 + .../service/containers/container9.php | 40 + tests/fixtures/service/graphviz/services1.dot | 7 + .../service/graphviz/services10-1.dot | 10 + .../fixtures/service/graphviz/services10.dot | 10 + tests/fixtures/service/graphviz/services9.dot | 15 + tests/fixtures/service/includes/classes.php | 36 + tests/fixtures/service/includes/foo.php | 46 + tests/fixtures/service/php/services1-1.php | 4 + tests/fixtures/service/php/services1.php | 4 + tests/fixtures/service/php/services8.php | 27 + tests/fixtures/service/php/services9.php | 64 + tests/fixtures/service/yaml/nonvalid1.yml | 2 + tests/fixtures/service/yaml/nonvalid2.yml | 1 + tests/fixtures/service/yaml/services1.yml | 1 + tests/fixtures/service/yaml/services2.yml | 9 + tests/fixtures/service/yaml/services3.yml | 20 + tests/fixtures/sfAlwaysAbsoluteRoute.php | 19 + .../sfCompileConfigHandler/simple.yml | 1 + .../prefix_all.yml | 15 + .../prefix_default.yml | 11 + .../prefix_result.php | 13 + tests/fixtures/sfException.php | 11 + .../sfFilterConfigHandler/condition.yml | 14 + .../sfFilterConfigHandler/default_filters.yml | 12 + .../sfFilterConfigHandler/disable.yml | 13 + .../sfFilterConfigHandler/filters.yml | 11 + .../sfFilterConfigHandler/no_class.yml | 5 + .../sfFilterConfigHandler/no_execution.yml | 7 + .../sfFilterConfigHandler/no_rendering.yml | 7 + .../sfFilterConfigHandler/not_disabled.yml | 2 + .../fixtures/sfFilterConfigHandler/result.php | 25 + .../sfGeneratorConfigHandler/empty.yml | 0 .../no_generator_class.yml | 4 + .../no_generator_section.yml | 2 + .../root_edit_section.yml | 7 + .../root_fields_section.yml | 7 + .../root_list_section.yml | 7 + tests/fixtures/sfMessageSource_Simple.php | 25 + tests/fixtures/sfMessageSource_Simple2.php | 24 + tests/fixtures/sfPluginTestHelper.php | 34 + tests/fixtures/sfSimpleCache.php | 54 + .../sfSimpleYamlConfigHandler/config.yml | 3 + .../sfSimpleYamlConfigHandler/config_bis.yml | 3 + tests/fixtures/sfUser.php | 19 + tests/fixtures/sfWebDebugTest.php | 23 + .../symfony/apps/cache/config/app.yml | 2 + .../symfony/apps/cache/config/cache.yml | 4 + .../cache/config/cacheConfiguration.class.php | 14 + .../symfony/apps/cache/config/factories.yml | 17 + .../symfony/apps/cache/config/filters.yml | 9 + .../symfony/apps/cache/config/routing.yml | 15 + .../symfony/apps/cache/config/security.yml | 2 + .../symfony/apps/cache/config/settings.yml | 22 + .../symfony/apps/cache/config/view.yml | 17 + .../symfony/apps/cache/lib/myUser.class.php | 11 + .../modules/cache/actions/actions.class.php | 97 + .../cache/actions/components.class.php | 43 + .../apps/cache/modules/cache/config/cache.yml | 62 + .../apps/cache/modules/cache/data/ok48.png | Bin 0 -> 3106 bytes .../templates/_anotherCacheablePartial.php | 10 + .../cache/templates/_cacheableComponent.php | 6 + .../cache/templates/_cacheablePartial.php | 8 + .../modules/cache/templates/_component.php | 1 + .../_contextualCacheableComponent.php | 1 + .../templates/_contextualCacheablePartial.php | 1 + .../cache/templates/_contextualComponent.php | 1 + .../cache/templates/_contextualPartial.php | 1 + .../modules/cache/templates/_partial.php | 1 + .../modules/cache/templates/actionSuccess.php | 1 + .../cache/templates/anotherPartialSuccess.php | 1 + .../cache/templates/componentSuccess.php | 2 + .../modules/cache/templates/imageSuccess.php | 11 + .../modules/cache/templates/indexSuccess.php | 3 + .../modules/cache/templates/listSuccess.php | 1 + .../cache/templates/multiBisSuccess.php | 10 + .../modules/cache/templates/multiSuccess.php | 30 + .../modules/cache/templates/pageSuccess.php | 1 + .../cache/templates/partialSuccess.php | 1 + .../templates/specificCacheKeySuccess.php | 5 + .../httpcache/actions/actions.class.php | 36 + .../cache/modules/httpcache/config/cache.yml | 11 + .../httpcache/templates/indexSuccess.php | 1 + .../modules/nocache/actions/actions.class.php | 24 + .../cache/modules/nocache/config/cache.yml | 2 + .../nocache/templates/indexSuccess.php | 3 + .../symfony/apps/cache/templates/image.php | 11 + .../symfony/apps/cache/templates/layout.php | 25 + .../symfony/apps/frontend/config/app.yml | 2 + .../symfony/apps/frontend/config/cache.yml | 4 + .../frontend/config/dirmyconfig/myconfig.yml | 0 .../apps/frontend/config/factories.yml | 17 + .../symfony/apps/frontend/config/filters.yml | 11 + .../config/frontendConfiguration.class.php | 47 + .../symfony/apps/frontend/config/routing.yml | 19 + .../symfony/apps/frontend/config/security.yml | 2 + .../symfony/apps/frontend/config/services.yml | 12 + .../symfony/apps/frontend/config/settings.yml | 25 + .../symfony/apps/frontend/config/view.yml | 24 + .../lib/myAppsFrontendLibClass.class.php | 17 + .../apps/frontend/lib/myAutoload.class.php | 23 + .../frontend/lib/myAutoloadedClass.class.php | 17 + .../apps/frontend/lib/myFilter.class.php | 30 + .../apps/frontend/lib/myUser.class.php | 11 + .../assetInclusion/actions/actions.class.php | 21 + .../modules/assetInclusion/config/view.yml | 7 + .../assetInclusion/templates/indexSuccess.php | 1 + .../modules/auth/actions/actions.class.php | 37 + .../modules/auth/templates/basicSuccess.php | 3 + .../autoload/actions/actions.class.php | 32 + ...myAppsFrontendModulesAutoloadLib.class.php | 17 + .../autoload/templates/indexSuccess.php | 4 + .../autoload/templates/myAutoloadSuccess.php | 1 + .../modules/browser/actions/actions.class.php | 66 + .../templates/redirectTarget1Success.php | 1 + .../templates/templateCustomCustomSuccess.php | 1 + .../templates/templateCustomSuccess.php | 1 + .../actions/actions.class.php | 21 + .../config/filters.yml | 14 + .../configFiltersSimpleFilterFilter.class.php | 20 + .../templates/indexSuccess.php | 11 + .../actions/actions.class.php | 21 + .../configModuleDisabled/config/module.yml | 2 + .../templates/indexSuccess.php | 0 .../actions/actions.class.php | 21 + .../config/security.yml | 3 + .../templates/indexSuccess.php | 0 .../actions/actions.class.php | 21 + .../config/security.yml | 3 + .../templates/indexSuccess.php | 0 .../actions/actions.class.php | 24 + .../templates/indexSuccess.php | 0 .../actions/actions.class.php | 21 + .../configViewHasLayout/config/view.yml | 2 + .../templates/withoutLayoutSuccess.php | 1 + .../modules/cookie/actions/actions.class.php | 38 + .../escaping/actions/actions.class.php | 36 + .../modules/escaping/templates/_partial1.php | 6 + .../modules/escaping/templates/_partial2.php | 4 + .../escaping/templates/indexSuccess.php | 4 + .../exception/actions/actions.class.php | 34 + .../modules/filter/actions/actions.class.php | 29 + .../modules/format/actions/actions.class.php | 52 + .../format/templates/_js_header.js.php | 1 + .../format/templates/indexSuccess.css.php | 1 + .../format/templates/indexSuccess.iphone.php | 1 + .../format/templates/indexSuccess.js.php | 3 + .../modules/format/templates/indexSuccess.php | 1 + .../format/templates/indexSuccess.xml.php | 1 + .../modules/format/templates/jsSuccess.js.php | 1 + .../notfound/actions/actions.class.php | 26 + .../presentation/actions/actions.class.php | 29 + .../presentation/templates/fooSuccess.php | 1 + .../presentation/templates/indexSuccess.php | 2 + .../renderText/actions/actions.class.php | 24 + .../config/dirmyconfig/myconfig.yml | 0 .../modules/sfConfigPlugin/config/filters.yml | 0 .../modules/sfConfigPlugin/config/view.yml | 0 .../modules/view/actions/actions.class.php | 28 + .../frontend/modules/view/config/view.yml | 16 + .../modules/view/templates/fooSuccess.php | 1 + .../modules/view/templates/imageSuccess.php | 1 + .../modules/view/templates/plainSuccess.php | 1 + .../apps/frontend/templates/layout.iphone.php | 21 + .../apps/frontend/templates/layout.php | 21 + .../apps/frontend/templates/layout.xml.php | 3 + .../fixtures/symfony/apps/i18n/config/app.yml | 2 + .../symfony/apps/i18n/config/cache.yml | 4 + .../symfony/apps/i18n/config/factories.yml | 17 + .../symfony/apps/i18n/config/filters.yml | 8 + .../i18n/config/i18nConfiguration.class.php | 18 + .../symfony/apps/i18n/config/routing.yml | 7 + .../symfony/apps/i18n/config/security.yml | 2 + .../symfony/apps/i18n/config/settings.yml | 25 + .../symfony/apps/i18n/config/view.yml | 17 + .../symfony/apps/i18n/i18n/messages.fr.xml | 15 + .../symfony/apps/i18n/i18n/other.fr.xml | 11 + .../symfony/apps/i18n/lib/myUser.class.php | 11 + .../modules/i18n/actions/actions.class.php | 53 + .../apps/i18n/modules/i18n/i18n/custom.fr.xml | 19 + .../i18n/modules/i18n/i18n/messages.fr.xml | 35 + .../apps/i18n/modules/i18n/i18n/other.fr.xml | 11 + .../lib/I18nCustomCatalogueForm.class.php | 18 + .../i18n/modules/i18n/lib/I18nForm.class.php | 33 + .../i18n/templates/i18nFormSuccess.php | 8 + .../modules/i18n/templates/indexSuccess.php | 13 + .../modules/sfI18NPlugin/i18n/messages.fr.xml | 11 + .../symfony/apps/i18n/templates/layout.php | 21 + .../config/ProjectConfiguration.class.php | 24 + tests/fixtures/symfony/config/databases.yml | 1 + .../symfony/config/dirmyconfig/myconfig.yml | 0 tests/fixtures/symfony/config/filters.yml | 8 + tests/fixtures/symfony/config/properties.ini | 3 + tests/fixtures/symfony/config/services.yml | 9 + tests/fixtures/symfony/config/view.yml | 0 .../symfony/data/environment.migrated | 0 tests/fixtures/symfony/lib/ExtendMe.class.php | 11 + .../symfony/lib/form/BaseForm.class.php | 18 + .../fixtures/symfony/lib/myLibClass.class.php | 17 + tests/fixtures/symfony/log/cache_test.log | 1 + tests/fixtures/symfony/log/frontend_test.log | 1 + tests/fixtures/symfony/log/i18n_test.log | 1 + .../config/NotInLib.class.php | 11 + .../sfAutoloadPlugin/config/autoload.yml | 11 + .../sfAutoloadPluginConfiguration.class.php | 11 + .../lib/BaseExtendMe.class.php | 11 + .../sfAutoloadPlugin/lib/ExtendMe.class.php | 11 + .../lib/vendor/ExcludedFromAutoload.class.php | 5 + .../autoloadPlugin/actions/actions.class.php | 19 + ...adPluginModulesAutoloadPluginLib.class.php | 17 + .../autoloadPlugin/templates/indexSuccess.php | 3 + .../test/functional/BarFunctionalTest.php | 0 .../test/functional/FooFunctionalTest.php | 0 .../nested/NestedFunctionalTest.php | 0 .../test/unit/BarUnitTest.php | 0 .../test/unit/FooUnitTest.php | 0 .../test/unit/nested/NestedUnitTest.php | 0 .../config/dirmyconfig/myconfig.yml | 0 .../plugins/sfConfigPlugin/config/filters.yml | 7 + .../sfConfigPlugin/config/services.yml | 9 + .../plugins/sfConfigPlugin/config/view.yml | 0 .../config/dirmyconfig/myconfig.yml | 0 .../modules/sfConfigPlugin/config/filters.yml | 0 .../modules/sfConfigPlugin/config/view.yml | 0 .../plugins/sfI18NPlugin/i18n/messages.fr.xml | 11 + .../sfI18NPlugin/actions/actions.class.php | 31 + .../modules/sfI18NPlugin/i18n/messages.fr.xml | 23 + .../sfI18NPlugin/templates/indexSuccess.php | 16 + tests/fixtures/symfony/symfony | 15 + tests/fixtures/testFunctionCache.php | 28 + tests/fixtures/testObject.php | 11 + tests/fixtures/testObjectWithToString.php | 17 + tests/fixtures/testRandomFunctionCache.php | 18 + tests/fixtures/testValidatorFile.php | 42 + tests/fixtures/yaml/YtsAnchorAlias.yml | 31 + tests/fixtures/yaml/YtsBasicTests.yml | 178 ++ tests/fixtures/yaml/YtsBlockMapping.yml | 52 + tests/fixtures/yaml/YtsDocumentSeparator.yml | 85 + tests/fixtures/yaml/YtsErrorTests.yml | 26 + tests/fixtures/yaml/YtsFlowCollections.yml | 60 + tests/fixtures/yaml/YtsFoldedScalars.yml | 176 ++ tests/fixtures/yaml/YtsNullsAndEmpties.yml | 45 + .../yaml/YtsSpecificationExamples.yml | 1681 +++++++++++++++++ tests/fixtures/yaml/YtsTypeTransfers.yml | 244 +++ tests/fixtures/yaml/index.yml | 15 + tests/fixtures/yaml/sfComments.yml | 51 + tests/fixtures/yaml/sfMergeKey.yml | 27 + tests/fixtures/yaml/sfObjects.yml | 11 + tests/fixtures/yaml/sfQuotes.yml | 33 + tests/fixtures/yaml/sfTests.yml | 153 ++ tests/form/addon/sfFormSymfonyTest.php | 67 + tests/form/sfFormFieldSchemaTest.php | 107 ++ tests/form/sfFormFieldTest.php | 234 +++ tests/form/sfFormTest.php | 1013 ++++++++++ tests/generator/sfGeneratorTest.php | 29 + ...sfModelGeneratorConfigurationFieldTest.php | 42 + tests/helper/AssetHelperTest.php | 247 +++ tests/helper/DateHelperTest.php | 110 ++ tests/helper/EscapingHelperTest.php | 56 + tests/helper/JavascriptBaseHelperTest.php | 57 + tests/helper/NumberHelperTest.php | 50 + tests/helper/PartialHelperTest.php | 61 + tests/helper/TagHelperTest.php | 77 + tests/helper/TextHelperTest.php | 162 ++ tests/helper/UrlHelperTest.php | 116 ++ tests/i18n/dataTest.php | 117 ++ tests/i18n/extract/sfI18nExtractTest.php | 54 + tests/i18n/extract/sfI18nPhpExtractorTest.php | 96 + .../sfI18nYamlGeneratorExtractorTest.php | 76 + .../sfI18nYamlValidateExtractorTest.php | 57 + tests/i18n/sfChoiceFormatTest.php | 166 ++ tests/i18n/sfCultureInfoTest.php | 267 +++ tests/i18n/sfI18NTest.php | 134 ++ tests/i18n/sfMessageSourceTest.php | 39 + tests/i18n/sfMessageSource_AggregateTest.php | 95 + tests/i18n/sfMessageSource_FileTest.php | 52 + tests/i18n/sfMessageSource_SQLiteTest.php | 117 ++ tests/i18n/sfMessageSource_XLIFFTest.php | 87 + tests/i18n/sfNumberFormatInfoTest.php | 141 ++ tests/log/sfAggregateLoggerTest.php | 69 + tests/log/sfConsoleLoggerTest.php | 34 + tests/log/sfFileLoggerTest.php | 86 + tests/log/sfLoggerTest.php | 99 + tests/log/sfLoggerWrapperTest.php | 40 + tests/log/sfStreamLoggerTest.php | 35 + tests/log/sfVarLoggerTest.php | 47 + tests/log/sfWebDebugLoggerTest.php | 38 + tests/mailer/sfMailerTest.php | 184 ++ tests/plugin/sfPearEnvironmentTest.php | 72 + tests/plugin/sfPearRestPluginTest.php | 69 + tests/plugin/sfPluginManagerTest.php | 203 ++ tests/plugin/sfPluginTestHelper.class.php | 37 + tests/plugin/sfTestPearDownloader.class.php | 48 + tests/plugin/sfTestPearRest.class.php | 49 + .../request/sfRequestEventDispatcherTest.php | 31 + .../sfRequestParameterHolderAttributeTest.php | 29 + .../sfRequestParameterHolderParameterTest.php | 29 + tests/request/sfRequestTest.php | 86 + tests/request/sfWebRequestTest.php | 544 ++++++ tests/response/sfResponseTest.php | 60 + tests/response/sfWebResponseTest.php | 312 +++ tests/routing/sfObjectRouteCollectionTest.php | 127 ++ tests/routing/sfObjectRouteTest.php | 35 + tests/routing/sfPatternRoutingTest.php | 653 +++++++ tests/routing/sfRequestRouteTest.php | 62 + tests/routing/sfRouteTest.php | 236 +++ .../service/sfServiceContainerBuilderTest.php | 228 +++ .../sfServiceContainerDumperGraphvizTest.php | 56 + .../sfServiceContainerDumperPhpTest.php | 59 + .../service/sfServiceContainerDumperTest.php | 36 + .../sfServiceContainerLoaderArrayTest.php | 89 + .../service/sfServiceContainerLoaderTest.php | 80 + tests/service/sfServiceContainerTest.php | 120 ++ tests/service/sfServiceDefinitionTest.php | 82 + tests/service/sfServiceParameterTest.php | 32 + tests/service/sfServiceReferenceTest.php | 33 + tests/sfContext.class.php | 123 ++ tests/sfEventDispatcherTestCase.php | 39 + tests/sfNoRouting.class.php | 107 ++ tests/sfParameterHolderProxyTestCase.php | 54 + tests/storage/sfCacheSessionStorageTest.php | 71 + tests/storage/sfMySQLStorageTest.php | 138 ++ tests/storage/sfMySQLiStorageTest.php | 146 ++ tests/storage/sfNoStorageTest.php | 34 + tests/storage/sfPDOSessionStorageTest.php | 105 + tests/storage/sfSessionStorageTest.php | 74 + tests/storage/sfStorageTest.php | 30 + tests/task/cache/sfCacheClearTaskTest.php | 62 + tests/task/sfBaseTaskTest.php | 103 + tests/task/sfFilesystemTest.php | 67 + tests/task/sfTaskTest.php | 88 + tests/user/sfBasicSecurityUserTest.php | 173 ++ tests/user/sfUserTest.php | 113 ++ tests/util/sfBrowserTest.php | 331 ++++ tests/util/sfCallableTest.php | 51 + tests/util/sfClassManipulatorTest.php | 260 +++ tests/util/sfContextTest.php | 109 ++ tests/util/sfDomCssSelectorTest.php | 220 +++ tests/util/sfFinderTest.php | 231 +++ tests/util/sfInflectorTest.php | 44 + .../util/sfNamespacedParameterHolderTest.php | 228 +++ tests/util/sfParameterHolderTest.php | 156 ++ tests/util/sfToolkitTest.php | 256 +++ .../i18n/sfValidatorI18nChoiceCountryTest.php | 44 + .../sfValidatorI18nChoiceLanguageTest.php | 44 + .../sfValidatorI18nChoiceTimezoneTest.php | 34 + tests/validator/sfValidatorAndTest.php | 124 ++ tests/validator/sfValidatorBaseTest.php | 208 ++ tests/validator/sfValidatorBooleanTest.php | 72 + tests/validator/sfValidatorCSRFTokenTest.php | 54 + tests/validator/sfValidatorCallbackTest.php | 71 + tests/validator/sfValidatorChoiceTest.php | 103 + tests/validator/sfValidatorDateRangeTest.php | 74 + tests/validator/sfValidatorDateTest.php | 224 +++ tests/validator/sfValidatorDateTimeTest.php | 36 + tests/validator/sfValidatorDecoratorTest.php | 109 ++ tests/validator/sfValidatorEmailTest.php | 54 + tests/validator/sfValidatorEqualTest.php | 81 + .../validator/sfValidatorErrorSchemaTest.php | 209 ++ tests/validator/sfValidatorErrorTest.php | 86 + tests/validator/sfValidatorFileMultiTest.php | 57 + tests/validator/sfValidatorFileTest.php | 244 +++ .../sfValidatorFromDescriptionTest.php | 137 ++ tests/validator/sfValidatorIntegerTest.php | 96 + tests/validator/sfValidatorIpTest.php | 239 +++ tests/validator/sfValidatorNumberTest.php | 86 + tests/validator/sfValidatorOrTest.php | 105 + tests/validator/sfValidatorPassTest.php | 33 + tests/validator/sfValidatorRegexTest.php | 90 + .../sfValidatorSchemaCompareTest.php | 140 ++ .../validator/sfValidatorSchemaFilterTest.php | 59 + tests/validator/sfValidatorSchemaTest.php | 360 ++++ tests/validator/sfValidatorStringTest.php | 83 + tests/validator/sfValidatorTimeTest.php | 133 ++ tests/validator/sfValidatorUrlTest.php | 66 + tests/view/sfViewCacheManagerTest.php | 205 ++ tests/view/sfViewParameterHolderTest.php | 135 ++ tests/view/sfViewTest.php | 75 + .../sfWidgetFormI18nChoiceCountryTest.php | 66 + .../sfWidgetFormI18nChoiceCurrencyTest.php | 65 + .../sfWidgetFormI18nChoiceLanguageTest.php | 61 + .../sfWidgetFormI18nChoiceTimezoneTest.php | 49 + .../widget/i18n/sfWidgetFormI18nDateTest.php | 58 + .../i18n/sfWidgetFormI18nDateTimeTest.php | 35 + .../widget/i18n/sfWidgetFormI18nTimeTest.php | 40 + tests/widget/sfWidgetFormChoiceTest.php | 108 ++ tests/widget/sfWidgetFormDateRangeTest.php | 39 + tests/widget/sfWidgetFormDateTest.php | 156 ++ tests/widget/sfWidgetFormDateTimeTest.php | 163 ++ tests/widget/sfWidgetFormFilterDateTest.php | 43 + tests/widget/sfWidgetFormFilterInputTest.php | 42 + .../widget/sfWidgetFormInputCheckboxTest.php | 40 + .../sfWidgetFormInputFileEditableTest.php | 81 + .../widget/sfWidgetFormInputFileMultiTest.php | 32 + tests/widget/sfWidgetFormInputFileTest.php | 32 + tests/widget/sfWidgetFormInputHiddenTest.php | 36 + .../widget/sfWidgetFormInputPasswordTest.php | 37 + tests/widget/sfWidgetFormInputReadTest.php | 41 + tests/widget/sfWidgetFormInputTextTest.php | 38 + .../sfWidgetFormSchemaDecoratorTest.php | 86 + .../sfWidgetFormSchemaFormatterListTest.php | 53 + .../sfWidgetFormSchemaFormatterTableTest.php | 53 + .../sfWidgetFormSchemaFormatterTest.php | 158 ++ tests/widget/sfWidgetFormSchemaTest.php | 452 +++++ .../widget/sfWidgetFormSelectCheckboxTest.php | 134 ++ tests/widget/sfWidgetFormSelectManyTest.php | 34 + tests/widget/sfWidgetFormSelectRadioTest.php | 127 ++ tests/widget/sfWidgetFormSelectTest.php | 141 ++ tests/widget/sfWidgetFormTest.php | 119 ++ tests/widget/sfWidgetFormTextareaTest.php | 39 + tests/widget/sfWidgetFormTimeTest.php | 164 ++ tests/widget/sfWidgetTest.php | 147 ++ tests/yaml/sfYamlDumperTest.php | 152 ++ tests/yaml/sfYamlInlineTest.php | 156 ++ tests/yaml/sfYamlParserTest.php | 93 + 669 files changed, 31997 insertions(+), 40 deletions(-) create mode 100644 lib/test/Symfony1ApplicationTestCase.php create mode 100644 lib/test/Symfony1ProjectTestCase.php create mode 100644 lib/test/TestCaseDrivenApplicationConfiguration.php create mode 100644 lib/test/TestCaseDrivenConfigurationInterface.php create mode 100644 lib/test/TestCaseDrivenProjectConfiguration.php create mode 100644 phpunit.xml.dist create mode 100644 tests/PhpUnitSfTestHelperTrait.php create mode 100644 tests/action/sfComponentTest.php create mode 100644 tests/addon/sfPagerTest.php create mode 100644 tests/autoload/sfCoreAutoloadTest.php create mode 100644 tests/autoload/sfSimpleAutoloadTest.php create mode 100644 tests/bootstrap.php create mode 100644 tests/cache/CacheDriverTestCase.php create mode 100644 tests/cache/sfAPCCacheTest.php create mode 100644 tests/cache/sfCacheTest.php create mode 100644 tests/cache/sfFileCacheTest.php create mode 100644 tests/cache/sfFunctionCacheTest.php create mode 100644 tests/cache/sfMemcacheCacheTest.php create mode 100644 tests/cache/sfNoCacheTest.php create mode 100644 tests/cache/sfSQLiteCacheFileTest.php create mode 100644 tests/cache/sfSQLiteCacheMemoryTest.php create mode 100644 tests/command/sfCommandArgumentSetTest.php create mode 100644 tests/command/sfCommandArgumentTest.php create mode 100644 tests/command/sfCommandManagerTest.php create mode 100644 tests/command/sfCommandOptionSetTest.php create mode 100644 tests/command/sfCommandOptionTest.php create mode 100644 tests/config/sfCompileConfigHandlerTest.php create mode 100644 tests/config/sfConfigHandlerTest.php create mode 100644 tests/config/sfConfigTest.php create mode 100644 tests/config/sfDefineEnvironmentConfigHandlerTest.php create mode 100644 tests/config/sfFilterConfigHandlerTest.php create mode 100644 tests/config/sfGeneratorConfigHandlerTest.php create mode 100644 tests/config/sfPluginConfigurationTest.php create mode 100644 tests/config/sfProjectConfigurationNonExistentPluginTest.php create mode 100644 tests/config/sfProjectConfigurationTest.php create mode 100644 tests/config/sfSimpleYamlConfigHandlerTest.php create mode 100644 tests/config/sfViewConfigHandlerTest.php create mode 100644 tests/config/sfYamlConfigHandlerTest.php create mode 100644 tests/controller/sfControllerTest.php create mode 100644 tests/controller/sfWebControllerTest.php create mode 100644 tests/database/sfDatabaseTest.php create mode 100644 tests/debug/sfDebugTest.php create mode 100644 tests/debug/sfTimerTest.php create mode 100644 tests/debug/sfWebDebugInjectTest.php create mode 100644 tests/escaper/sfOutputEscaperArrayDecoratorTest.php create mode 100644 tests/escaper/sfOutputEscaperObjectDecoratorTest.php create mode 100644 tests/escaper/sfOutputEscaperSafeTest.php create mode 100644 tests/escaper/sfOutputEscaperTest.php create mode 100644 tests/event/sfEventDispatcherTest.php create mode 100644 tests/event/sfEventTest.php create mode 100644 tests/exception/sfExceptionsTest.php create mode 100644 tests/filter/sfFilterTest.php create mode 100644 tests/fixtures/A.php create mode 100644 tests/fixtures/ApplicationTask.php create mode 100644 tests/fixtures/ArgumentsTest1Task.php create mode 100644 tests/fixtures/ArgumentsTest2Task.php create mode 100644 tests/fixtures/BaseForm.php create mode 100644 tests/fixtures/BaseTestTask.php create mode 100644 tests/fixtures/BytesValidatorSchema.php create mode 100644 tests/fixtures/CompileCheckRoute.php create mode 100644 tests/fixtures/DetailedDescriptionTestTask.php create mode 100644 tests/fixtures/EnglishSentence.php create mode 100644 tests/fixtures/FakeValidator.php create mode 100644 tests/fixtures/Foo.php create mode 100644 tests/fixtures/Foo2.php create mode 100644 tests/fixtures/FooCountable.php create mode 100644 tests/fixtures/FormFormatterMock.php create mode 100644 tests/fixtures/FormFormatterStub.php create mode 100644 tests/fixtures/FormListener.php create mode 100644 tests/fixtures/FormTest.php create mode 100644 tests/fixtures/Listener.php create mode 100644 tests/fixtures/MethodFilterer.php create mode 100644 tests/fixtures/MyClass.php create mode 100644 tests/fixtures/MyFalseClass.php create mode 100644 tests/fixtures/MyFormatter.php create mode 100644 tests/fixtures/MyFormatter2.php create mode 100644 tests/fixtures/MyRoute.php create mode 100644 tests/fixtures/MySessionStorage.php create mode 100644 tests/fixtures/MyTestPartialView.php create mode 100644 tests/fixtures/MyValidator.php create mode 100644 tests/fixtures/MyWidget.php create mode 100644 tests/fixtures/MyWidget2.php create mode 100644 tests/fixtures/MyWidget3.php create mode 100644 tests/fixtures/MyWidget4.php create mode 100644 tests/fixtures/MyWidgetForm.php create mode 100644 tests/fixtures/MyWidgetWithRequired.php create mode 100644 tests/fixtures/NotSerializable.php create mode 100644 tests/fixtures/NumericFieldsForm.php create mode 100644 tests/fixtures/OptionsTest1Task.php create mode 100644 tests/fixtures/OutputEscaperTest.php create mode 100644 tests/fixtures/OutputEscaperTestClass.php create mode 100644 tests/fixtures/OutputEscaperTestClassChild.php create mode 100644 tests/fixtures/Post1Validator.php create mode 100644 tests/fixtures/PostValidator.php create mode 100644 tests/fixtures/PreValidator.php create mode 100644 tests/fixtures/ProjectDumper.php create mode 100644 tests/fixtures/ProjectLoader.php create mode 100644 tests/fixtures/ProjectLoader2.php create mode 100644 tests/fixtures/ProjectServiceContainer.php create mode 100644 tests/fixtures/TestClass1.php create mode 100644 tests/fixtures/TestClass2.php create mode 100644 tests/fixtures/TestClass3.php create mode 100644 tests/fixtures/TestConfiguration.php create mode 100644 tests/fixtures/TestForm.php create mode 100644 tests/fixtures/TestForm1.php create mode 100644 tests/fixtures/TestForm2.php create mode 100644 tests/fixtures/TestForm3.php create mode 100644 tests/fixtures/TestForm4.php create mode 100644 tests/fixtures/TestLogger.php create mode 100644 tests/fixtures/TestTask.php create mode 100644 tests/fixtures/TrimTest.php create mode 100644 tests/fixtures/ValidatorChoiceTestIsEmpty.php create mode 100644 tests/fixtures/ValidatorIdentity.php create mode 100644 tests/fixtures/ValidatorIdentityWithRequired.php create mode 100644 tests/fixtures/WidgetFormStub.php create mode 100644 tests/fixtures/config_routing.yml.php create mode 100644 tests/fixtures/configuredView.php create mode 100644 tests/fixtures/fakeCache.php create mode 100644 tests/fixtures/fakeRequest.php create mode 100644 tests/fixtures/fakeStorage.php create mode 100644 tests/fixtures/finder/finder/FILE5.txt create mode 100644 tests/fixtures/finder/finder/dir1/dir2/dir3/file31 create mode 100644 tests/fixtures/finder/finder/dir1/dir2/dir4/file41 create mode 100644 tests/fixtures/finder/finder/dir1/dir2/file21.php create mode 100644 tests/fixtures/finder/finder/dir1/dir2/file22 create mode 100644 tests/fixtures/finder/finder/dir1/dir2/file23 create mode 100644 tests/fixtures/finder/finder/dir1/dir2/file24 create mode 100644 tests/fixtures/finder/finder/dir1/file11 create mode 100644 tests/fixtures/finder/finder/dir1/file12.php create mode 100644 tests/fixtures/finder/finder/dir1/file13 create mode 100644 tests/fixtures/finder/finder/file1 create mode 100644 tests/fixtures/finder/finder/file2.txt create mode 100644 tests/fixtures/finder/finder_permissions/secret/passwd create mode 100644 tests/fixtures/mailer/TestMailMessage.class.php create mode 100644 tests/fixtures/mailer/TestMailerTransport.class.php create mode 100644 tests/fixtures/mailer/TestSpool.class.php create mode 100644 tests/fixtures/messages/messages.fr.xml create mode 100644 tests/fixtures/messages/messages.fr_BE.xml create mode 100644 tests/fixtures/messages/messages_bis.fr.xml create mode 100644 tests/fixtures/myCache.php create mode 100644 tests/fixtures/myCache2.php create mode 100644 tests/fixtures/myClickBrowser.php create mode 100644 tests/fixtures/myComponent.php create mode 100644 tests/fixtures/myConfigHandler.php create mode 100644 tests/fixtures/myContext.php create mode 100644 tests/fixtures/myController.php create mode 100644 tests/fixtures/myController2.php create mode 100644 tests/fixtures/myController3.php create mode 100644 tests/fixtures/myController4.php create mode 100644 tests/fixtures/myDatabase.php create mode 100644 tests/fixtures/myEventDispatcherTest.php create mode 100644 tests/fixtures/myException.php create mode 100644 tests/fixtures/myFilesystem.php create mode 100644 tests/fixtures/myFilter.php create mode 100644 tests/fixtures/myForm.php create mode 100644 tests/fixtures/myGenerator.php create mode 100644 tests/fixtures/myI18n.php create mode 100644 tests/fixtures/myI18nExtractTest.php create mode 100644 tests/fixtures/myLogger.php create mode 100644 tests/fixtures/myLogger2.php create mode 100644 tests/fixtures/myLoggerWrapper.php create mode 100644 tests/fixtures/myObjectRoute.php create mode 100644 tests/fixtures/myPager.php create mode 100644 tests/fixtures/myPatternRouting.php create mode 100644 tests/fixtures/myPluginManager.php create mode 100644 tests/fixtures/myRequest.php create mode 100644 tests/fixtures/myRequest2.php create mode 100644 tests/fixtures/myRequest3.php create mode 100644 tests/fixtures/myRequest4.php create mode 100644 tests/fixtures/myRequest5.php create mode 100644 tests/fixtures/myRequest6.php create mode 100644 tests/fixtures/myResponse.php create mode 100644 tests/fixtures/myResponse2.php create mode 100644 tests/fixtures/myRouting.php create mode 100644 tests/fixtures/mySfUser.php create mode 100644 tests/fixtures/myStorage.php create mode 100644 tests/fixtures/myValidatedFile.php create mode 100644 tests/fixtures/myView.php create mode 100644 tests/fixtures/myViewCacheManager.php create mode 100644 tests/fixtures/myViewConfigHandler.php create mode 100644 tests/fixtures/myWebResponse.php create mode 100644 tests/fixtures/myWebResponse2.php create mode 100644 tests/fixtures/myYamlConfigHandler.php create mode 100644 tests/fixtures/notaLogger.php create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/p/sffooplugin/info.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/p/sftestplugin/info.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sffooplugin/1.0.0.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sffooplugin/allreleases.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sffooplugin/deps.1.0.0.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/1.0.0.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/1.0.3.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/1.0.4.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/1.1.3.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/1.1.4.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/allreleases.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/deps.1.0.0.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/deps.1.0.3.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/deps.1.0.4.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/deps.1.1.3.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/REST/r/sftestplugin/deps.1.1.4.txt create mode 100644 tests/fixtures/plugin/http/pear.example.com/channel.xml create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfFooPlugin/sfFooPlugin-1.0.0.tgz create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.0.tgz create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.3.tgz create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.4.tgz create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.3.tgz create mode 100644 tests/fixtures/plugin/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.4.tgz create mode 100644 tests/fixtures/plugin/sfFooPlugin/package.xml create mode 100644 tests/fixtures/plugin/sfFooPlugin/sfFooPlugin-1.0.0/VERSION create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.0/package.xml create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.0/sfTestPlugin-1.0.0/VERSION create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.3/package.xml create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.3/sfTestPlugin-1.0.3/VERSION create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.4/package.xml create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.0.4/sfTestPlugin-1.0.4/VERSION create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.1.3/package.xml create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.1.3/sfTestPlugin-1.1.3/VERSION create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.1.4/package.xml create mode 100644 tests/fixtures/plugin/sfTestPlugin/sfTestPlugin-1.1.4/sfTestPlugin-1.1.4/VERSION create mode 100644 tests/fixtures/service/containers/container10.php create mode 100644 tests/fixtures/service/containers/container8.php create mode 100644 tests/fixtures/service/containers/container9.php create mode 100644 tests/fixtures/service/graphviz/services1.dot create mode 100644 tests/fixtures/service/graphviz/services10-1.dot create mode 100644 tests/fixtures/service/graphviz/services10.dot create mode 100644 tests/fixtures/service/graphviz/services9.dot create mode 100644 tests/fixtures/service/includes/classes.php create mode 100644 tests/fixtures/service/includes/foo.php create mode 100644 tests/fixtures/service/php/services1-1.php create mode 100644 tests/fixtures/service/php/services1.php create mode 100644 tests/fixtures/service/php/services8.php create mode 100644 tests/fixtures/service/php/services9.php create mode 100644 tests/fixtures/service/yaml/nonvalid1.yml create mode 100644 tests/fixtures/service/yaml/nonvalid2.yml create mode 100644 tests/fixtures/service/yaml/services1.yml create mode 100644 tests/fixtures/service/yaml/services2.yml create mode 100644 tests/fixtures/service/yaml/services3.yml create mode 100644 tests/fixtures/sfAlwaysAbsoluteRoute.php create mode 100644 tests/fixtures/sfCompileConfigHandler/simple.yml create mode 100644 tests/fixtures/sfDefineEnvironmentConfigHandler/prefix_all.yml create mode 100644 tests/fixtures/sfDefineEnvironmentConfigHandler/prefix_default.yml create mode 100644 tests/fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php create mode 100644 tests/fixtures/sfException.php create mode 100644 tests/fixtures/sfFilterConfigHandler/condition.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/default_filters.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/disable.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/filters.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/no_class.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/no_execution.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/no_rendering.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/not_disabled.yml create mode 100644 tests/fixtures/sfFilterConfigHandler/result.php create mode 100644 tests/fixtures/sfGeneratorConfigHandler/empty.yml create mode 100644 tests/fixtures/sfGeneratorConfigHandler/no_generator_class.yml create mode 100644 tests/fixtures/sfGeneratorConfigHandler/no_generator_section.yml create mode 100644 tests/fixtures/sfGeneratorConfigHandler/root_edit_section.yml create mode 100644 tests/fixtures/sfGeneratorConfigHandler/root_fields_section.yml create mode 100644 tests/fixtures/sfGeneratorConfigHandler/root_list_section.yml create mode 100644 tests/fixtures/sfMessageSource_Simple.php create mode 100644 tests/fixtures/sfMessageSource_Simple2.php create mode 100644 tests/fixtures/sfPluginTestHelper.php create mode 100644 tests/fixtures/sfSimpleCache.php create mode 100644 tests/fixtures/sfSimpleYamlConfigHandler/config.yml create mode 100644 tests/fixtures/sfSimpleYamlConfigHandler/config_bis.yml create mode 100644 tests/fixtures/sfUser.php create mode 100644 tests/fixtures/sfWebDebugTest.php create mode 100644 tests/fixtures/symfony/apps/cache/config/app.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/cacheConfiguration.class.php create mode 100644 tests/fixtures/symfony/apps/cache/config/factories.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/filters.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/routing.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/security.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/settings.yml create mode 100644 tests/fixtures/symfony/apps/cache/config/view.yml create mode 100644 tests/fixtures/symfony/apps/cache/lib/myUser.class.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/actions/components.class.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/data/ok48.png create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_anotherCacheablePartial.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_cacheableComponent.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_cacheablePartial.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_component.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_contextualCacheableComponent.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_contextualCacheablePartial.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_contextualComponent.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_contextualPartial.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/_partial.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/actionSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/anotherPartialSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/componentSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/imageSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/listSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/multiBisSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/multiSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/pageSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/partialSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/cache/templates/specificCacheKeySuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/httpcache/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/httpcache/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/cache/modules/httpcache/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/nocache/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/cache/modules/nocache/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/cache/modules/nocache/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/cache/templates/image.php create mode 100644 tests/fixtures/symfony/apps/cache/templates/layout.php create mode 100644 tests/fixtures/symfony/apps/frontend/config/app.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/dirmyconfig/myconfig.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/factories.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/filters.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/frontendConfiguration.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/config/routing.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/security.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/services.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/settings.yml create mode 100644 tests/fixtures/symfony/apps/frontend/config/view.yml create mode 100644 tests/fixtures/symfony/apps/frontend/lib/myAppsFrontendLibClass.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/lib/myAutoload.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/lib/myAutoloadedClass.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/lib/myFilter.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/lib/myUser.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/assetInclusion/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/assetInclusion/config/view.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/assetInclusion/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/auth/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/auth/templates/basicSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/autoload/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/autoload/lib/myAppsFrontendModulesAutoloadLib.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/autoload/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/autoload/templates/myAutoloadSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/browser/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/browser/templates/redirectTarget1Success.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/browser/templates/templateCustomCustomSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/browser/templates/templateCustomSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configFiltersSimpleFilter/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configFiltersSimpleFilter/config/filters.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configFiltersSimpleFilter/lib/configFiltersSimpleFilterFilter.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configFiltersSimpleFilter/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configModuleDisabled/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configModuleDisabled/config/module.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configModuleDisabled/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecure/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecure/config/security.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecure/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecureAction/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecureAction/config/security.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSecurityIsSecureAction/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSettingsMaxForwards/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configSettingsMaxForwards/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configViewHasLayout/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configViewHasLayout/config/view.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/configViewHasLayout/templates/withoutLayoutSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/cookie/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/escaping/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/escaping/templates/_partial1.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/escaping/templates/_partial2.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/escaping/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/exception/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/filter/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/_js_header.js.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/indexSuccess.css.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/indexSuccess.iphone.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/indexSuccess.js.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/indexSuccess.xml.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/format/templates/jsSuccess.js.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/notfound/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/presentation/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/presentation/templates/fooSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/presentation/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/renderText/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/sfConfigPlugin/config/dirmyconfig/myconfig.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/sfConfigPlugin/config/filters.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/sfConfigPlugin/config/view.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/view/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/view/config/view.yml create mode 100644 tests/fixtures/symfony/apps/frontend/modules/view/templates/fooSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/view/templates/imageSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/modules/view/templates/plainSuccess.php create mode 100644 tests/fixtures/symfony/apps/frontend/templates/layout.iphone.php create mode 100644 tests/fixtures/symfony/apps/frontend/templates/layout.php create mode 100644 tests/fixtures/symfony/apps/frontend/templates/layout.xml.php create mode 100644 tests/fixtures/symfony/apps/i18n/config/app.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/cache.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/factories.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/filters.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/i18nConfiguration.class.php create mode 100644 tests/fixtures/symfony/apps/i18n/config/routing.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/security.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/settings.yml create mode 100644 tests/fixtures/symfony/apps/i18n/config/view.yml create mode 100644 tests/fixtures/symfony/apps/i18n/i18n/messages.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/i18n/other.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/lib/myUser.class.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/actions/actions.class.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/i18n/custom.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/i18n/messages.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/i18n/other.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/lib/I18nCustomCatalogueForm.class.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/lib/I18nForm.class.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/templates/i18nFormSuccess.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/i18n/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/apps/i18n/modules/sfI18NPlugin/i18n/messages.fr.xml create mode 100644 tests/fixtures/symfony/apps/i18n/templates/layout.php create mode 100644 tests/fixtures/symfony/config/ProjectConfiguration.class.php create mode 100644 tests/fixtures/symfony/config/databases.yml create mode 100644 tests/fixtures/symfony/config/dirmyconfig/myconfig.yml create mode 100644 tests/fixtures/symfony/config/filters.yml create mode 100644 tests/fixtures/symfony/config/properties.ini create mode 100644 tests/fixtures/symfony/config/services.yml create mode 100644 tests/fixtures/symfony/config/view.yml create mode 100644 tests/fixtures/symfony/data/environment.migrated create mode 100644 tests/fixtures/symfony/lib/ExtendMe.class.php create mode 100644 tests/fixtures/symfony/lib/form/BaseForm.class.php create mode 100644 tests/fixtures/symfony/lib/myLibClass.class.php create mode 100644 tests/fixtures/symfony/log/cache_test.log create mode 100644 tests/fixtures/symfony/log/frontend_test.log create mode 100644 tests/fixtures/symfony/log/i18n_test.log create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/config/NotInLib.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/config/autoload.yml create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/config/sfAutoloadPluginConfiguration.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/lib/BaseExtendMe.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/lib/ExtendMe.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/lib/vendor/ExcludedFromAutoload.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/modules/autoloadPlugin/actions/actions.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/modules/autoloadPlugin/lib/myPluginsSfAutoloadPluginModulesAutoloadPluginLib.class.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/modules/autoloadPlugin/templates/indexSuccess.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/functional/BarFunctionalTest.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/functional/FooFunctionalTest.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/functional/nested/NestedFunctionalTest.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/unit/BarUnitTest.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/unit/FooUnitTest.php create mode 100644 tests/fixtures/symfony/plugins/sfAutoloadPlugin/test/unit/nested/NestedUnitTest.php create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/config/dirmyconfig/myconfig.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/config/filters.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/config/services.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/config/view.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/modules/sfConfigPlugin/config/dirmyconfig/myconfig.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/modules/sfConfigPlugin/config/filters.yml create mode 100644 tests/fixtures/symfony/plugins/sfConfigPlugin/modules/sfConfigPlugin/config/view.yml create mode 100644 tests/fixtures/symfony/plugins/sfI18NPlugin/i18n/messages.fr.xml create mode 100644 tests/fixtures/symfony/plugins/sfI18NPlugin/modules/sfI18NPlugin/actions/actions.class.php create mode 100644 tests/fixtures/symfony/plugins/sfI18NPlugin/modules/sfI18NPlugin/i18n/messages.fr.xml create mode 100644 tests/fixtures/symfony/plugins/sfI18NPlugin/modules/sfI18NPlugin/templates/indexSuccess.php create mode 100755 tests/fixtures/symfony/symfony create mode 100644 tests/fixtures/testFunctionCache.php create mode 100644 tests/fixtures/testObject.php create mode 100644 tests/fixtures/testObjectWithToString.php create mode 100644 tests/fixtures/testRandomFunctionCache.php create mode 100644 tests/fixtures/testValidatorFile.php create mode 100644 tests/fixtures/yaml/YtsAnchorAlias.yml create mode 100644 tests/fixtures/yaml/YtsBasicTests.yml create mode 100644 tests/fixtures/yaml/YtsBlockMapping.yml create mode 100644 tests/fixtures/yaml/YtsDocumentSeparator.yml create mode 100644 tests/fixtures/yaml/YtsErrorTests.yml create mode 100644 tests/fixtures/yaml/YtsFlowCollections.yml create mode 100644 tests/fixtures/yaml/YtsFoldedScalars.yml create mode 100644 tests/fixtures/yaml/YtsNullsAndEmpties.yml create mode 100644 tests/fixtures/yaml/YtsSpecificationExamples.yml create mode 100644 tests/fixtures/yaml/YtsTypeTransfers.yml create mode 100644 tests/fixtures/yaml/index.yml create mode 100644 tests/fixtures/yaml/sfComments.yml create mode 100644 tests/fixtures/yaml/sfMergeKey.yml create mode 100644 tests/fixtures/yaml/sfObjects.yml create mode 100644 tests/fixtures/yaml/sfQuotes.yml create mode 100644 tests/fixtures/yaml/sfTests.yml create mode 100644 tests/form/addon/sfFormSymfonyTest.php create mode 100644 tests/form/sfFormFieldSchemaTest.php create mode 100644 tests/form/sfFormFieldTest.php create mode 100644 tests/form/sfFormTest.php create mode 100644 tests/generator/sfGeneratorTest.php create mode 100644 tests/generator/sfModelGeneratorConfigurationFieldTest.php create mode 100644 tests/helper/AssetHelperTest.php create mode 100644 tests/helper/DateHelperTest.php create mode 100644 tests/helper/EscapingHelperTest.php create mode 100644 tests/helper/JavascriptBaseHelperTest.php create mode 100644 tests/helper/NumberHelperTest.php create mode 100644 tests/helper/PartialHelperTest.php create mode 100644 tests/helper/TagHelperTest.php create mode 100644 tests/helper/TextHelperTest.php create mode 100644 tests/helper/UrlHelperTest.php create mode 100644 tests/i18n/dataTest.php create mode 100644 tests/i18n/extract/sfI18nExtractTest.php create mode 100644 tests/i18n/extract/sfI18nPhpExtractorTest.php create mode 100644 tests/i18n/extract/sfI18nYamlGeneratorExtractorTest.php create mode 100644 tests/i18n/extract/sfI18nYamlValidateExtractorTest.php create mode 100644 tests/i18n/sfChoiceFormatTest.php create mode 100644 tests/i18n/sfCultureInfoTest.php create mode 100644 tests/i18n/sfI18NTest.php create mode 100644 tests/i18n/sfMessageSourceTest.php create mode 100644 tests/i18n/sfMessageSource_AggregateTest.php create mode 100644 tests/i18n/sfMessageSource_FileTest.php create mode 100644 tests/i18n/sfMessageSource_SQLiteTest.php create mode 100644 tests/i18n/sfMessageSource_XLIFFTest.php create mode 100644 tests/i18n/sfNumberFormatInfoTest.php create mode 100644 tests/log/sfAggregateLoggerTest.php create mode 100644 tests/log/sfConsoleLoggerTest.php create mode 100644 tests/log/sfFileLoggerTest.php create mode 100644 tests/log/sfLoggerTest.php create mode 100644 tests/log/sfLoggerWrapperTest.php create mode 100644 tests/log/sfStreamLoggerTest.php create mode 100644 tests/log/sfVarLoggerTest.php create mode 100644 tests/log/sfWebDebugLoggerTest.php create mode 100644 tests/mailer/sfMailerTest.php create mode 100644 tests/plugin/sfPearEnvironmentTest.php create mode 100644 tests/plugin/sfPearRestPluginTest.php create mode 100644 tests/plugin/sfPluginManagerTest.php create mode 100644 tests/plugin/sfPluginTestHelper.class.php create mode 100644 tests/plugin/sfTestPearDownloader.class.php create mode 100644 tests/plugin/sfTestPearRest.class.php create mode 100755 tests/request/sfRequestEventDispatcherTest.php create mode 100755 tests/request/sfRequestParameterHolderAttributeTest.php create mode 100755 tests/request/sfRequestParameterHolderParameterTest.php create mode 100755 tests/request/sfRequestTest.php create mode 100644 tests/request/sfWebRequestTest.php create mode 100644 tests/response/sfResponseTest.php create mode 100644 tests/response/sfWebResponseTest.php create mode 100644 tests/routing/sfObjectRouteCollectionTest.php create mode 100644 tests/routing/sfObjectRouteTest.php create mode 100644 tests/routing/sfPatternRoutingTest.php create mode 100644 tests/routing/sfRequestRouteTest.php create mode 100644 tests/routing/sfRouteTest.php create mode 100644 tests/service/sfServiceContainerBuilderTest.php create mode 100644 tests/service/sfServiceContainerDumperGraphvizTest.php create mode 100644 tests/service/sfServiceContainerDumperPhpTest.php create mode 100644 tests/service/sfServiceContainerDumperTest.php create mode 100644 tests/service/sfServiceContainerLoaderArrayTest.php create mode 100644 tests/service/sfServiceContainerLoaderTest.php create mode 100644 tests/service/sfServiceContainerTest.php create mode 100644 tests/service/sfServiceDefinitionTest.php create mode 100644 tests/service/sfServiceParameterTest.php create mode 100644 tests/service/sfServiceReferenceTest.php create mode 100644 tests/sfContext.class.php create mode 100644 tests/sfEventDispatcherTestCase.php create mode 100644 tests/sfNoRouting.class.php create mode 100644 tests/sfParameterHolderProxyTestCase.php create mode 100644 tests/storage/sfCacheSessionStorageTest.php create mode 100644 tests/storage/sfMySQLStorageTest.php create mode 100644 tests/storage/sfMySQLiStorageTest.php create mode 100644 tests/storage/sfNoStorageTest.php create mode 100644 tests/storage/sfPDOSessionStorageTest.php create mode 100644 tests/storage/sfSessionStorageTest.php create mode 100644 tests/storage/sfStorageTest.php create mode 100644 tests/task/cache/sfCacheClearTaskTest.php create mode 100644 tests/task/sfBaseTaskTest.php create mode 100644 tests/task/sfFilesystemTest.php create mode 100644 tests/task/sfTaskTest.php create mode 100644 tests/user/sfBasicSecurityUserTest.php create mode 100644 tests/user/sfUserTest.php create mode 100644 tests/util/sfBrowserTest.php create mode 100644 tests/util/sfCallableTest.php create mode 100644 tests/util/sfClassManipulatorTest.php create mode 100644 tests/util/sfContextTest.php create mode 100644 tests/util/sfDomCssSelectorTest.php create mode 100644 tests/util/sfFinderTest.php create mode 100644 tests/util/sfInflectorTest.php create mode 100644 tests/util/sfNamespacedParameterHolderTest.php create mode 100644 tests/util/sfParameterHolderTest.php create mode 100644 tests/util/sfToolkitTest.php create mode 100644 tests/validator/i18n/sfValidatorI18nChoiceCountryTest.php create mode 100644 tests/validator/i18n/sfValidatorI18nChoiceLanguageTest.php create mode 100644 tests/validator/i18n/sfValidatorI18nChoiceTimezoneTest.php create mode 100644 tests/validator/sfValidatorAndTest.php create mode 100644 tests/validator/sfValidatorBaseTest.php create mode 100644 tests/validator/sfValidatorBooleanTest.php create mode 100644 tests/validator/sfValidatorCSRFTokenTest.php create mode 100644 tests/validator/sfValidatorCallbackTest.php create mode 100644 tests/validator/sfValidatorChoiceTest.php create mode 100644 tests/validator/sfValidatorDateRangeTest.php create mode 100644 tests/validator/sfValidatorDateTest.php create mode 100644 tests/validator/sfValidatorDateTimeTest.php create mode 100644 tests/validator/sfValidatorDecoratorTest.php create mode 100644 tests/validator/sfValidatorEmailTest.php create mode 100644 tests/validator/sfValidatorEqualTest.php create mode 100644 tests/validator/sfValidatorErrorSchemaTest.php create mode 100644 tests/validator/sfValidatorErrorTest.php create mode 100644 tests/validator/sfValidatorFileMultiTest.php create mode 100644 tests/validator/sfValidatorFileTest.php create mode 100644 tests/validator/sfValidatorFromDescriptionTest.php create mode 100644 tests/validator/sfValidatorIntegerTest.php create mode 100644 tests/validator/sfValidatorIpTest.php create mode 100644 tests/validator/sfValidatorNumberTest.php create mode 100644 tests/validator/sfValidatorOrTest.php create mode 100644 tests/validator/sfValidatorPassTest.php create mode 100644 tests/validator/sfValidatorRegexTest.php create mode 100644 tests/validator/sfValidatorSchemaCompareTest.php create mode 100644 tests/validator/sfValidatorSchemaFilterTest.php create mode 100644 tests/validator/sfValidatorSchemaTest.php create mode 100644 tests/validator/sfValidatorStringTest.php create mode 100644 tests/validator/sfValidatorTimeTest.php create mode 100644 tests/validator/sfValidatorUrlTest.php create mode 100644 tests/view/sfViewCacheManagerTest.php create mode 100644 tests/view/sfViewParameterHolderTest.php create mode 100644 tests/view/sfViewTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nChoiceCountryTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nChoiceCurrencyTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nChoiceLanguageTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nChoiceTimezoneTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nDateTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nDateTimeTest.php create mode 100644 tests/widget/i18n/sfWidgetFormI18nTimeTest.php create mode 100644 tests/widget/sfWidgetFormChoiceTest.php create mode 100644 tests/widget/sfWidgetFormDateRangeTest.php create mode 100644 tests/widget/sfWidgetFormDateTest.php create mode 100644 tests/widget/sfWidgetFormDateTimeTest.php create mode 100644 tests/widget/sfWidgetFormFilterDateTest.php create mode 100644 tests/widget/sfWidgetFormFilterInputTest.php create mode 100644 tests/widget/sfWidgetFormInputCheckboxTest.php create mode 100644 tests/widget/sfWidgetFormInputFileEditableTest.php create mode 100644 tests/widget/sfWidgetFormInputFileMultiTest.php create mode 100644 tests/widget/sfWidgetFormInputFileTest.php create mode 100644 tests/widget/sfWidgetFormInputHiddenTest.php create mode 100644 tests/widget/sfWidgetFormInputPasswordTest.php create mode 100644 tests/widget/sfWidgetFormInputReadTest.php create mode 100644 tests/widget/sfWidgetFormInputTextTest.php create mode 100644 tests/widget/sfWidgetFormSchemaDecoratorTest.php create mode 100644 tests/widget/sfWidgetFormSchemaFormatterListTest.php create mode 100644 tests/widget/sfWidgetFormSchemaFormatterTableTest.php create mode 100644 tests/widget/sfWidgetFormSchemaFormatterTest.php create mode 100644 tests/widget/sfWidgetFormSchemaTest.php create mode 100644 tests/widget/sfWidgetFormSelectCheckboxTest.php create mode 100644 tests/widget/sfWidgetFormSelectManyTest.php create mode 100644 tests/widget/sfWidgetFormSelectRadioTest.php create mode 100644 tests/widget/sfWidgetFormSelectTest.php create mode 100644 tests/widget/sfWidgetFormTest.php create mode 100644 tests/widget/sfWidgetFormTextareaTest.php create mode 100644 tests/widget/sfWidgetFormTimeTest.php create mode 100644 tests/widget/sfWidgetTest.php create mode 100644 tests/yaml/sfYamlDumperTest.php create mode 100644 tests/yaml/sfYamlInlineTest.php create mode 100644 tests/yaml/sfYamlParserTest.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 561845967..189711c9d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,6 +39,9 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" + extensions: "json,memcached,apcu" + ini-values: date.timezone=UTC,memory_limit=-1,apc.enable_cli=1 + tools: pecl - name: Get composer cache directory id: composer-cache @@ -58,4 +61,6 @@ jobs: run: php data/bin/check_configuration.php - name: Run Tests - run: php data/bin/symfony symfony:test --trace + run: php vendor/bin/phpunit + env: + MEMCACHED_HOST: 'localhost:11211' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c17d4767..8d9c80e04 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/ /vendor /composer.lock .php-cs-fixer.cache +.phpunit.result.cache +phpunit.xml diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f5e11f987..ba3caf92f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,8 +10,8 @@ ->exclude('task/generator/skeleton/') ->exclude('plugins/sfDoctrinePlugin/data/generator/') // Exclude generated files (single files) - ->notPath('unit/config/fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php') - ->notPath('unit/config/fixtures/sfFilterConfigHandler/result.php') + ->notPath('fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php') + ->notPath('fixtures/sfFilterConfigHandler/result.php') ; $config = new PhpCsFixer\Config(); diff --git a/composer.json b/composer.json index a424d6ea6..f56ace222 100755 --- a/composer.json +++ b/composer.json @@ -8,7 +8,10 @@ "swiftmailer/swiftmailer": "~5.2 || ^6.0" }, "require-dev": { - "psr/log": "*" + "ext-zlib": "*", + "ext-apcu": "*", + "psr/log": "*", + "phpunit/phpunit": "^9.6" }, "autoload": { "files": ["autoload.php"] @@ -26,5 +29,9 @@ "replace": { "lexpress/symfony1": "^1.5" }, + "scripts": { + "test": "phpunit", + "php-cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix" + }, "bin": ["data/bin/symfony"] } diff --git a/lib/autoload/sfCoreAutoload.class.php b/lib/autoload/sfCoreAutoload.class.php index 2b711629c..30ea6f231 100755 --- a/lib/autoload/sfCoreAutoload.class.php +++ b/lib/autoload/sfCoreAutoload.class.php @@ -301,6 +301,11 @@ class sfCoreAutoload 'sftesterresponse' => 'test/sfTesterResponse.class.php', 'sftesteruser' => 'test/sfTesterUser.class.php', 'sftesterviewcache' => 'test/sfTesterViewCache.class.php', + 'symfony1applicationtestcase' => 'test/Symfony1ApplicationTestCase.php', + 'symfony1projecttestcase' => 'test/Symfony1ProjectTestCase.php', + 'testcasedrivenapplicationconfiguration' => 'test/TestCaseDrivenApplicationConfiguration.php', + 'testcasedrivenconfigurationinterface' => 'test/TestCaseDrivenConfigurationInterface.php', + 'testcasedrivenprojectconfiguration' => 'test/TestCaseDrivenProjectConfiguration.php', 'sfbasicsecurityuser' => 'user/sfBasicSecurityUser.class.php', 'sfsecurityuser' => 'user/sfSecurityUser.class.php', 'sfuser' => 'user/sfUser.class.php', diff --git a/lib/cache/sfAPCCache.class.php b/lib/cache/sfAPCCache.class.php index 721bea021..c7e7b24dd 100644 --- a/lib/cache/sfAPCCache.class.php +++ b/lib/cache/sfAPCCache.class.php @@ -32,7 +32,7 @@ public function initialize($options = array()) { parent::initialize($options); - $this->enabled = function_exists('apc_store') && ini_get('apc.enabled'); + $this->enabled = function_exists('apcu_store') && apcu_enabled(); } /** @@ -69,6 +69,8 @@ public function has($key) * @see sfCache * * @param mixed|null $lifetime + * + * @return bool|array */ public function set($key, $data, $lifetime = null) { @@ -76,7 +78,7 @@ public function set($key, $data, $lifetime = null) return true; } - return apc_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime)); + return apcu_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime)); } /** @@ -88,7 +90,7 @@ public function remove($key) return true; } - return apc_delete($this->getOption('prefix').$key); + return apcu_delete($this->getOption('prefix').$key); } /** @@ -101,7 +103,7 @@ public function clean($mode = sfCache::ALL) } if (sfCache::ALL === $mode) { - return apc_clear_cache('user'); + return apcu_clear_cache(); } } @@ -138,7 +140,7 @@ public function removePattern($pattern) return true; } - $infos = apc_cache_info('user'); + $infos = apcu_cache_info(); if (!is_array($infos['cache_list'])) { return; } @@ -147,7 +149,7 @@ public function removePattern($pattern) foreach ($infos['cache_list'] as $info) { if (preg_match($regexp, $info['info'])) { - apc_delete($info['info']); + apcu_delete($info['info']); } } } @@ -165,7 +167,7 @@ protected function getCacheInfo($key) return false; } - $infos = apc_cache_info('user'); + $infos = apcu_cache_info(); if (is_array($infos['cache_list'])) { foreach ($infos['cache_list'] as $info) { @@ -181,7 +183,7 @@ protected function getCacheInfo($key) private function fetch($key, &$success) { $has = null; - $value = apc_fetch($key, $has); + $value = apcu_fetch($key, $has); // the second argument was added in APC 3.0.17. If it is still null we fall back to the value returned if (null !== $has) { $success = $has; diff --git a/lib/cache/sfEAcceleratorCache.class.php b/lib/cache/sfEAcceleratorCache.class.php index c97092456..33166aa38 100644 --- a/lib/cache/sfEAcceleratorCache.class.php +++ b/lib/cache/sfEAcceleratorCache.class.php @@ -14,6 +14,8 @@ * @author Fabien Potencier * * @version SVN: $Id$ + * + * @deprecated */ class sfEAcceleratorCache extends sfCache { diff --git a/lib/cache/sfFileCache.class.php b/lib/cache/sfFileCache.class.php index 11d2d3c84..0847c36c9 100644 --- a/lib/cache/sfFileCache.class.php +++ b/lib/cache/sfFileCache.class.php @@ -63,7 +63,13 @@ public function get($key, $default = null) return $default; } - return $data[self::READ_DATA]; + $rawData = $data[self::READ_DATA]; + + if ('FaLSe' === $rawData) { + $rawData = false; + } + + return $rawData; } /** @@ -87,6 +93,10 @@ public function set($key, $data, $lifetime = null) $this->clean(sfCache::OLD); } + if (false === $data) { + $data = 'FaLSe'; + } + return $this->write($this->getFilePath($key), $data, time() + $this->getLifetime($lifetime)); } diff --git a/lib/cache/sfSQLiteCache.class.php b/lib/cache/sfSQLiteCache.class.php index 5200cb60d..957e7420f 100644 --- a/lib/cache/sfSQLiteCache.class.php +++ b/lib/cache/sfSQLiteCache.class.php @@ -72,6 +72,10 @@ public function get($key, $default = null) $data = $this->dbh->singleQuery(sprintf("SELECT data FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time())); } + if ('FaLSe' === $data) { + $data = false; + } + return null === $data ? $default : $data; } @@ -81,7 +85,7 @@ public function get($key, $default = null) public function has($key) { if ($this->isSqLite3()) { - return (int) $this->dbh->querySingle(sprintf("SELECT count(*) FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time())); + return $this->dbh->querySingle(sprintf("SELECT count(*) FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time())) > 0; } return (bool) $this->dbh->query(sprintf("SELECT key FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time()))->numRows(); @@ -98,6 +102,10 @@ public function set($key, $data, $lifetime = null) $this->clean(sfCache::OLD); } + if (false === $data) { + $data = 'FaLSe'; + } + if ($this->isSqLite3()) { return $this->dbh->exec(sprintf("INSERT OR REPLACE INTO cache (key, data, timeout, last_modified) VALUES ('%s', '%s', %d, %d)", $this->dbh->escapeString($key), $this->dbh->escapeString($data), time() + $this->getLifetime($lifetime), time())); } diff --git a/lib/cache/sfXCacheCache.class.php b/lib/cache/sfXCacheCache.class.php index 8c5c53e5e..251117f75 100644 --- a/lib/cache/sfXCacheCache.class.php +++ b/lib/cache/sfXCacheCache.class.php @@ -14,6 +14,8 @@ * @author Fabien Potencier * * @version SVN: $Id$ + * + * @deprecated */ class sfXCacheCache extends sfCache { diff --git a/lib/command/sfCommandOption.class.php b/lib/command/sfCommandOption.class.php index 43e1f91d3..b5b7dfff2 100644 --- a/lib/command/sfCommandOption.class.php +++ b/lib/command/sfCommandOption.class.php @@ -97,7 +97,7 @@ public function getName() */ public function acceptParameter() { - return $this->isParameterRequired() || $this->isParameterOptional(); + return self::PARAMETER_NONE !== (self::PARAMETER_NONE & $this->mode); } /** diff --git a/lib/database/sfMySQLDatabase.class.php b/lib/database/sfMySQLDatabase.class.php index fac1ccd9f..02222e9b9 100644 --- a/lib/database/sfMySQLDatabase.class.php +++ b/lib/database/sfMySQLDatabase.class.php @@ -24,6 +24,8 @@ * @author Sean Kerr * * @version SVN: $Id$ + * + * @deprecated */ class sfMySQLDatabase extends sfDatabase { @@ -31,9 +33,13 @@ class sfMySQLDatabase extends sfDatabase * Connects to the database. * * @throws sfDatabaseException If a connection could not be created + * + * @deprecated */ public function connect() { + @trigger_error('sfMySQLDatabase storage is deprecated. use sfMySQLiDatabase instead.', \E_USER_DEPRECATED); + $database = $this->getParameter('database'); $host = $this->getParameter('host', 'localhost'); $password = $this->getParameter('password'); @@ -78,9 +84,13 @@ public function connect() * Execute the shutdown procedure. * * @throws sfDatabaseException If an error occurs while shutting down this database + * + * @deprecated */ public function shutdown() { + @trigger_error('sfMySQLDatabase storage is deprecated. use sfMySQLiDatabase instead.', \E_USER_DEPRECATED); + if (null != $this->connection) { @mysql_close($this->connection); } @@ -92,9 +102,13 @@ public function shutdown() * @param bool $persistent wether persistent connections are use or not * * @return string name of connect method + * + * @deprecated */ protected function getConnectMethod($persistent) { + @trigger_error('sfMySQLDatabase storage is deprecated. use sfMySQLiDatabase instead.', \E_USER_DEPRECATED); + return $persistent ? 'mysql_pconnect' : 'mysql_connect'; } @@ -104,9 +118,13 @@ protected function getConnectMethod($persistent) * @param string $database Name of database to be connected * * @return bool true if this was successful + * + * @deprecated */ protected function selectDatabase($database) { + @trigger_error('sfMySQLDatabase storage is deprecated. use sfMySQLiDatabase instead.', \E_USER_DEPRECATED); + return null != $database && !@mysql_select_db($database, $this->connection); } } diff --git a/lib/form/sfForm.class.php b/lib/form/sfForm.class.php index 4852027bf..e8c68e36d 100644 --- a/lib/form/sfForm.class.php +++ b/lib/form/sfForm.class.php @@ -503,8 +503,17 @@ public function mergeForm(sfForm $form) $this->validatorSchema[$field] = $validator; } - $this->getWidgetSchema()->setLabels($form->getWidgetSchema()->getLabels() + $this->getWidgetSchema()->getLabels()); - $this->getWidgetSchema()->setHelps($form->getWidgetSchema()->getHelps() + $this->getWidgetSchema()->getHelps()); + $labels = $this->getWidgetSchema()->getLabels(); + foreach ($form->getWidgetSchema()->getLabels() as $name => $label) { + $labels[$name] = $label; + } + $this->getWidgetSchema()->setLabels($labels); + + $helps = $this->getWidgetSchema()->getHelps(); + foreach ($form->getWidgetSchema()->getHelps() as $name => $help) { + $helps[$name] = $help; + } + $this->getWidgetSchema()->setHelps($helps); $this->mergePreValidator($form->getValidatorSchema()->getPreValidator()); $this->mergePostValidator($form->getValidatorSchema()->getPostValidator()); diff --git a/lib/i18n/sfI18N.class.php b/lib/i18n/sfI18N.class.php index 9c0332558..94e18bf3a 100644 --- a/lib/i18n/sfI18N.class.php +++ b/lib/i18n/sfI18N.class.php @@ -313,12 +313,12 @@ public function getDateForCulture($date, $culture = null) * @param string $time The formatted date as string * @param string $culture The culture * - * @return array An array with the hour and minute + * @return array|null An array with the hour and minute */ public function getTimeForCulture($time, $culture = null) { if (!$time) { - return 0; + return null; } $culture = null === $culture ? $this->culture : $culture; diff --git a/lib/i18n/sfMessageSource_XLIFF.class.php b/lib/i18n/sfMessageSource_XLIFF.class.php index 48e08a2ad..f073b9e70 100644 --- a/lib/i18n/sfMessageSource_XLIFF.class.php +++ b/lib/i18n/sfMessageSource_XLIFF.class.php @@ -50,9 +50,11 @@ class sfMessageSource_XLIFF extends sfMessageSource_File */ public function &loadData($filename) { + $translations = false; + libxml_use_internal_errors(true); if (!$xml = simplexml_load_file($filename)) { - return false; + return $translations; } libxml_use_internal_errors(false); diff --git a/lib/mailer/sfMailer.class.php b/lib/mailer/sfMailer.class.php index bb55247f4..665b23489 100755 --- a/lib/mailer/sfMailer.class.php +++ b/lib/mailer/sfMailer.class.php @@ -58,7 +58,7 @@ public function __construct(sfEventDispatcher $dispatcher, $options) 'logging' => false, 'delivery_strategy' => self::REALTIME, 'transport' => array( - 'class' => 'Swift_MailTransport', + 'class' => 'Swift_SendmailTransport', 'param' => array(), ), ), $options); diff --git a/lib/plugin/sfPearConfig.class.php b/lib/plugin/sfPearConfig.class.php index 20a2edbe9..fa839da51 100644 --- a/lib/plugin/sfPearConfig.class.php +++ b/lib/plugin/sfPearConfig.class.php @@ -23,6 +23,8 @@ public function &getREST($version, $options = array()) { $class = 'sfPearRest'.str_replace('.', '', $version); - return new $class($this, $options); + $instance = new $class($this, $options); + + return $instance; } } diff --git a/lib/plugin/sfPluginManager.class.php b/lib/plugin/sfPluginManager.class.php index 0b23c29ba..91dd1d609 100644 --- a/lib/plugin/sfPluginManager.class.php +++ b/lib/plugin/sfPluginManager.class.php @@ -428,7 +428,8 @@ protected function isPluginCompatibleWithDependency($dependency) */ protected function checkDependency($dependency) { - $dependencyChecker = new PEAR_Dependency2($this->environment->getConfig(), array(), array('package' => '', 'channel' => '')); + $config = $this->environment->getConfig(); + $dependencyChecker = new PEAR_Dependency2($config, array(), array('package' => '', 'channel' => '')); PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $e = $dependencyChecker->validatePackageDependency($dependency, true, array()); diff --git a/lib/request/sfWebRequest.class.php b/lib/request/sfWebRequest.class.php index 554c04c54..ca5d64dc8 100644 --- a/lib/request/sfWebRequest.class.php +++ b/lib/request/sfWebRequest.class.php @@ -436,7 +436,7 @@ public function getLanguages() return $this->languages; } - if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) || empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { return array(); } diff --git a/lib/response/sfResponse.class.php b/lib/response/sfResponse.class.php index 3735789b0..951d5c4ea 100644 --- a/lib/response/sfResponse.class.php +++ b/lib/response/sfResponse.class.php @@ -25,7 +25,7 @@ abstract class sfResponse implements Serializable protected $dispatcher; /** @var string */ - protected $content = ''; + protected $content; /** * Class constructor. diff --git a/lib/service/sfServiceContainerDumperGraphviz.class.php b/lib/service/sfServiceContainerDumperGraphviz.class.php index 80e1f0a61..6f5702554 100644 --- a/lib/service/sfServiceContainerDumperGraphviz.class.php +++ b/lib/service/sfServiceContainerDumperGraphviz.class.php @@ -23,6 +23,7 @@ class sfServiceContainerDumperGraphviz extends sfServiceContainerDumper { protected $nodes; protected $edges; + /* array */ protected $options; /** * Dumps the service container as a graphviz graph. diff --git a/lib/test/Symfony1ApplicationTestCase.php b/lib/test/Symfony1ApplicationTestCase.php new file mode 100644 index 000000000..61f5646bd --- /dev/null +++ b/lib/test/Symfony1ApplicationTestCase.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class Symfony1ApplicationTestCase extends TestCase +{ + public function resetSfConfig() + { + sfConfig::set('sf_symfony_lib_dir', realpath(__DIR__.'/../lib')); + sfConfig::set('sf_test_cache_dir', sys_get_temp_dir().'/sf_test_project'); + } + + public function getEnvironment() + { + return 'test'; + } + + public function getDebug() + { + return true; + } + + public function getEventDispatcher() + { + return null; + } + + public function getRootDir() + { + return null; + } + + public function projectSetup(sfApplicationConfiguration $applicationConfiguration) {} + + public function getApplicationConfiguration() + { + return new TestCaseDrivenApplicationConfiguration( + $this, + $this->getEnvironment(), + $this->getDebug(), + $this->getRootDir(), + $this->getEventDispatcher() + ); + } +} diff --git a/lib/test/Symfony1ProjectTestCase.php b/lib/test/Symfony1ProjectTestCase.php new file mode 100644 index 000000000..4bde0c3e9 --- /dev/null +++ b/lib/test/Symfony1ProjectTestCase.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class Symfony1ProjectTestCase extends TestCase +{ + public function resetSfConfig() + { + sfConfig::set('sf_symfony_lib_dir', realpath(__DIR__.'/../lib')); + sfConfig::set('sf_test_cache_dir', sys_get_temp_dir().'/sf_test_project'); + } + + public function projectSetup(sfProjectConfiguration $configuration) {} + + public function getEventDispatcher() + { + return null; + } + + public function getRootDir() + { + return null; + } + + public function getProjectConfiguration() + { + return new TestCaseDrivenProjectConfiguration($this, $this->getRootDir(), $this->getEventDispatcher()); + } +} diff --git a/lib/test/TestCaseDrivenApplicationConfiguration.php b/lib/test/TestCaseDrivenApplicationConfiguration.php new file mode 100644 index 000000000..a6236b485 --- /dev/null +++ b/lib/test/TestCaseDrivenApplicationConfiguration.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class TestCaseDrivenApplicationConfiguration extends sfApplicationConfiguration implements TestCaseDrivenConfigurationInterface +{ + protected $testCase; + + public function __construct($testCase, $environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null) + { + $this->testCase = $testCase; + parent::__construct($environment, $debug, $rootDir, $dispatcher); + } + + public function getTestCase() + { + return $this->testCase; + } + + public function getI18NGlobalDirs() + { + if (method_exists($this->testCase, 'getI18NGlobalDirs')) { + return $this->testCase->getI18NGlobalDirs(); + } + + return parent::getI18NGlobalDirs(); + } +} diff --git a/lib/test/TestCaseDrivenConfigurationInterface.php b/lib/test/TestCaseDrivenConfigurationInterface.php new file mode 100644 index 000000000..1a9fe9b26 --- /dev/null +++ b/lib/test/TestCaseDrivenConfigurationInterface.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +interface TestCaseDrivenConfigurationInterface +{ + public function getTestCase(); +} diff --git a/lib/test/TestCaseDrivenProjectConfiguration.php b/lib/test/TestCaseDrivenProjectConfiguration.php new file mode 100644 index 000000000..49e1316c0 --- /dev/null +++ b/lib/test/TestCaseDrivenProjectConfiguration.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class TestCaseDrivenProjectConfiguration extends ProjectConfiguration implements TestCaseDrivenConfigurationInterface +{ + protected $testCase; + + public function __construct($testCase, $rootDir = null, sfEventDispatcher $dispatcher = null) + { + $this->testCase = $testCase; + + parent::__construct($rootDir, $dispatcher); + } + + public function getTestCase() + { + return $this->testCase; + } +} diff --git a/lib/util/sfClassManipulator.class.php b/lib/util/sfClassManipulator.class.php index 45b628b72..6a96e933b 100644 --- a/lib/util/sfClassManipulator.class.php +++ b/lib/util/sfClassManipulator.class.php @@ -190,7 +190,7 @@ public function filterMethod($method, $callable) $line .= $token; } - $lines = preg_split('/(\r?\n)/', $line, null, PREG_SPLIT_DELIM_CAPTURE); + $lines = preg_split('/(\r?\n)/', $line, -1, PREG_SPLIT_DELIM_CAPTURE); if (count($lines) > 1 || $break) { $line = $break ? '' : array_pop($lines); foreach (array_chunk($lines, 2) as $chunk) { diff --git a/lib/validator/sfValidatorDate.class.php b/lib/validator/sfValidatorDate.class.php index a4366932a..2fa355989 100644 --- a/lib/validator/sfValidatorDate.class.php +++ b/lib/validator/sfValidatorDate.class.php @@ -139,6 +139,10 @@ protected function doClean($value) $format = $this->getOption('with_time') ? $this->getOption('datetime_output') : $this->getOption('date_output'); + if ('U' === $format) { + return isset($date) ? (int) $date->format($format) : (int) date($format, $cleanTime); + } + return isset($date) ? $date->format($format) : date($format, $cleanTime); } diff --git a/lib/validator/sfValidatorError.class.php b/lib/validator/sfValidatorError.class.php index f94ff6bc0..9a25b7b1a 100644 --- a/lib/validator/sfValidatorError.class.php +++ b/lib/validator/sfValidatorError.class.php @@ -108,7 +108,7 @@ public function getArguments($raw = false) continue; } - $arguments["%{$key}%"] = htmlspecialchars($value, ENT_QUOTES, sfValidatorBase::getCharset()); + $arguments["%{$key}%"] = null !== $value ? htmlspecialchars($value, ENT_QUOTES, sfValidatorBase::getCharset()) : ''; } return $arguments; diff --git a/lib/validator/sfValidatorFile.class.php b/lib/validator/sfValidatorFile.class.php index 368bea6f1..a2b56d91f 100644 --- a/lib/validator/sfValidatorFile.class.php +++ b/lib/validator/sfValidatorFile.class.php @@ -96,10 +96,14 @@ protected function configure($options = array(), $messages = array()) */ protected function doClean($value) { - if (!is_array($value) || !isset($value['tmp_name'])) { + if (!is_array($value)) { throw new sfValidatorError($this, 'invalid', array('value' => (string) $value)); } + if (!isset($value['tmp_name'])) { + throw new sfValidatorError($this, 'invalid', array('value' => var_export($value, true))); + } + if (!isset($value['name'])) { $value['name'] = ''; } diff --git a/lib/validator/sfValidatorFromDescription.class.php b/lib/validator/sfValidatorFromDescription.class.php index 11bcd93fc..525f5b629 100644 --- a/lib/validator/sfValidatorFromDescription.class.php +++ b/lib/validator/sfValidatorFromDescription.class.php @@ -305,6 +305,7 @@ class sfValidatorFDTokenOperator protected $class; protected $operator; protected $token; + protected $arguments = array(); public function __construct($operator, $arguments = array()) { diff --git a/lib/validator/sfValidatorIp.class.php b/lib/validator/sfValidatorIp.class.php index 9bf2cdb24..c65334083 100644 --- a/lib/validator/sfValidatorIp.class.php +++ b/lib/validator/sfValidatorIp.class.php @@ -106,7 +106,7 @@ protected function doClean($value) break; default: - $flag = null; + $flag = 0; break; } diff --git a/lib/validator/sfValidatorSchema.class.php b/lib/validator/sfValidatorSchema.class.php index 9064138c9..2ad47d96d 100644 --- a/lib/validator/sfValidatorSchema.class.php +++ b/lib/validator/sfValidatorSchema.class.php @@ -354,6 +354,10 @@ protected function doClean($values) protected function getBytes($value) { + if (empty($value)) { + return 0; + } + $value = trim($value); $number = (float) $value; $modifier = strtolower($value[strlen($value) - 1]); diff --git a/lib/validator/sfValidatorSchemaCompare.class.php b/lib/validator/sfValidatorSchemaCompare.class.php index 3572aa1cb..b3a1aacb1 100644 --- a/lib/validator/sfValidatorSchemaCompare.class.php +++ b/lib/validator/sfValidatorSchemaCompare.class.php @@ -97,16 +97,15 @@ public function asString($indent = 0) protected function doClean($values) { if (null === $values) { - $values = array(); - } - - if (!is_array($values)) { + $leftValue = null; + $rightValue = null; + } elseif (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); + } else { + $leftValue = isset($values[$this->getOption('left_field')]) ? $values[$this->getOption('left_field')] : null; + $rightValue = isset($values[$this->getOption('right_field')]) ? $values[$this->getOption('right_field')] : null; } - $leftValue = isset($values[$this->getOption('left_field')]) ? $values[$this->getOption('left_field')] : null; - $rightValue = isset($values[$this->getOption('right_field')]) ? $values[$this->getOption('right_field')] : null; - switch ($this->getOption('operator')) { case self::GREATER_THAN: $valid = $leftValue > $rightValue; diff --git a/lib/validator/sfValidatorString.class.php b/lib/validator/sfValidatorString.class.php index 35574e7d9..169bc4e3f 100644 --- a/lib/validator/sfValidatorString.class.php +++ b/lib/validator/sfValidatorString.class.php @@ -51,6 +51,10 @@ protected function configure($options = array(), $messages = array()) */ protected function doClean($value) { + if (null === $value) { + return $value; + } + $clean = (string) $value; $length = function_exists('mb_strlen') ? mb_strlen($clean, $this->getCharset()) : strlen($clean); diff --git a/lib/validator/sfValidatorTime.class.php b/lib/validator/sfValidatorTime.class.php index bda409397..f98d3d568 100644 --- a/lib/validator/sfValidatorTime.class.php +++ b/lib/validator/sfValidatorTime.class.php @@ -58,7 +58,7 @@ protected function doClean($value) } $clean = $this->convertTimeArrayToTimestamp($match); - } elseif (!ctype_digit($value)) { + } elseif (!ctype_digit((string) $value)) { $clean = strtotime($value); if (false === $clean) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); @@ -67,7 +67,18 @@ protected function doClean($value) $clean = (int) $value; } - return $clean === $this->getEmptyValue() ? $clean : date($this->getOption('time_output'), $clean); + if ($clean === $this->getEmptyValue()) { + return $clean; + } + + $formattedClean = date($this->getOption('time_output'), $clean); + + // don't change integer type + if ('U' === $this->getOption('time_output')) { + settype($formattedClean, 'integer'); + } + + return $formattedClean; } /** diff --git a/lib/vendor/lime/lime.php b/lib/vendor/lime/lime.php index 2d5f8986e..18102a40d 100644 --- a/lib/vendor/lime/lime.php +++ b/lib/vendor/lime/lime.php @@ -14,6 +14,7 @@ * @package lime * @author Fabien Potencier * @version SVN: $Id: lime.php 29529 2010-05-19 13:41:48Z fabien $ + * @deprecated */ class lime_test { diff --git a/lib/view/sfViewCacheManager.class.php b/lib/view/sfViewCacheManager.class.php index dd5201b00..f568353f1 100644 --- a/lib/view/sfViewCacheManager.class.php +++ b/lib/view/sfViewCacheManager.class.php @@ -387,7 +387,7 @@ public function get($internalUri) public function has($internalUri) { if (!$this->isCacheable($internalUri) || $this->ignore()) { - return null; + return false; } return $this->cache->has($this->generateCacheKey($internalUri)); diff --git a/lib/yaml/sfYamlInline.class.php b/lib/yaml/sfYamlInline.class.php index d1028416f..396c0f0fb 100644 --- a/lib/yaml/sfYamlInline.class.php +++ b/lib/yaml/sfYamlInline.class.php @@ -101,7 +101,15 @@ public static function dump($value) return is_string($value) ? "'{$value}'" : (int) $value; case is_numeric($value) && false === strpbrk($value, "\f\n\r\t\v"): - return is_infinite($value) ? str_ireplace('INF', '.Inf', (string) $value) : (is_string($value) ? "'{$value}'" : $value); + if (is_infinite($value)) { + return str_ireplace('INF', '.Inf', (string) $value); + } + + if (is_float($value)) { + return strval($value); + } + + return is_string($value) ? "'{$value}'" : $value; case false !== strpos($value, "\n") || false !== strpos($value, "\r"): return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\n', '\r'), $value)); diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..41c3f6314 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + ./tests/ + + + + + + + ./lib/ + + + diff --git a/tests/PhpUnitSfTestHelperTrait.php b/tests/PhpUnitSfTestHelperTrait.php new file mode 100644 index 000000000..49cd0e754 --- /dev/null +++ b/tests/PhpUnitSfTestHelperTrait.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +trait PhpUnitSfTestHelperTrait +{ + public function diag($message): void {} + + /** + * @see self::assertSame + * @deprecated + */ + public function is($actual, $expected, string $message = ''): void + { + $this->assertSame($expected, $actual, $message); + } + + /** + * @see self::assertNotSame + * @deprecated + */ + public function isnt($actual, $expected, string $message = ''): void + { + $this->assertNotSame($expected, $actual, $message); + } + + public function is_deeply($actual, $expected, string $message = ''): void + { + $this->assertSame($expected, $actual, $message); + } + + public function pass($message): void + { + $this->assertSame(true, true, $message); + } + + public function ok($actual, string $message = ''): void + { + $this->assertTrue($actual, $message); + } + + public function isa_ok($actual, $expected, string $message = ''): void + { + if ('array' === $expected) { + $this->assertIsArray($actual, $message); + } elseif (str_starts_with($expected, 'sf')) { + $this->assertInstanceOf($expected, $actual, $message); + } else { + throw new \RuntimeException('unhandled type: '.$expected); + } + } + + public function like($exp, $regex, string $message = '') + { + return $this->ok(preg_match($regex, $exp) > 0, $message); + } + + public function todo() {} +} diff --git a/tests/action/sfComponentTest.php b/tests/action/sfComponentTest.php new file mode 100644 index 000000000..91e695b50 --- /dev/null +++ b/tests/action/sfComponentTest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../fixtures/myComponent.php'; +require_once __DIR__.'/../sfContext.class.php'; +require_once __DIR__.'/../sfNoRouting.class.php'; +require_once __DIR__.'/../sfEventDispatcherTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfComponentTest extends sfEventDispatcherTestCase +{ + private sfContext $context; + + public function setUp(): void + { + $this->context = sfContext::getInstance(array( + 'routing' => 'sfNoRouting', + 'request' => 'sfWebRequest', + )); + + $this->testObject = new myComponent($this->context, 'module', 'action'); + $this->dispatcher = $this->context->getEventDispatcher(); + $this->class = 'component'; + } + + public function testInitialize() + { + $component = new myComponent($this->context, 'module', 'action'); + $this->assertSame($this->context, $component->getContext(), '->initialize() takes a sfContext object as its first argument'); + $component->initialize($this->context, 'module', 'action'); + $this->assertSame($this->context, $component->getContext(), '->initialize() takes a sfContext object as its first argument'); + } + + public function testGetContext() + { + $component = new myComponent($this->context, 'module', 'action'); + + $component->initialize($this->context, 'module', 'action'); + $this->assertSame($this->context, $component->getContext(), '->getContext() returns the current context'); + } + + public function testGetRequest() + { + $component = new myComponent($this->context, 'module', 'action'); + + $component->initialize($this->context, 'module', 'action'); + $this->assertSame($this->context->getRequest(), $component->getRequest(), '->getRequest() returns the current request'); + } + + public function testGetResponse() + { + $component = new myComponent($this->context, 'module', 'action'); + + $component->initialize($this->context, 'module', 'action'); + $this->assertSame($this->context->getResponse(), $component->getResponse(), '->getResponse() returns the current response'); + } + + public function testSetter() + { + $component = new myComponent($this->context, 'module', 'action'); + + $component->foo = array(); + $component->foo[] = 'bar'; + $this->assertSame(array('bar'), $component->foo, '__set() populates component variables'); + } +} diff --git a/tests/addon/sfPagerTest.php b/tests/addon/sfPagerTest.php new file mode 100644 index 000000000..9fbc9f5ac --- /dev/null +++ b/tests/addon/sfPagerTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/myPager.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfPagerTest extends TestCase +{ + /** + * #8021. + */ + public function testRewind() + { + $pager = new myPager('fooClass'); + + $countRuns = 0; + foreach ($pager as $item) { + ++$countRuns; + } + $this->assertSame($pager->count(), $countRuns, 'iterating first time will invoke on all items'); + + $countRuns = 0; + $pager->rewind(); + foreach ($pager as $item) { + ++$countRuns; + } + $this->assertSame($pager->count(), $countRuns, '->rewind will allow reiterating'); + } +} diff --git a/tests/autoload/sfCoreAutoloadTest.php b/tests/autoload/sfCoreAutoloadTest.php new file mode 100644 index 000000000..8408c4fc4 --- /dev/null +++ b/tests/autoload/sfCoreAutoloadTest.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCoreAutoloadTest extends TestCase +{ + public function testClassPath() + { + $autoload = sfCoreAutoload::getInstance(); + $this->assertSame($autoload->getBaseDir().'/action/sfAction.class.php', $autoload->getClassPath('sfaction'), '"sfCoreAutoload" is case-insensitive'); + $this->assertSame($autoload->getBaseDir().'/action/sfAction.class.php', $autoload->getClassPath('sFaCTiOn'), '"sfCoreAutoload" is case-insensitive'); + } +} diff --git a/tests/autoload/sfSimpleAutoloadTest.php b/tests/autoload/sfSimpleAutoloadTest.php new file mode 100644 index 000000000..32ec11755 --- /dev/null +++ b/tests/autoload/sfSimpleAutoloadTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfSimpleAutoloadTest extends TestCase +{ + public function testClassLoad() + { + $autoload = sfSimpleAutoload::getInstance(); + $autoload->addFile(__DIR__.'/../fixtures/myEventDispatcherTest.php'); + $autoload->register(); + + $this->assertSame(true, class_exists('myeventdispatchertest'), '"sfSimpleAutoload" is case insensitive'); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 000000000..b54372e08 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// setup expected test environment (per check_configuration.php) +ini_set('magic_quotes_runtime', 'off'); +ini_set('session.auto_start', 'off'); +ini_set('arg_separator.output', '&'); +ini_set('allow_url_fopen', 'on'); + +require_once __DIR__.'/../vendor/autoload.php'; + +$libDir = realpath(__DIR__.'/../lib'); + +require_once __DIR__.'/../lib/config/sfConfig.class.php'; +sfConfig::set('sf_symfony_lib_dir', $libDir); + +require_once $libDir.'/autoload/sfCoreAutoload.class.php'; +sfCoreAutoload::register(); + +require_once $libDir.'/util/sfToolkit.class.php'; +sfConfig::set('sf_test_cache_dir', sys_get_temp_dir().'/sf_test_project'); + +require_once __DIR__.'/fixtures/symfony/config/ProjectConfiguration.class.php'; + +// remove all test cache +sf_unit_test_shutdown(); + +// create test cache dir +$sf_root_dir = sys_get_temp_dir().'/sf_test_project'; +@mkdir($sf_root_dir, 0777, true); + +register_shutdown_function('sf_unit_test_shutdown'); + +function sf_unit_test_shutdown() +{ + $sf_root_dir = sys_get_temp_dir().'/sf_test_project'; + if (is_dir($sf_root_dir)) { + sfToolkit::clearDirectory($sf_root_dir); + @rmdir($sf_root_dir); + } + + $sessions = glob(sys_get_temp_dir().'/sessions*'); + $tmp_files = glob(sys_get_temp_dir().'/sf*'); + + $files = array_merge(empty($sessions) ? array() : $sessions, empty($tmp_files) ? array() : $tmp_files); + foreach ($files as $file) { + if (is_dir($file)) { + sfToolkit::clearDirectory($file); + @rmdir($file); + } else { + @unlink($file); + } + } +} + +// Helper for cross platform testcases that validate output +function fix_linebreaks($content) +{ + return str_replace(array("\r\n", "\n", "\r"), "\n", $content); +} diff --git a/tests/cache/CacheDriverTestCase.php b/tests/cache/CacheDriverTestCase.php new file mode 100644 index 000000000..8fdf1627d --- /dev/null +++ b/tests/cache/CacheDriverTestCase.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +abstract class CacheDriverTestCase extends TestCase +{ + protected sfCache $cache; + + public function testSetGetHas() + { + $data = 'some random data to store in the cache system... (\'"!#/é$£)'; + + $this->assertTrue($this->cache->set('test', $data, 86400)); + $this->assertSame($data, $this->cache->get('test'), '->get() retrieves data form the cache'); + $this->assertTrue($this->cache->has('test'), '->has() returns true if the cache exists'); + + $this->assertTrue($this->cache->set('test', $data, -10), '->set() takes a lifetime as its third argument'); + $this->assertSame('default', $this->cache->get('test', 'default'), '->get() returns the default value if cache has expired'); + $this->assertSame(false, $this->cache->has('test'), '->has() returns true if the cache exists'); + + $this->assertSame(null, $this->cache->get('foo'), '->get() returns null if the cache does not exist'); + $this->assertSame('default', $this->cache->get('foo', 'default'), '->get() takes a default value as its second argument'); + $this->assertSame(false, $this->cache->has('foo'), '->has() returns false if the cache does not exist'); + + $data = 'another some random data to store in the cache system...'; + $this->assertTrue($this->cache->set('test', $data), '->set() overrides previous data stored in the cache'); + $this->assertSame($data, $this->cache->get('test'), '->get() retrieves the latest data form the cache'); + + $data = false; + $this->assertTrue($this->cache->set('test', $data), '->set() false data are stored in the cache'); + $this->assertTrue($this->cache->has('test'), '->has() returns true if the cache exists with false value'); + $this->assertSame($data, $this->cache->get('test'), '->get() retrieves the latest data form the cache'); + $this->assertSame($data, $this->cache->get('test', 'foo'), '->get() does not return default value if false is stored'); + + $this->cache->clean(); + $this->cache->set('foo', 'foo'); + $this->cache->set('foo:bar', 'bar'); + $this->cache->set('foo:bar:foo:bar:foo', 'foobar'); + $this->assertSame('foo', $this->cache->get('foo'), '->set() accepts a "namespaced" cache key'); + $this->assertSame('bar', $this->cache->get('foo:bar'), '->set() accepts a "namespaced" cache key'); + $this->assertSame('foobar', $this->cache->get('foo:bar:foo:bar:foo'), '->set() accepts a "namespaced" cache key'); + } + + public function testClean() + { + $data = 'some random data to store in the cache system...'; + $this->cache->set('foo', $data, -10); + $this->cache->set('bar', $data, 86400); + + $this->cache->clean(sfCache::OLD); + $this->assertSame(false, $this->cache->has('foo'), '->clean() cleans old cache key if given the sfCache::OLD argument'); + $this->assertTrue($this->cache->has('bar'), '->clean() cleans old cache key if given the sfCache::OLD argument'); + + $this->cache->set('foo', $data, -10); + $this->cache->set('bar', $data, 86400); + + $this->cache->clean(sfCache::ALL); + $this->assertSame(false, $this->cache->has('foo'), '->clean() cleans all cache key if given the sfCache::ALL argument'); + $this->assertSame(false, $this->cache->has('bar'), '->clean() cleans all cache key if given the sfCache::ALL argument'); + + $this->cache->set('foo', $data, -10); + $this->cache->set('bar', $data, 86400); + + $this->cache->clean(); + $this->assertSame(false, $this->cache->has('foo'), '->clean() cleans all cache key if given no argument'); + $this->assertSame(false, $this->cache->has('bar'), '->clean() cleans all cache key if given no argument'); + + $this->cache->clean(); + $this->cache->setOption('automatic_cleaning_factor', 1); + $this->cache->set('foo', $data); + $this->cache->set('foo', $data); + $this->cache->set('foo', $data); + $this->cache->setOption('automatic_cleaning_factor', 1000); + } + + public function testRemove() + { + $data = 'some random data to store in the cache system...'; + $this->cache->clean(); + $this->cache->set('foo', $data); + $this->cache->set('bar', $data); + + $this->cache->remove('foo'); + $this->assertSame(false, $this->cache->has('foo'), '->remove() takes a cache key as its first argument'); + $this->assertSame(null, $this->cache->get('foo'), '->remove() takes a cache key as its first argument'); + $this->assertTrue($this->cache->has('bar'), '->remove() takes a cache key as its first argument'); + } + + /** + * @dataProvider removePatternDataProvider + */ + public function testRemovePattern(string $pattern, array $results) + { + $this->cache->clean(); + + $this->cache->set('foo:bar:foo', 'foo'); + $this->cache->set('bar:bar:foo', 'foo'); + $this->cache->set('foo:bar:foo1', 'foo'); + $this->cache->set('foo:bar:foo:bar', 'foo'); + + $this->cache->removePattern($pattern); + + $this->assertSame($results[0], $this->cache->has('foo:bar:foo'), '->removePattern() takes a pattern as its first argument'); + $this->assertSame($results[1], $this->cache->has('bar:bar:foo'), '->removePattern() takes a pattern as its first argument'); + $this->assertSame($results[2], $this->cache->has('foo:bar:foo1'), '->removePattern() takes a pattern as its first argument'); + $this->assertSame($results[3], $this->cache->has('foo:bar:foo:bar'), '->removePattern() takes a pattern as its first argument'); + } + + public function removePatternDataProvider(): Generator + { + yield array('*:bar:foo', array(false, false, true, true)); + yield array('foo:bar:*', array(false, true, false, true)); + yield array('foo:**:foo', array(false, true, true, true)); + yield array('foo:bar:**', array(false, true, false, false)); + yield array('**:bar', array(true, true, true, false)); + yield array('**', array(false, false, false, false)); + } + + public function testGetTimeout() + { + foreach (array(86400, 10) as $lifetime) { + $this->cache->set('foo', 'bar', $lifetime); + + $delta = $this->cache->getTimeout('foo') - time(); + $this->assertTrue($delta >= $lifetime - 1 && $delta <= $lifetime, '->getTimeout() returns the timeout time for a given cache key'); + } + + $this->cache->set('bar', 'foo', -10); + $this->assertSame($this->cache->getTimeout('bar'), 0, '->getTimeout() returns the timeout time for a given cache key'); + + foreach (array(86400, 10) as $lifetime) { + $this->cache->setOption('lifetime', $lifetime); + $this->cache->set('foo', 'bar'); + + $delta = $this->cache->getTimeout('foo') - time(); + $this->assertTrue($delta >= $lifetime - 1 && $delta <= $lifetime, '->getTimeout() returns the timeout time for a given cache key'); + } + + $this->assertSame(0, $this->cache->getTimeout('nonexistantkey'), '->getTimeout() returns 0 if the cache key does not exist'); + } + + public function testGetLastModified() + { + foreach (array(86400, 10) as $lifetime) { + $this->cache->set('bar', 'foo', $lifetime); + $now = time(); + $lastModified = $this->cache->getLastModified('bar'); + $this->assertTrue($lastModified >= time() - 1 && $lastModified <= time(), '->getLastModified() returns the last modified time for a given cache key'); + } + + $this->cache->set('bar', 'foo', -10); + $this->assertSame(0, $this->cache->getLastModified('bar'), '->getLastModified() returns the last modified time for a given cache key'); + + foreach (array(86400, 10) as $lifetime) { + $this->cache->setOption('lifetime', $lifetime); + $this->cache->set('bar', 'foo'); + + $now = time(); + $lastModified = $this->cache->getLastModified('bar'); + $this->assertSame($lastModified >= time() - 1 && $lastModified <= time(), true, '->getLastModified() returns the last modified time for a given cache key'); + } + + $this->assertSame(0, $this->cache->getLastModified('nonexistantkey'), '->getLastModified() returns 0 if the cache key does not exist'); + } + + public function testGetMany() + { + $this->cache->clean(); + + $this->cache->set('bar', 'foo'); + $this->cache->set('foo', 'bar'); + + $result = $this->cache->getMany(array('foo', 'bar')); + asort($result); + $this->assertSame(array('foo', 'bar'), array_keys($result), '->getMany() gets many keys in one call'); + $this->assertSame('bar', $result['foo'], '->getMany() gets many keys in one call'); + $this->assertSame('foo', $result['bar'], '->getMany() gets many keys in one call'); + + $this->cache->clean(); + } +} diff --git a/tests/cache/sfAPCCacheTest.php b/tests/cache/sfAPCCacheTest.php new file mode 100644 index 000000000..96a7e235e --- /dev/null +++ b/tests/cache/sfAPCCacheTest.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/CacheDriverTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfAPCCacheTest extends CacheDriverTestCase +{ + public function setUp(): void + { + $this->cache = new sfAPCCache(); + $this->cache->initialize(); + } +} diff --git a/tests/cache/sfCacheTest.php b/tests/cache/sfCacheTest.php new file mode 100644 index 000000000..3279cec9a --- /dev/null +++ b/tests/cache/sfCacheTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/myCache.php'; +require_once __DIR__.'/../fixtures/fakeCache.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfCacheTest extends TestCase +{ + public function testInitialize() + { + $cache = new myCache(); + $cache->initialize(array('foo' => 'bar')); + $this->assertSame('bar', $cache->getOption('foo'), '->initialize() takes an array of options as its first argument'); + } +} diff --git a/tests/cache/sfFileCacheTest.php b/tests/cache/sfFileCacheTest.php new file mode 100644 index 000000000..f4d03166a --- /dev/null +++ b/tests/cache/sfFileCacheTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/CacheDriverTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfFileCacheTest extends CacheDriverTestCase +{ + public function setUp(): void + { + sfConfig::set('sf_logging_enabled', false); + + $temp = tempnam(sys_get_temp_dir(), 'file_cache_temp_'); + unlink($temp); + mkdir($temp); + + $this->cache = new sfFileCache(array( + 'cache_dir' => $temp, + )); + } + + protected function tearDown(): void + { + $cacheDir = $this->cache->getOption('cache_dir'); + + sfToolkit::clearDirectory($cacheDir); + rmdir($cacheDir); + } + + public function testCacheDirOptionMissing() + { + $this->expectException(\sfInitializationException::class); + + new sfFileCache(); + } +} diff --git a/tests/cache/sfFunctionCacheTest.php b/tests/cache/sfFunctionCacheTest.php new file mode 100644 index 000000000..12014ebb6 --- /dev/null +++ b/tests/cache/sfFunctionCacheTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/sfSimpleCache.php'; +require_once __DIR__.'/../fixtures/testFunctionCache.php'; +require_once __DIR__.'/../fixtures/testRandomFunctionCache.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfFunctionCacheTest extends TestCase +{ + public function testFunction() + { + $cache = new sfSimpleCache(); + $functionCache = new sfFunctionCache($cache); + + $result = testFunctionCache(1, 2); + + $this->assertSame('121', $result); + $this->assertSame('122', $functionCache->call('testFunctionCache', array(1, 2)), $result, '->call() works with functions'); + $this->assertSame('122', $functionCache->call('testFunctionCache', array(1, 2)), $result, '->call() stores the function call in cache'); + } + + public function testClassStaticMethod() + { + $cache = new sfSimpleCache(); + $functionCache = new sfFunctionCache($cache); + + $result = testFunctionCache::testStatic(1, 2); + + $this->assertSame(1, testFunctionCache::$count); + $this->assertSame($result, $functionCache->call(array(testFunctionCache::class, 'testStatic'), array(1, 2)), '->call() works with static method calls'); + $this->assertSame(2, testFunctionCache::$count); + $this->assertSame($result, $functionCache->call(array(testFunctionCache::class, 'testStatic'), array(1, 2)), '->call() stores the function call in cache'); + $this->assertSame(2, testFunctionCache::$count); + } + + public function testClassNonStaticMethod() + { + $cache = new sfSimpleCache(); + $functionCache = new sfFunctionCache($cache); + + testFunctionCache::$count = 0; + + $object = new testFunctionCache(); + $result = $object->test(1, 2); + + $this->assertSame(1, testFunctionCache::$count); + $this->assertSame($result, $functionCache->call(array($object, 'test'), array(1, 2)), '->call() works with object methods'); + $this->assertSame(2, testFunctionCache::$count); + $this->assertSame($result, $functionCache->call(array($object, 'test'), array(1, 2)), '->call() stores the function call in cache'); + $this->assertSame(2, testFunctionCache::$count); + } +} diff --git a/tests/cache/sfMemcacheCacheTest.php b/tests/cache/sfMemcacheCacheTest.php new file mode 100644 index 000000000..eb4dbaa43 --- /dev/null +++ b/tests/cache/sfMemcacheCacheTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/CacheDriverTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfMemcacheCacheTest extends CacheDriverTestCase +{ + public function setUp(): void + { + $memcachedHost = getenv('MEMCACHED_HOST'); + if (!$memcachedHost) { + $memcachedHost = null; + } + + $this->cache = new sfMemcacheCache(array( + 'storeCacheInfo' => true, + 'host' => $memcachedHost, + )); + } + + public function testRemove() + { + parent::testRemove(); + + $backend = $this->cache->getBackend(); + $prefix = $this->cache->getOption('prefix'); + $this->cache->clean(); + $this->cache->set('test_1', 'abc'); + $this->cache->set('test_2', 'abc'); + $this->cache->remove('test_1'); + + $cacheInfo = $backend->get($prefix.'_metadata'); + + $this->assertTrue(is_array($cacheInfo), 'Cache info is an array'); + $this->assertSame(1, count($cacheInfo), 'Cache info contains 1 element'); + $this->assertTrue(!in_array($prefix.'test_1', $cacheInfo), 'Cache info no longer contains the removed key'); + $this->assertTrue(in_array($prefix.'test_2', $cacheInfo), 'Cache info still contains the key that was not removed'); + } + + // ->removePattern() test for ticket #6220 + public function testRemovePattern6220() + { + $backend = $this->cache->getBackend(); + $prefix = $this->cache->getOption('prefix'); + $this->cache->clean(); + $this->cache->set('test_1', 'abc'); + $this->cache->set('test_2', 'abc'); + $this->cache->set('test3', 'abc'); + $this->cache->removePattern('test_*'); + + $cacheInfo = $backend->get($prefix.'_metadata'); + $this->assertTrue(is_array($cacheInfo), 'Cache info is an array'); + $this->assertSame(1, count($cacheInfo), 'Cache info contains 1 element'); + $this->assertTrue(!in_array($prefix.'test_1', $cacheInfo), 'Cache info no longer contains the key that matches the pattern (first key)'); + $this->assertTrue(!in_array($prefix.'test_2', $cacheInfo), 'Cache info no longer contains the key that matches the pattern (second key)'); + $this->assertTrue(in_array($prefix.'test3', $cacheInfo), 'Cache info still contains the key that did not match the pattern (third key)'); + } +} diff --git a/tests/cache/sfNoCacheTest.php b/tests/cache/sfNoCacheTest.php new file mode 100644 index 000000000..0857b5d15 --- /dev/null +++ b/tests/cache/sfNoCacheTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfNoCacheTest extends TestCase +{ + public function testGet() + { + $cache = new sfNoCache(); + $this->assertSame(null, $cache->get('foo'), '->get() always returns "null"'); + } + + public function testSet() + { + $cache = new sfNoCache(); + $this->assertTrue($cache->set('foo', 'bar'), '->set() always returns "true"'); + } + + public function testHas() + { + $cache = new sfNoCache(); + $cache->set('foo', 'bar'); + $this->assertSame(false, $cache->has('foo'), '->has() always returns "false"'); + } + + public function testRemove() + { + $cache = new sfNoCache(); + $this->assertTrue($cache->remove('foo'), '->remove() always returns "true"'); + } + + public function testRemovePattern() + { + $cache = new sfNoCache(); + $this->assertTrue($cache->removePattern('**'), '->removePattern() always returns "true"'); + } + + public function testClean() + { + $cache = new sfNoCache(); + $this->assertTrue($cache->clean(), '->clean() always returns "true"'); + } + + public function testGetLastModified() + { + $cache = new sfNoCache(); + $this->assertSame(0, $cache->getLastModified('foo'), '->getLastModified() always returns "0"'); + } + + public function testGetTimeout() + { + $cache = new sfNoCache(); + $this->assertSame(0, $cache->getTimeout('foo'), '->getTimeout() always returns "0"'); + } +} diff --git a/tests/cache/sfSQLiteCacheFileTest.php b/tests/cache/sfSQLiteCacheFileTest.php new file mode 100644 index 000000000..47f150c76 --- /dev/null +++ b/tests/cache/sfSQLiteCacheFileTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/CacheDriverTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfSQLiteCacheFileTest extends CacheDriverTestCase +{ + public function setUp(): void + { + $database = tempnam(sys_get_temp_dir(), 'file_cache_temp_'); + unlink($database); + $this->cache = new sfSQLiteCache(array('database' => $database)); + } + + protected function tearDown(): void + { + $database = $this->cache->getOption('database'); + + if (is_file($database)) { + unlink($database); + } + } +} diff --git a/tests/cache/sfSQLiteCacheMemoryTest.php b/tests/cache/sfSQLiteCacheMemoryTest.php new file mode 100644 index 000000000..9cd0d0839 --- /dev/null +++ b/tests/cache/sfSQLiteCacheMemoryTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/CacheDriverTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfSQLiteCacheMemoryTest extends CacheDriverTestCase +{ + public function setUp(): void + { + $this->cache = new sfSQLiteCache(array('database' => ':memory:')); + } +} diff --git a/tests/command/sfCommandArgumentSetTest.php b/tests/command/sfCommandArgumentSetTest.php new file mode 100644 index 000000000..203f34867 --- /dev/null +++ b/tests/command/sfCommandArgumentSetTest.php @@ -0,0 +1,157 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCommandArgumentSetTest extends TestCase +{ + public function testConstruct() + { + $argumentSet = new sfCommandArgumentSet(); + + $this->assertSame(array(), $argumentSet->getArguments(), '__construct() creates a new sfCommandArgumentSet object'); + + $foo = new sfCommandArgument('foo'); + $bar = new sfCommandArgument('bar'); + $argumentSet = new sfCommandArgumentSet(array($foo, $bar)); + $this->assertSame(array('foo' => $foo, 'bar' => $bar), $argumentSet->getArguments(), '__construct() takes an array of sfCommandArgument objects as its first argument'); + } + + public function testSetArguments() + { + $foo = new sfCommandArgument('foo'); + $bar = new sfCommandArgument('bar'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->setArguments(array($foo)); + $this->assertSame(array('foo' => $foo), $argumentSet->getArguments(), '->setArguments() sets the array of sfCommandArgument objects'); + + $argumentSet->setArguments(array($bar)); + $this->assertSame(array('bar' => $bar), $argumentSet->getArguments(), '->setArguments() clears all sfCommandArgument objects'); + } + + public function testAddArgument() + { + $foo = new sfCommandArgument('foo'); + $bar = new sfCommandArgument('bar'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array($foo)); + $this->assertSame(array('foo' => $foo), $argumentSet->getArguments(), '->addArguments() adds an array of sfCommandArgument objects'); + + $argumentSet->addArguments(array($bar)); + $this->assertSame(array('foo' => $foo, 'bar' => $bar), $argumentSet->getArguments(), '->addArguments() does not clear existing sfCommandArgument objects'); + } + + public function testConflictNames() + { + $foo = new sfCommandArgument('foo'); + $foo2 = new sfCommandArgument('foo'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array($foo)); + + $this->expectException(sfCommandException::class); + $argumentSet->addArgument($foo2); + } + + public function testArgumentAfterArray() + { + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArgument(new sfCommandArgument('fooarray', sfCommandArgument::IS_ARRAY)); + + $this->expectException(sfCommandException::class); + $argumentSet->addArgument(new sfCommandArgument('anotherbar')); + } + + public function testRequiredAfterOptional() + { + $foo = new sfCommandArgument('foo'); + $foo2 = new sfCommandArgument('foo2', sfCommandArgument::REQUIRED); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArgument($foo); + + $this->expectException(sfCommandException::class); + $argumentSet->addArgument($foo2); + } + + public function testGetArgument() + { + $foo = new sfCommandArgument('foo'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array($foo)); + + $this->assertSame($foo, $argumentSet->getArgument('foo'), '->getArgument() returns a sfCommandArgument by its name'); + + $this->expectException(sfCommandException::class); + $argumentSet->getArgument('bar'); + } + + public function testHasArgument() + { + $foo = new sfCommandArgument('foo'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array($foo)); + $this->assertSame($argumentSet->hasArgument('foo'), true, '->hasArgument() returns true if a sfCommandArgument exists for the given name'); + $this->assertSame($argumentSet->hasArgument('bar'), false, '->hasArgument() returns false if a sfCommandArgument exists for the given name'); + } + + public function testGetArgumentRequiredCount() + { + $foo2 = new sfCommandArgument('foo2', sfCommandArgument::REQUIRED); + $foo = new sfCommandArgument('foo'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArgument($foo2); + $this->assertSame($argumentSet->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + + $argumentSet->addArgument($foo); + $this->assertSame($argumentSet->getArgumentRequiredCount(), 1, '->getArgumentRequiredCount() returns the number of required arguments'); + } + + public function testGetArgumentCount() + { + $foo2 = new sfCommandArgument('foo2', sfCommandArgument::REQUIRED); + $foo = new sfCommandArgument('foo'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArgument($foo2); + $this->assertSame($argumentSet->getArgumentCount(), 1, '->getArgumentCount() returns the number of arguments'); + + $argumentSet->addArgument($foo); + $this->assertSame($argumentSet->getArgumentCount(), 2, '->getArgumentCount() returns the number of arguments'); + } + + public function testGetDefaults() + { + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array( + new sfCommandArgument('foo1', sfCommandArgument::OPTIONAL), + new sfCommandArgument('foo2', sfCommandArgument::OPTIONAL, '', 'default'), + new sfCommandArgument('foo3', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY), + // new sfCommandArgument('foo4', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertSame($argumentSet->getDefaults(), array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), '->getDefaults() return the default values for each argument'); + + $argumentSet = new sfCommandArgumentSet(); + $argumentSet->addArguments(array( + new sfCommandArgument('foo4', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertSame($argumentSet->getDefaults(), array('foo4' => array(1, 2)), '->getDefaults() return the default values for each argument'); + } +} diff --git a/tests/command/sfCommandArgumentTest.php b/tests/command/sfCommandArgumentTest.php new file mode 100644 index 000000000..57c4da209 --- /dev/null +++ b/tests/command/sfCommandArgumentTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCommandArgumentTest extends TestCase +{ + public function testConstruct() + { + $argument = new sfCommandArgument('foo'); + $this->assertSame('foo', $argument->getName(), '__construct() takes a name as its first argument'); + + // mode argument + $argument = new sfCommandArgument('foo'); + $this->assertSame(false, $argument->isRequired(), '__construct() gives a "sfCommandArgument::OPTIONAL" mode by default'); + + $argument = new sfCommandArgument('foo', null); + $this->assertSame(false, $argument->isRequired(), '__construct() can take "sfCommandArgument::OPTIONAL" as its mode'); + + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL); + $this->assertSame(false, $argument->isRequired(), '__construct() can take "sfCommandArgument::PARAMETER_OPTIONAL" as its mode'); + + $argument = new sfCommandArgument('foo', sfCommandArgument::REQUIRED); + $this->assertSame(true, $argument->isRequired(), '__construct() can take "sfCommandArgument::PARAMETER_REQUIRED" as its mode'); + + $this->expectException(sfCommandException::class); + $argument = new sfCommandArgument('foo', 'ANOTHER_ONE'); + } + + public function testIsArray() + { + $argument = new sfCommandArgument('foo', sfCommandArgument::IS_ARRAY); + $this->assertSame(true, $argument->isArray(), '->isArray() returns true if the argument can be an array'); + + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY); + $this->assertSame(true, $argument->isArray(), '->isArray() returns true if the argument can be an array'); + + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL); + $this->assertSame(true, !$argument->isArray(), '->isArray() returns false if the argument can not be an array'); + } + + public function testGetHelp() + { + $argument = new sfCommandArgument('foo', null, 'Some help'); + $this->assertSame('Some help', $argument->getHelp(), '->getHelp() return the message help'); + } + + public function testGetDefault() + { + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL, '', 'default'); + $this->assertSame('default', $argument->getDefault(), '->getDefault() return the default value'); + } + + public function testSetDefault() + { + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL, '', 'default'); + $argument->setDefault(null); + $this->assertSame(true, null === $argument->getDefault(), '->setDefault() can reset the default value by passing null'); + + $argument->setDefault('another'); + $this->assertSame($argument->getDefault(), 'another', '->setDefault() changes the default value'); + + $argument = new sfCommandArgument('foo', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY); + $argument->setDefault(array(1, 2)); + $this->assertSame(array(1, 2), $argument->getDefault(), '->setDefault() changes the default value'); + } + + public function testDefaultValueForRequired() + { + $this->expectException(sfCommandException::class); + + $argument = new sfCommandArgument('foo', sfCommandArgument::REQUIRED); + $argument->setDefault('default'); + } + + public function testNonArrayForArrayArgument() + { + $this->expectException(sfCommandException::class); + + $argument = new sfCommandArgument('foo', sfCommandArgument::IS_ARRAY); + $argument->setDefault('default'); + } +} diff --git a/tests/command/sfCommandManagerTest.php b/tests/command/sfCommandManagerTest.php new file mode 100644 index 000000000..c3e65ea24 --- /dev/null +++ b/tests/command/sfCommandManagerTest.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCommandManagerTest extends TestCase +{ + public function testConstruct() + { + $argumentSet = new sfCommandArgumentSet(); + $optionSet = new sfCommandOptionSet(); + + $manager = new sfCommandManager(); + $this->assertInstanceOf(sfCommandArgumentSet::class, $manager->getArgumentSet(), '__construct() creates a new sfCommandArgumentsSet if none given'); + $this->assertInstanceOf(sfCommandOptionSet::class, $manager->getOptionSet(), '__construct() creates a new sfCommandOptionSet if none given'); + + $manager = new sfCommandManager($argumentSet); + $this->assertSame($manager->getArgumentSet(), $argumentSet, '__construct() takes a sfCommandArgumentSet as its first argument'); + $this->assertInstanceOf(sfCommandOptionSet::class, $manager->getOptionSet(), '__construct() takes a sfCommandArgumentSet as its first argument'); + + $manager = new sfCommandManager($argumentSet, $optionSet); + $this->assertSame($optionSet, $manager->getOptionSet(), '__construct() can take a sfCommandOptionSet as its second argument'); + } + + public function testSetArgumentSet() + { + $manager = new sfCommandManager(new sfCommandArgumentSet()); + $argumentSet = new sfCommandArgumentSet(); + $manager->setArgumentSet($argumentSet); + $this->assertSame($argumentSet, $manager->getArgumentSet(), '->setArgumentSet() sets the manager argument set'); + } + + public function testSetOptionSet() + { + $manager = new sfCommandManager(new sfCommandArgumentSet()); + $optionSet = new sfCommandOptionSet(); + $manager->setOptionSet($optionSet); + $this->assertSame($manager->getOptionSet(), $optionSet, '->setOptionSet() sets the manager option set'); + } + + /** @dataProvider processDataProvider */ + public function testProcess(sfCommandManager $manager) + { + $options = array( + 'foo1' => true, + 'foo2' => true, + 'foo3' => 'default3', + 'foo4' => 'foo4', + 'foo5' => 'foo5', + 'foo6' => 'foo6 foo6', + 'foo7' => 'foo7', + 'foo8' => array('foo', 'bar'), + 'foo9' => 'default9', + 'foo10' => 'foo10', + 'foo11' => 'foo11', + ); + $arguments = array( + 'foo1' => 'foo1', + 'foo2' => array('foo2', 'foo3', 'foo4'), + ); + + $this->assertSame(true, $manager->isValid(), '->process() processes CLI options'); + $this->assertSame($manager->getOptionValues(), $options, '->process() processes CLI options'); + $this->assertSame($manager->getArgumentValues(), $arguments, '->process() processes CLI options'); + + foreach ($options as $name => $value) { + $this->assertSame($value, $manager->getOptionValue($name), '->getOptionValue() returns the value for the given option name'); + } + + foreach ($arguments as $name => $value) { + $this->assertSame($value, $manager->getArgumentValue($name), '->getArgumentValue() returns the value for the given argument name'); + } + } + + /** @dataProvider processDataProvider */ + public function testNonExistantOption(sfCommandManager $manager) + { + $this->expectException(sfCommandException::class); + $manager->getOptionValue('nonexistant'); + } + + /** @dataProvider processDataProvider */ + public function testNonExistantArgument(sfCommandManager $manager) + { + $this->expectException(sfCommandException::class); + $manager->getArgumentValue('nonexistant'); + } + + public function processDataProvider() + { + $argumentSet = new sfCommandArgumentSet(array( + new sfCommandArgument('foo1', sfCommandArgument::REQUIRED), + new sfCommandArgument('foo2', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY), + )); + $optionSet = new sfCommandOptionSet(array( + new sfCommandOption('foo1', null, sfCommandOption::PARAMETER_NONE), + new sfCommandOption('foo2', 'f', sfCommandOption::PARAMETER_NONE), + new sfCommandOption('foo3', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default3'), + new sfCommandOption('foo4', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default4'), + new sfCommandOption('foo5', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default5'), + new sfCommandOption('foo6', 'r', sfCommandOption::PARAMETER_REQUIRED, '', 'default5'), + new sfCommandOption('foo7', 't', sfCommandOption::PARAMETER_REQUIRED, '', 'default7'), + new sfCommandOption('foo8', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY), + new sfCommandOption('foo9', 's', sfCommandOption::PARAMETER_OPTIONAL, '', 'default9'), + new sfCommandOption('foo10', 'u', sfCommandOption::PARAMETER_OPTIONAL, '', 'default10'), + new sfCommandOption('foo11', 'v', sfCommandOption::PARAMETER_OPTIONAL, '', 'default11'), + )); + $manager = new sfCommandManager($argumentSet, $optionSet); + $manager->process('--foo1 -f --foo3 --foo4="foo4" --foo5=foo5 -r"foo6 foo6" -t foo7 --foo8="foo" --foo8=bar -s -u foo10 -vfoo11 foo1 foo2 foo3 foo4'); + + yield array($manager); + } + + public function testIsValid() + { + $argumentSet = new sfCommandArgumentSet(); + $manager = new sfCommandManager($argumentSet); + $manager->process('foo'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $argumentSet = new sfCommandArgumentSet(array(new sfCommandArgument('foo', sfCommandArgument::REQUIRED))); + $manager = new sfCommandManager($argumentSet); + $manager->process(''); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $optionSet = new sfCommandOptionSet(array(new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED))); + $manager = new sfCommandManager(null, $optionSet); + $manager->process('--foo'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $optionSet = new sfCommandOptionSet(array(new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_REQUIRED))); + $manager = new sfCommandManager(null, $optionSet); + $manager->process('-f'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $optionSet = new sfCommandOptionSet(array(new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE))); + $manager = new sfCommandManager(null, $optionSet); + $manager->process('--foo="bar"'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $manager = new sfCommandManager(); + $manager->process('--bar'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $manager = new sfCommandManager(); + $manager->process('-b'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + + $manager = new sfCommandManager(); + $manager->process('--bar="foo"'); + $this->assertSame(true, !$manager->isValid(), '->isValid() returns false if the options are not valid'); + $this->assertSame(count($manager->getErrors()), 1, '->getErrors() returns an array of errors'); + } +} diff --git a/tests/command/sfCommandOptionSetTest.php b/tests/command/sfCommandOptionSetTest.php new file mode 100644 index 000000000..a01624eb1 --- /dev/null +++ b/tests/command/sfCommandOptionSetTest.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCommandOptionSetTest extends TestCase +{ + public function testConstruct() + { + $foo = new sfCommandOption('foo', 'f'); + $bar = new sfCommandOption('bar', 'b'); + + $optionSet = new sfCommandOptionSet(); + $this->assertSame(array(), $optionSet->getOptions(), '__construct() creates a new sfCommandOptionSet object'); + + $optionSet = new sfCommandOptionSet(array($foo, $bar)); + $this->assertSame(array('foo' => $foo, 'bar' => $bar), $optionSet->getOptions(), '__construct() takes an array of sfCommandOption objects as its first argument'); + } + + public function testSetOptions() + { + $foo = new sfCommandOption('foo', 'f'); + $bar = new sfCommandOption('bar', 'b'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->setOptions(array($foo)); + $this->assertSame(array('foo' => $foo), $optionSet->getOptions(), '->setOptions() sets the array of sfCommandOption objects'); + + $optionSet->setOptions(array($bar)); + $this->assertSame(array('bar' => $bar), $optionSet->getOptions(), '->setOptions() clears all sfCommandOption objects'); + + $this->expectException(sfCommandException::class); + $optionSet->getOptionForShortcut('f'); + } + + public function testAddOptions() + { + $foo = new sfCommandOption('foo', 'f'); + $bar = new sfCommandOption('bar', 'b'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array($foo)); + $this->assertSame($optionSet->getOptions(), array('foo' => $foo), '->addOptions() adds an array of sfCommandOption objects'); + + $optionSet->addOptions(array($bar)); + $this->assertSame($optionSet->getOptions(), array('foo' => $foo, 'bar' => $bar), '->addOptions() does not clear existing sfCommandOption objects'); + } + + public function testAddOption() + { + $foo = new sfCommandOption('foo', 'f'); + $bar = new sfCommandOption('bar', 'b'); + $foo2 = new sfCommandOption('foo', 'p'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOption($foo); + $this->assertSame($optionSet->getOptions(), array('foo' => $foo), '->addOption() adds a sfCommandOption object'); + $optionSet->addOption($bar); + $this->assertSame($optionSet->getOptions(), array('foo' => $foo, 'bar' => $bar), '->addOption() adds a sfCommandOption object'); + + $this->expectException(sfCommandException::class); + $optionSet->addOption($foo2); + } + + public function testAddOptionWithShortcutAlreadyExists() + { + $foo = new sfCommandOption('foo', 'f'); + $foo1 = new sfCommandOption('fooBis', 'f'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOption($foo); + + $this->expectException(sfCommandException::class); + $optionSet->addOption($foo1); + } + + public function testGetOption() + { + $foo = new sfCommandOption('foo', 'f'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array($foo)); + $this->assertSame($optionSet->getOption('foo'), $foo, '->getOption() returns a sfCommandOption by its name'); + + $this->expectException(sfCommandException::class); + $optionSet->getOption('bar'); + } + + public function testHasOption() + { + $foo = new sfCommandOption('foo', 'f'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array($foo)); + $this->assertSame($optionSet->hasOption('foo'), true, '->hasOption() returns true if a sfCommandOption exists for the given name'); + $this->assertSame($optionSet->hasOption('bar'), false, '->hasOption() returns false if a sfCommandOption exists for the given name'); + } + + public function testHasShortcut() + { + $foo = new sfCommandOption('foo', 'f'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array($foo)); + $this->assertSame($optionSet->hasShortcut('f'), true, '->hasShortcut() returns true if a sfCommandOption exists for the given shortcut'); + $this->assertSame($optionSet->hasShortcut('b'), false, '->hasShortcut() returns false if a sfCommandOption exists for the given shortcut'); + } + + public function testGetOptionForShortcut() + { + $foo = new sfCommandOption('foo', 'f'); + + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array($foo)); + $this->assertSame($optionSet->getOptionForShortcut('f'), $foo, '->getOptionForShortcut() returns a sfCommandOption by its shortcut'); + + $this->expectException(sfCommandException::class); + $optionSet->getOptionForShortcut('l'); + } + + public function testGetDefaults() + { + $optionSet = new sfCommandOptionSet(); + $optionSet->addOptions(array( + new sfCommandOption('foo1', null, sfCommandOption::PARAMETER_NONE), + new sfCommandOption('foo2', null, sfCommandOption::PARAMETER_REQUIRED), + new sfCommandOption('foo3', null, sfCommandOption::PARAMETER_REQUIRED, '', 'default'), + new sfCommandOption('foo4', null, sfCommandOption::PARAMETER_OPTIONAL), + new sfCommandOption('foo5', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default'), + new sfCommandOption('foo6', null, sfCommandOption::PARAMETER_OPTIONAL | sfCommandOption::IS_ARRAY), + new sfCommandOption('foo7', null, sfCommandOption::PARAMETER_OPTIONAL | sfCommandOption::IS_ARRAY, '', array(1, 2)), + )); + + $defaults = array( + 'foo1' => false, // TODO that was null + 'foo2' => null, + 'foo3' => 'default', + 'foo4' => null, + 'foo5' => 'default', + 'foo6' => array(), + 'foo7' => array(1, 2), + ); + + $this->assertSame($defaults, $optionSet->getDefaults(), '->getDefaults() returns the default values for all options'); + } +} diff --git a/tests/command/sfCommandOptionTest.php b/tests/command/sfCommandOptionTest.php new file mode 100644 index 000000000..5ecb2acfe --- /dev/null +++ b/tests/command/sfCommandOptionTest.php @@ -0,0 +1,146 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCommandOptionTest extends TestCase +{ + public function testConstruct() + { + $option = new sfCommandOption('foo'); + $this->assertSame($option->getName(), 'foo', '__construct() takes a name as its first argument'); + + $option = new sfCommandOption('--foo'); + $this->assertSame($option->getName(), 'foo', '__construct() removes the leading -- of the option name'); + + // shortcut argument + $option = new sfCommandOption('foo', 'f'); + $this->assertSame($option->getShortcut(), 'f', '__construct() can take a shortcut as its second argument'); + + $option = new sfCommandOption('foo', '-f'); + $this->assertSame($option->getShortcut(), 'f', '__construct() removes the leading - of the shortcut'); + + // mode argument + $option = new sfCommandOption('foo', 'f'); + $this->assertSame($option->acceptParameter(), false, '__construct() gives a "sfCommandOption::PARAMETER_NONE" mode by default'); + $this->assertSame($option->isParameterRequired(), false, '__construct() gives a "sfCommandOption::PARAMETER_NONE" mode by default'); + $this->assertSame($option->isParameterOptional(), false, '__construct() gives a "sfCommandOption::PARAMETER_NONE" mode by default'); + + $option = new sfCommandOption('foo', 'f', null); + $this->assertSame($option->acceptParameter(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + $this->assertSame($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + $this->assertSame($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + + $option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_NONE); + $this->assertSame($option->acceptParameter(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + $this->assertSame($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + $this->assertSame($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode'); + + $option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_REQUIRED); + $this->assertSame($option->acceptParameter(), true, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode'); + $this->assertSame($option->isParameterRequired(), true, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode'); + $this->assertSame($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode'); + + $option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_OPTIONAL); + $this->assertSame($option->acceptParameter(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode'); + $this->assertSame($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode'); + $this->assertSame($option->isParameterOptional(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode'); + } + + public function testInvalidMode() + { + $this->expectException(sfCommandException::class); + + $option = new sfCommandOption('foo', 'f', 'ANOTHER_ONE'); + } + + public function testIsArray() + { + $option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY); + $this->assertSame(true, $option->isArray(), '->isArray() returns true if the option can be an array'); + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE | sfCommandOption::IS_ARRAY); + $this->assertSame(true, $option->isArray(), '->isArray() returns true if the option can be an array'); + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE); + $this->assertSame(true, !$option->isArray(), '->isArray() returns false if the option can not be an array'); + } + + public function testGetHelp() + { + $option = new sfCommandOption('foo', 'f', null, 'Some help'); + $this->assertSame($option->getHelp(), 'Some help', '->getHelp() returns the help message'); + } + + public function testAcceptParameter() + { + $option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY); + $this->assertSame(true, $option->acceptParameter()); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_OPTIONAL); + $this->assertSame(true, $option->acceptParameter()); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED); + $this->assertSame(true, $option->acceptParameter()); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE); + $this->assertSame(false, $option->acceptParameter()); + } + + public function testGetDefault() + { + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default'); + $this->assertSame('default', $option->getDefault(), '->getDefault() returns the default value'); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED, '', 'default'); + $this->assertSame('default', $option->getDefault(), '->getDefault() returns the default value'); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED); + $this->assertSame(true, null === $option->getDefault(), '->getDefault() returns null if no default value is configured'); + + $option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY); + $this->assertSame(array(), $option->getDefault(), '->getDefault() returns an empty array if option is an array'); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE); + $this->assertSame(true, false === $option->getDefault(), '->getDefault() returns false if the option does not take a parameter'); + } + + public function testSetDefault() + { + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED, '', 'default'); + $option->setDefault(null); + $this->assertSame(true, null === $option->getDefault(), '->setDefault() can reset the default value by passing null'); + $option->setDefault('another'); + $this->assertSame($option->getDefault(), 'another', '->setDefault() changes the default value'); + + $option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY); + $option->setDefault(array(1, 2)); + $this->assertSame($option->getDefault(), array(1, 2), '->setDefault() changes the default value'); + } + + public function testDefaultValueForNonParameter() + { + $this->expectException(sfCommandException::class); + + $option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_NONE); + $option->setDefault('default'); + } + + public function testNonArrayDefaultValueForArrayOption() + { + $this->expectException(sfCommandException::class); + + $option = new sfCommandOption('foo', 'f', sfCommandOption::IS_ARRAY); + $option->setDefault('default'); + } +} diff --git a/tests/config/sfCompileConfigHandlerTest.php b/tests/config/sfCompileConfigHandlerTest.php new file mode 100644 index 000000000..47e7a77f1 --- /dev/null +++ b/tests/config/sfCompileConfigHandlerTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfCompileConfigHandlerTest extends TestCase +{ + public function testExecute() + { + $handler = new sfCompileConfigHandler(); + $handler->initialize(); + + $dir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'sfCompileConfigHandler'); + + sfConfig::set('sf_debug', true); + $data = $handler->execute(array($dir.DIRECTORY_SEPARATOR.'simple.yml')); + $this->assertSame(true, false !== strpos($data, "class sfInflector\n{\n /**"), '->execute() return complete classe codes'); + + sfConfig::set('sf_debug', false); + $data = $handler->execute(array($dir.DIRECTORY_SEPARATOR.'simple.yml')); + $this->assertSame(true, false !== strpos($data, "class sfInflector\n{\n public"), '->execute() return minified classe codes'); + } +} diff --git a/tests/config/sfConfigHandlerTest.php b/tests/config/sfConfigHandlerTest.php new file mode 100644 index 000000000..92dbb1e28 --- /dev/null +++ b/tests/config/sfConfigHandlerTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/myConfigHandler.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfConfigHandlerTest extends TestCase +{ + public function testInitialize() + { + $config = new myConfigHandler(); + $config->initialize(); + + $config->initialize(array('foo' => 'bar')); + $this->assertSame('bar', $config->getParameterHolder()->get('foo'), '->initialize() takes an array of parameters as its first argument'); + } + + public function testReplaceConstants() + { + $config = new myConfigHandler(); + $config->initialize(); + + sfConfig::set('foo', 'bar'); + $this->assertSame('my value with a bar constant', sfConfigHandler::replaceConstants('my value with a %foo% constant'), '::replaceConstants() replaces constants enclosed in %'); + $this->assertSame('%Y/%m/%d %H:%M', sfConfigHandler::replaceConstants('%Y/%m/%d %H:%M'), '::replaceConstants() does not replace unknown constants'); + + sfConfig::set('foo', 'bar'); + $value = array( + 'foo' => 'my value with a %foo% constant', + 'bar' => array( + 'foo' => 'my value with a %foo% constant', + ), + ); + $value = sfConfigHandler::replaceConstants($value); + $this->assertSame('my value with a bar constant', $value['foo'], '::replaceConstants() replaces constants in arrays recursively'); + $this->assertSame('my value with a bar constant', $value['bar']['foo'], '::replaceConstants() replaces constants in arrays recursively'); + } + + public function testGetParameterHolder() + { + $config = new myConfigHandler(); + $config->initialize(); + + $this->assertInstanceOf(sfParameterHolder::class, $config->getParameterHolder(), '->getParameterHolder() returns a parameter holder instance'); + } + + public function testReplacePath() + { + $config = new myConfigHandler(); + $config->initialize(); + + sfConfig::set('sf_app_dir', 'ROOTDIR'); + $this->assertSame($config->replacePath('test'), 'ROOTDIR/test', '->replacePath() prefix a relative path with "sf_app_dir"'); + $this->assertSame($config->replacePath('/test'), '/test', '->replacePath() prefix a relative path with "sf_app_dir"'); + } +} diff --git a/tests/config/sfConfigTest.php b/tests/config/sfConfigTest.php new file mode 100644 index 000000000..a954eede5 --- /dev/null +++ b/tests/config/sfConfigTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfConfigTest extends TestCase +{ + public function setUp(): void + { + sfConfig::clear(); + } + + public function testSet() + { + sfConfig::set('foo', 'bar'); + + $this->assertSame('bar', sfConfig::get('foo')); + $this->assertSame('default_value', sfConfig::get('foo1', 'default_value')); + } + + public function testHas() + { + $this->assertSame(false, sfConfig::has('foo')); + + sfConfig::set('foo', 'bar'); + + $this->assertSame(true, sfConfig::has('foo')); + } + + public function testAdd() + { + sfConfig::set('foo', 'bar'); + sfConfig::set('foo1', 'foo1'); + sfConfig::add(array('foo' => 'foo', 'bar' => 'bar')); + + $this->assertSame('foo', sfConfig::get('foo')); + $this->assertSame('bar', sfConfig::get('bar')); + $this->assertSame('foo1', sfConfig::get('foo1')); + } + + public function testGetAll() + { + sfConfig::set('foo', 'bar'); + sfConfig::set('foo1', 'foo1'); + + $this->assertSame(array('foo' => 'bar', 'foo1' => 'foo1'), sfConfig::getAll()); + } + + public function testClear() + { + sfConfig::set('foo1', 'foo1'); + $this->assertSame('foo1', sfConfig::get('foo1')); + sfConfig::clear(); + $this->assertSame(null, sfConfig::get('foo1')); + } +} diff --git a/tests/config/sfDefineEnvironmentConfigHandlerTest.php b/tests/config/sfDefineEnvironmentConfigHandlerTest.php new file mode 100644 index 000000000..047313f0c --- /dev/null +++ b/tests/config/sfDefineEnvironmentConfigHandlerTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfDefineEnvironmentConfigHandlerTest extends TestCase +{ + public function testPrefix() + { + sfConfig::set('sf_symfony_lib_dir', realpath(__DIR__.'/../../../lib')); + + // prefix + $handler = new sfDefineEnvironmentConfigHandler(); + $handler->initialize(array('prefix' => 'sf_')); + + $dir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'sfDefineEnvironmentConfigHandler'); + + $files = array( + $dir.DIRECTORY_SEPARATOR.'prefix_default.yml', + $dir.DIRECTORY_SEPARATOR.'prefix_all.yml', + ); + + sfConfig::set('sf_environment', 'prod'); + + $data = $handler->execute($files); + $data = preg_replace('#date\: \d+/\d+/\d+ \d+\:\d+\:\d+#', '', $data); + + $this->assertSame($data, str_replace("\r\n", "\n", file_get_contents($dir.DIRECTORY_SEPARATOR.'prefix_result.php'))); + } +} diff --git a/tests/config/sfFilterConfigHandlerTest.php b/tests/config/sfFilterConfigHandlerTest.php new file mode 100644 index 000000000..5c02efb33 --- /dev/null +++ b/tests/config/sfFilterConfigHandlerTest.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfFilterConfigHandlerTest extends TestCase +{ + public function testClassSectionParserError() + { + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $files = array( + $dir.'no_class.yml', + ); + + $this->expectException(sfParseException::class); + $data = $handler->execute($files); + } + + /** @dataProvider parseErrorsDataProvider */ + public function testParseErrors(string $errorKind) + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.sprintf('no_%s.yml', $errorKind), + ); + + $this->expectException(sfParseException::class); + $data = $handler->execute($files); + } + + public function parseErrorsDataProvider(): Generator + { + yield array('execution'); + yield array('rendering'); + } + + public function testFilterInheritance() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'default_filters.yml', + $dir.'not_disabled.yml', + ); + + $this->expectException(sfConfigurationException::class); + $data = $handler->execute($files); + } + + public function testFilterDisabling() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'disable.yml', + ); + + $this->assertDoesNotMatchRegularExpression('/defaultFilterClass/', $handler->execute($files), 'you can disable a filter by settings "enabled" to false'); + } + + public function testConditionSupport() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'condition.yml', + ); + + sfConfig::set('default_test', true); + $this->assertMatchesRegularExpression('/defaultFilterClass/', $handler->execute($files), 'you can add a "condition" key to the filter parameters'); + + sfConfig::set('default_test', false); + $this->assertDoesNotMatchRegularExpression('/defaultFilterClass/', $handler->execute($files), 'you can add a "condition" key to the filter parameters'); + } + + public function testUsualConfiuration() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfFilterConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfFilterConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'default_filters.yml', + $dir.'filters.yml', + ); + + $data = $handler->execute($files); + $data = preg_replace('#date\: \d+/\d+/\d+ \d+\:\d+\:\d+\n#', '', $data); + $this->assertSame($data, str_replace("\r\n", "\n", file_get_contents($dir.'result.php')), 'core filters.yml can be overriden'); + } +} diff --git a/tests/config/sfGeneratorConfigHandlerTest.php b/tests/config/sfGeneratorConfigHandlerTest.php new file mode 100644 index 000000000..178265e9d --- /dev/null +++ b/tests/config/sfGeneratorConfigHandlerTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfGeneratorConfigHandlerTest extends TestCase +{ + protected function setUp(): void + { + sfConfig::set('sf_symfony_lib_dir', realpath(__DIR__.'/../../../lib')); + } + + public function testParseError() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfGeneratorConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfGeneratorConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'empty.yml', + $dir.'no_generator_class.yml', + ); + + $this->expectException(sfParseException::class); + $this->expectExceptionMessageMatches('/must specify a generator class section under the generator section/'); + $data = $handler->execute($files); + } + + public function testMissingGeneratorSection() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfGeneratorConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfGeneratorConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'empty.yml', + $dir.'no_generator_section.yml', + ); + + $this->expectException(sfParseException::class); + $this->expectExceptionMessageMatches('/must specify a generator section/'); + $data = $handler->execute($files); + } + + public function testFieldsSectionUnderParam() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfGeneratorConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfGeneratorConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'empty.yml', + $dir.'root_fields_section.yml', + ); + + $this->expectException(sfParseException::class); + $this->expectExceptionMessageMatches('/can specify a "fields" section but only under the param section/'); + $data = $handler->execute($files); + } + + public function testListSectionUnderParam() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfGeneratorConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfGeneratorConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'empty.yml', + $dir.'root_list_section.yml', + ); + + $this->expectException(sfParseException::class); + $this->expectExceptionMessageMatches('/can specify a "list" section but only under the param section/'); + $data = $handler->execute($files); + } + + public function testEditSectionUnderParam() + { + $fixtureDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixtureDir.DIRECTORY_SEPARATOR.'sfGeneratorConfigHandler'.DIRECTORY_SEPARATOR; + + $handler = new sfGeneratorConfigHandler(); + $handler->initialize(); + + $files = array( + $dir.'empty.yml', + $dir.'root_edit_section.yml', + ); + + $this->expectException(sfParseException::class); + $this->expectExceptionMessageMatches('/can specify a "edit" section but only under the param section/'); + $data = $handler->execute($files); + } +} diff --git a/tests/config/sfPluginConfigurationTest.php b/tests/config/sfPluginConfigurationTest.php new file mode 100644 index 000000000..39d86ec75 --- /dev/null +++ b/tests/config/sfPluginConfigurationTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../../lib/test/Symfony1ProjectTestCase.php'; +$rootDir = realpath(__DIR__.'/../fixtures/symfony'); +$pluginRoot = realpath($rootDir.'/plugins/sfAutoloadPlugin'); +require_once $pluginRoot.'/config/sfAutoloadPluginConfiguration.class.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfPluginConfigurationTest extends Symfony1ProjectTestCase +{ + public function projectSetup(sfProjectConfiguration $configuration) + { + $configuration->enablePlugins('sfAutoloadPlugin'); + } + + public function testGuessRootDirAndName() + { + $rootDir = realpath(__DIR__.'/../fixtures/symfony'); + $pluginRoot = realpath($rootDir.'/plugins/sfAutoloadPlugin'); + + $configuration = $this->getProjectConfiguration(); + $pluginConfig = new sfAutoloadPluginConfiguration($configuration); + + $this->assertSame($pluginRoot, $pluginConfig->getRootDir(), '->guessRootDir() guesses plugin root directory'); + $this->assertSame('sfAutoloadPlugin', $pluginConfig->getName(), '->guessName() guesses plugin name'); + } + + public function testFilterTestFiles() + { + $rootDir = realpath(__DIR__.'/../fixtures/symfony'); + + $configuration = $this->getProjectConfiguration(); + $pluginConfig = new sfAutoloadPluginConfiguration($configuration); + + $task = new sfTestAllTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array(), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(6, \count($files), '->filterTestFiles() adds all plugin tests'); + } + + public function testTestFunctional() + { + $rootDir = realpath(__DIR__.'/../fixtures/symfony'); + + $configuration = $this->getProjectConfiguration(); + $pluginConfig = new sfAutoloadPluginConfiguration($configuration); + + $task = new sfTestFunctionalTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('controller' => array()), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(3, \count($files), '->filterTestFiles() adds functional plugin tests'); + + $task = new sfTestFunctionalTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('controller' => array('BarFunctional')), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(1, \count($files), '->filterTestFiles() adds functional plugin tests when a controller is specified'); + + $task = new sfTestFunctionalTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('controller' => array('nested/NestedFunctional')), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(1, \count($files), '->filterTestFiles() adds functional plugin tests when a nested controller is specified'); + } + + public function testTestUnit() + { + $rootDir = realpath(__DIR__.'/../fixtures/symfony'); + + $configuration = $this->getProjectConfiguration(); + $pluginConfig = new sfAutoloadPluginConfiguration($configuration); + + $task = new sfTestUnitTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('name' => array()), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(3, \count($files), '->filterTestFiles() adds unit plugin tests'); + + $task = new sfTestUnitTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('name' => array('FooUnit')), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(1, \count($files), '->filterTestFiles() adds unit plugin tests when a name is specified'); + + $task = new sfTestUnitTask($configuration->getEventDispatcher(), new sfFormatter()); + $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('name' => array('nested/NestedUnit')), 'options' => array())); + $files = $pluginConfig->filterTestFiles($event, array()); + $this->assertSame(1, \count($files), '->filterTestFiles() adds unit plugin tests when a nested name is specified'); + } +} diff --git a/tests/config/sfProjectConfigurationNonExistentPluginTest.php b/tests/config/sfProjectConfigurationNonExistentPluginTest.php new file mode 100644 index 000000000..8ae13e318 --- /dev/null +++ b/tests/config/sfProjectConfigurationNonExistentPluginTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../../lib/test/Symfony1ProjectTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfProjectConfigurationNonExistentPluginTest extends Symfony1ProjectTestCase +{ + public function projectSetup(sfProjectConfiguration $configuration) + { + $configuration->enablePlugins('NonExistantPlugin'); + } + + public function testEnableNonExistantPlugin() + { + $this->expectException(\InvalidArgumentException::class); + + $configuration = $this->getProjectConfiguration(); + } +} diff --git a/tests/config/sfProjectConfigurationTest.php b/tests/config/sfProjectConfigurationTest.php new file mode 100644 index 000000000..627ca02c1 --- /dev/null +++ b/tests/config/sfProjectConfigurationTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../../lib/test/Symfony1ProjectTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfProjectConfigurationTest extends Symfony1ProjectTestCase +{ + public function projectSetup(sfProjectConfiguration $configuration) + { + $configuration->enablePlugins(array('sfAutoloadPlugin', 'sfConfigPlugin')); + $configuration->setPluginPath('sfConfigPlugin', $configuration->getRootDir().'/lib/plugins/sfConfigPlugin'); + } + + /** + * @dataProvider lateMethodCallExceptionDataProvider + */ + public function testLateMethodCallException(string $methodName) + { + $this->expectException(\LogicException::class); + + $configuration = $this->getProjectConfiguration(); + + $configuration->{$methodName}(array()); + } + + public static function lateMethodCallExceptionDataProvider(): Generator + { + yield array('setPlugins'); + yield array('disablePlugins'); + yield array('enablePlugins'); + yield array('enableAllPluginsExcept'); + } + + public function testEnabledPlugins() + { + $configuration = $this->getProjectConfiguration(); + + $this->assertSame(array('sfAutoloadPlugin', 'sfConfigPlugin'), $configuration->getPlugins()); + } +} diff --git a/tests/config/sfSimpleYamlConfigHandlerTest.php b/tests/config/sfSimpleYamlConfigHandlerTest.php new file mode 100644 index 000000000..e2196fb96 --- /dev/null +++ b/tests/config/sfSimpleYamlConfigHandlerTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +function get_retval($config, $files) +{ + $retval = $config->execute($files); + $retval = preg_replace('#^<\?php#', '', $retval); + $retval = preg_replace('#<\?php$#s', '', $retval); + + return eval($retval); +} + +/** + * @internal + * + * @coversNothing + */ +class sfSimpleYamlConfigHandlerTest extends TestCase +{ + public function test() + { + $config = new sfSimpleYamlConfigHandler(); + $config->initialize(); + + $fixturesDir = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'fixtures'); + $dir = $fixturesDir.DIRECTORY_SEPARATOR.'sfSimpleYamlConfigHandler'.DIRECTORY_SEPARATOR; + + $array = get_retval($config, array($dir.'config.yml')); + $this->assertSame('foo', $array['article']['title'], '->execute() returns configuration file as an array'); + + $array = get_retval($config, array($dir.'config.yml', $dir.'config_bis.yml')); + $this->assertSame('bar', $array['article']['title'], '->execute() returns configuration file as an array'); + } +} diff --git a/tests/config/sfViewConfigHandlerTest.php b/tests/config/sfViewConfigHandlerTest.php new file mode 100644 index 000000000..5aecf6025 --- /dev/null +++ b/tests/config/sfViewConfigHandlerTest.php @@ -0,0 +1,337 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/myViewConfigHandler.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfViewConfigHandlerTest extends TestCase +{ + public function testAddHtmlAsset() + { + $handler = new myViewConfigHandler(); + + $handler->setConfiguration(array( + 'myView' => array( + 'stylesheets' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds stylesheets to the response'); + + $handler->setConfiguration(array( + 'myView' => array( + 'stylesheets' => array(array('foobar' => array('position' => 'last'))), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('foobar', 'last', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds stylesheets to the response'); + + $handler->setConfiguration(array( + 'myView' => array( + 'javascripts' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds JavaScript to the response'); + + $handler->setConfiguration(array( + 'myView' => array( + 'javascripts' => array(array('foobar' => array('position' => 'last'))), + ), + )); + $content = <<<'EOF' + $response->addJavascript('foobar', 'last', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds JavaScript to the response'); + + $handler->setConfiguration(array( + 'myView' => array( + 'stylesheets' => array('foobar'), + ), + 'all' => array( + 'stylesheets' => array('all_foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('all_foobar', '', array ()); + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific stylesheets after application-wide assets'); + + $handler->setConfiguration(array( + 'all' => array( + 'stylesheets' => array('all_foobar'), + ), + 'myView' => array( + 'stylesheets' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('all_foobar', '', array ()); + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific stylesheets after application-wide assets'); + + $handler->setConfiguration(array( + 'myView' => array( + 'stylesheets' => array('foobar'), + ), + 'default' => array( + 'stylesheets' => array('default_foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('default_foobar', '', array ()); + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific stylesheets after default assets'); + + $handler->setConfiguration(array( + 'default' => array( + 'stylesheets' => array('default_foobar'), + ), + 'myView' => array( + 'stylesheets' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('default_foobar', '', array ()); + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific stylesheets after default assets'); + + $handler->setConfiguration(array( + 'default' => array( + 'stylesheets' => array('default_foobar'), + ), + 'all' => array( + 'stylesheets' => array('all_foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('default_foobar', '', array ()); + $response->addStylesheet('all_foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds application-specific stylesheets after default assets'); + + $handler->setConfiguration(array( + 'all' => array( + 'stylesheets' => array('all_foobar'), + ), + 'default' => array( + 'stylesheets' => array('default_foobar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('default_foobar', '', array ()); + $response->addStylesheet('all_foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds application-specific stylesheets after default assets'); + + $handler->setConfiguration(array( + 'myView' => array( + 'javascripts' => array('foobar'), + ), + 'all' => array( + 'javascripts' => array('all_foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('all_foobar', '', array ()); + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific javascripts after application-wide assets'); + + $handler->setConfiguration(array( + 'all' => array( + 'javascripts' => array('all_foobar'), + ), + 'myView' => array( + 'javascripts' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('all_foobar', '', array ()); + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific javascripts after application-wide assets'); + + $handler->setConfiguration(array( + 'myView' => array( + 'javascripts' => array('foobar'), + ), + 'default' => array( + 'javascripts' => array('default_foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('default_foobar', '', array ()); + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific javascripts after default assets'); + + $handler->setConfiguration(array( + 'default' => array( + 'javascripts' => array('default_foobar'), + ), + 'myView' => array( + 'javascripts' => array('foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('default_foobar', '', array ()); + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds view-specific javascripts after default assets'); + + $handler->setConfiguration(array( + 'default' => array( + 'javascripts' => array('default_foobar'), + ), + 'all' => array( + 'javascripts' => array('all_foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('default_foobar', '', array ()); + $response->addJavascript('all_foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds application-specific javascripts after default assets'); + + $handler->setConfiguration(array( + 'all' => array( + 'javascripts' => array('all_foobar'), + ), + 'default' => array( + 'javascripts' => array('default_foobar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('default_foobar', '', array ()); + $response->addJavascript('all_foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() adds application-specific javascripts after default assets'); + + $handler->setConfiguration(array( + 'all' => array( + 'stylesheets' => array('all_foo', 'all_bar'), + ), + 'myView' => array( + 'stylesheets' => array('foobar', '-all_bar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('all_foo', '', array ()); + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the - option to remove one stylesheet previously added'); + + $handler->setConfiguration(array( + 'all' => array( + 'javascripts' => array('all_foo', 'all_bar'), + ), + 'myView' => array( + 'javascripts' => array('foobar', '-all_bar'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('all_foo', '', array ()); + $response->addJavascript('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the - option to remove one javascript previously added'); + + $handler->setConfiguration(array( + 'all' => array( + 'stylesheets' => array('foo', 'bar', '-*', 'baz'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('baz', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the -* option to remove all stylesheets previously added'); + + $handler->setConfiguration(array( + 'all' => array( + 'javascripts' => array('foo', 'bar', '-*', 'baz'), + ), + )); + $content = <<<'EOF' + $response->addJavascript('baz', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the -* option to remove all javascripts previously added'); + + $handler->setConfiguration(array( + 'all' => array( + 'stylesheets' => array('-*', 'foobar'), + ), + 'default' => array( + 'stylesheets' => array('default_foo', 'default_bar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('foobar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the -* option to remove all assets previously added'); + + $handler->setConfiguration(array( + 'myView' => array( + 'stylesheets' => array('foobar', '-*', 'bar'), + 'javascripts' => array('foobar', '-*', 'bar'), + ), + 'all' => array( + 'stylesheets' => array('all_foo', 'all_foofoo', 'all_barbar'), + 'javascripts' => array('all_foo', 'all_foofoo', 'all_barbar'), + ), + 'default' => array( + 'stylesheets' => array('default_foo', 'default_foofoo', 'default_barbar'), + 'javascripts' => array('default_foo', 'default_foofoo', 'default_barbar'), + ), + )); + $content = <<<'EOF' + $response->addStylesheet('bar', '', array ()); + $response->addJavascript('bar', '', array ()); + +EOF; + $this->assertSame(fix_linebreaks($handler->addHtmlAsset('myView')), fix_linebreaks($content), 'addHtmlAsset() supports the -* option to remove all assets previously added'); + } +} diff --git a/tests/config/sfYamlConfigHandlerTest.php b/tests/config/sfYamlConfigHandlerTest.php new file mode 100644 index 000000000..d983f94d2 --- /dev/null +++ b/tests/config/sfYamlConfigHandlerTest.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/myYamlConfigHandler.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfYamlConfigHandlerTest extends TestCase +{ + public function testMergeConfigValue() + { + $config = new myYamlConfigHandler(); + $config->initialize(); + + $config->yamlConfig = array( + 'bar' => array( + 'foo' => array( + 'foo' => 'foobar', + 'bar' => 'bar', + ), + ), + 'all' => array( + 'foo' => array( + 'foo' => 'fooall', + 'barall' => 'barall', + ), + ), + ); + $values = $config->mergeConfigValue('foo', 'bar'); + $this->assertSame('foobar', $values['foo'], '->mergeConfigValue() merges values for a given key under a given category'); + $this->assertSame('bar', $values['bar'], '->mergeConfigValue() merges values for a given key under a given category'); + $this->assertSame('barall', $values['barall'], '->mergeConfigValue() merges values for a given key under a given category'); + } + + public function testGetConfigValue() + { + $config = new myYamlConfigHandler(); + $config->initialize(); + + $config->yamlConfig = array( + 'bar' => array( + 'foo' => 'foobar', + ), + 'all' => array( + 'foo' => 'fooall', + ), + ); + $this->assertSame('foobar', $config->getConfigValue('foo', 'bar'), '->getConfigValue() returns the value for the key in the given category'); + $this->assertSame('fooall', $config->getConfigValue('foo', 'all'), '->getConfigValue() returns the value for the key in the given category'); + $this->assertSame('fooall', $config->getConfigValue('foo', 'foofoo'), '->getConfigValue() returns the value for the key in the "all" category if the key does not exist in the given category'); + $this->assertSame('default', $config->getConfigValue('foofoo', 'foofoo', 'default'), '->getConfigValue() returns the default value if key is not found in the category and in the "all" category'); + } +} diff --git a/tests/controller/sfControllerTest.php b/tests/controller/sfControllerTest.php new file mode 100644 index 000000000..3654e6454 --- /dev/null +++ b/tests/controller/sfControllerTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../sfContext.class.php'; +require_once __DIR__.'/../fixtures/myController.php'; +require_once __DIR__.'/../sfEventDispatcherTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfControllerTest extends sfEventDispatcherTestCase +{ + public function setUp(): void + { + parent::setUp(); + + $context = sfContext::getInstance(); + $this->testObject = new myController($context); + $this->dispatcher = $context->getEventDispatcher(); + $this->class = 'controller'; + } +} diff --git a/tests/controller/sfWebControllerTest.php b/tests/controller/sfWebControllerTest.php new file mode 100644 index 000000000..cdf3b64af --- /dev/null +++ b/tests/controller/sfWebControllerTest.php @@ -0,0 +1,230 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../sfContext.class.php'; +require_once __DIR__.'/../sfNoRouting.class.php'; +require_once __DIR__.'/../fixtures/myWebResponse.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfWebControllerTest extends TestCase +{ + private sfFrontWebController $controller; + private sfContext $context; + + protected function setUp(): void + { + $_SERVER['HTTP_HOST'] = 'localhost'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + sfConfig::set('sf_max_forwards', 10); + $this->context = sfContext::getInstance(array( + 'routing' => 'sfNoRouting', + 'request' => 'sfWebRequest', + 'response' => 'myWebResponse', + ), true); + + $this->controller = new sfFrontWebController($this->context, null); + } + + /** @dataProvider convertUrlStringToParametersDataProvider */ + public function testConvertUrlStringToParameters(string $url, array $expected) + { + $message = sprintf('->convertUrlStringToParameters() converts a symfony internal URI to an array of parameters (%s)', $url); + $this->assertSame($expected, $this->controller->convertUrlStringToParameters($url), $message); + } + + public function convertUrlStringToParametersDataProvider(): Generator + { + yield array('module/action', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + ), + )); + + yield array('module/action?id=12', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'id' => '12', + ), + )); + + yield array('module/action?id=12&', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'id' => '12&', + ), + )); + + yield array('module/action?id=12&test=4&toto=9', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'id' => '12', + 'test' => '4', + 'toto' => '9', + ), + )); + + yield array('module/action?id=12&test=4&5&6&7&&toto=9', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'id' => '12', + 'test' => '4&5&6&7&', + 'toto' => '9', + ), + )); + + yield array('module/action?test=value1&value2&toto=9', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'test' => 'value1&value2', + 'toto' => '9', + ), + )); + + yield array('module/action?test=value1&value2', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'test' => 'value1&value2', + ), + )); + + yield array('module/action?test=value1=value2&toto=9', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'test' => 'value1=value2', + 'toto' => '9', + ), + )); + + yield array('module/action?test=value1=value2', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'test' => 'value1=value2', + ), + )); + + yield array('module/action?test=4&5&6&7&&toto=9&id=', array( + '', + array( + 'module' => 'module', + 'action' => 'action', + 'test' => '4&5&6&7&', + 'toto' => '9', + 'id' => '', + ), + )); + + yield array('@test?test=4', array( + 'test', + array( + 'test' => '4', + ), + )); + + yield array('@test', array( + 'test', + array( + ), + )); + + yield array('@test?id=12&foo=bar', array( + 'test', + array( + 'id' => '12', + 'foo' => 'bar', + ), + )); + + yield array('@test?id=foo%26bar&foo=bar%3Dfoo', array( + 'test', + array( + 'id' => 'foo&bar', + 'foo' => 'bar=foo', + ), + )); + } + + public function testParseError() + { + $this->expectException(sfParseException::class); + $this->controller->convertUrlStringToParameters('@test?foobar'); + } + + public function testRedirect() + { + $this->controller->redirect('module/action?id=1#photos'); + $response = $this->context->getResponse(); + $this->assertMatchesRegularExpression('~http\://localhost/index.php/\?module=module&action=action&id=1#photos~', $response->getContent(), '->redirect() adds a refresh meta in the content'); + $this->assertMatchesRegularExpression('~http\://localhost/index.php/\?module=module&action=action&id=1#photos~', $response->getHttpHeader('Location'), '->redirect() adds a Location HTTP header'); + } + + public function testRedirectWithNull() + { + try { + $this->controller->redirect(null); + + $this->assertTrue(false, '->redirect() throw an InvalidArgumentException when the url argument is null'); + } catch (InvalidArgumentException $iae) { + $this->assertTrue(true, '->redirect() throw an InvalidArgumentException when the url argument is null'); + } catch (Exception $e) { + $this->assertTrue(false, '->redirect() throw an InvalidArgumentException when the url argument is null. '.get_class($e).' was received'); + } + } + + public function testRedirectWithEmpty() + { + try { + $this->controller->redirect(''); + + $this->assertTrue(false, '->redirect() throw an InvalidArgumentException when the url argument is an empty string'); + } catch (InvalidArgumentException $iae) { + $this->assertTrue(true, '->redirect() throw an InvalidArgumentException when the url argument is an empty string'); + } catch (Exception $e) { + $this->assertTrue(false, '->redirect() throw an InvalidArgumentException when the url argument is an empty string. '.get_class($e).' was received'); + } + } + + public function testGenUrl() + { + $expected = $this->controller->genUrl(array('action' => 'action', 'module' => 'module', 'id' => 4)); + $actual = $this->controller->genUrl('module/action?id=4'); + $this->assertSame($expected, $actual, '->genUrl() accepts a string or an array as its first argument'); + } + + public function testGenUrlWithEmptyString() + { + $lastError = error_get_last(); + $this->controller->genUrl(''); + $this->assertSame(error_get_last(), $lastError, '->genUrl() accepts an empty string'); + } +} diff --git a/tests/database/sfDatabaseTest.php b/tests/database/sfDatabaseTest.php new file mode 100644 index 000000000..3b4ef2358 --- /dev/null +++ b/tests/database/sfDatabaseTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../sfContext.class.php'; +require_once __DIR__.'/../fixtures/myDatabase.php'; +require_once __DIR__.'/../sfParameterHolderProxyTestCase.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfDatabaseTest extends sfParameterHolderProxyTestCase +{ + public function setUp(): void + { + $this->object = new myDatabase(); + $this->object->initialize(sfContext::getInstance()); + } +} diff --git a/tests/debug/sfDebugTest.php b/tests/debug/sfDebugTest.php new file mode 100644 index 000000000..8d208870f --- /dev/null +++ b/tests/debug/sfDebugTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/A.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfDebugTest extends TestCase +{ + public function testRemoveObjects() + { + $objectArray = array('foo', 42, new sfDebug(), array('bar', 23, new A())); + $cleanedArray = array('foo', 42, 'sfDebug Object()', array('bar', 23, 'A Object()')); + + $this->assertSame($cleanedArray, sfDebug::removeObjects($objectArray), '::removeObjects() converts objects to String representations using the class name'); + } +} diff --git a/tests/debug/sfTimerTest.php b/tests/debug/sfTimerTest.php new file mode 100644 index 000000000..29fc504d6 --- /dev/null +++ b/tests/debug/sfTimerTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +/** + * @internal + * + * @coversNothing + */ +class sfTimerTest extends TestCase +{ + public function testStartingAndStopping() + { + $timer = new sfTimer(); + $timer->addTime(); + sleep(1); + $timer->addTime(); + $this->assertSame(2, $timer->getCalls(), '->getCalls() returns the amount of addTime() calls'); + $this->assertSame(true, $timer->getElapsedTime() > 0, '->getElapsedTime() returns a value greater than zero. No precision is tested by the unit test to avoid false alarms'); + } + + public function testTimeManager() + { + $timerA = sfTimerManager::getTimer('timerA'); + $timerB = sfTimerManager::getTimer('timerB'); + $this->assertInstanceOf('sfTimer', $timerA, '::getTimer() returns an sfTimer instance'); + + $timers = sfTimerManager::getTimers(); + $this->assertSame(2, \count($timers), '::getTimers() returns an array with the timers created by the timer manager'); + $this->assertSame($timerA, $timers['timerA'], '::getTimers() returns an array with keys being the timer name'); + sfTimerManager::clearTimers(); + $this->assertSame(0, \count(sfTimerManager::getTimers()), '::clearTimers() empties the list of the timer instances'); + } +} diff --git a/tests/debug/sfWebDebugInjectTest.php b/tests/debug/sfWebDebugInjectTest.php new file mode 100644 index 000000000..bf44f87a2 --- /dev/null +++ b/tests/debug/sfWebDebugInjectTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use PHPUnit\Framework\TestCase; + +require_once __DIR__.'/../fixtures/sfWebDebugTest.php'; + +/** + * @internal + * + * @coversNothing + */ +class sfWebDebugInjectTest extends TestCase +{ + private sfWebDebugTest $debug; + + protected function setUp(): void + { + $this->debug = new sfWebDebugTest(); + } + + public function testInjectToolbar() + { + $before = ''; + $after = $this->debug->injectToolbar($before); + + $this->assertMatchesRegularExpression('/