From 39bbc0fbe8de47f3755414a192c74b48b71da04a Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Fri, 26 May 2023 17:50:33 +0200 Subject: [PATCH] Specs: Workaround for the DefineDefaultCulture binding and removing the Settings feature which is now redundant with CreatingAndUsingDateTimeFieldsInAnotherCulture --- src/Orchard.Specs/Bindings/Settings.cs | 19 +++--- src/Orchard.Specs/Orchard.Specs.csproj | 9 --- src/Orchard.Specs/Settings.feature | 14 ---- src/Orchard.Specs/Settings.feature.cs | 93 -------------------------- 4 files changed, 8 insertions(+), 127 deletions(-) delete mode 100644 src/Orchard.Specs/Settings.feature delete mode 100644 src/Orchard.Specs/Settings.feature.cs diff --git a/src/Orchard.Specs/Bindings/Settings.cs b/src/Orchard.Specs/Bindings/Settings.cs index 607c01ab0..4bd67b750 100644 --- a/src/Orchard.Specs/Bindings/Settings.cs +++ b/src/Orchard.Specs/Bindings/Settings.cs @@ -1,15 +1,7 @@ -using System; -using NUnit.Framework; -using Orchard.ContentManagement; -using Orchard.ContentManagement.Aspects; -using Orchard.Core.Contents; -using Orchard.Data; -using Orchard.Security; -using Orchard.Security.Permissions; +using System.Linq; +using Orchard.Localization.Services; using Orchard.Specs.Hosting.Orchard.Web; using TechTalk.SpecFlow; -using Orchard.Localization.Services; -using System.Linq; namespace Orchard.Specs.Bindings { [Binding] @@ -20,7 +12,7 @@ namespace Orchard.Specs.Bindings { var webApp = Binding(); webApp.Host.Execute(() => { - using ( var environment = MvcApplication.CreateStandaloneEnvironment("Default") ) { + using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var orchardServices = environment.Resolve(); var cultureManager = environment.Resolve(); @@ -30,6 +22,11 @@ namespace Orchard.Specs.Bindings { } orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName; + + // Restarting the shell to reset the cache, because the cache entry storing the list of available + // cultures isn't invalidated by the signal in DefaultCultureManager.ListCultures when running + // inside the test webhost. + MvcApplication.RestartTenant("Default"); } }); } diff --git a/src/Orchard.Specs/Orchard.Specs.csproj b/src/Orchard.Specs/Orchard.Specs.csproj index e64f028c7..9eada9333 100644 --- a/src/Orchard.Specs/Orchard.Specs.csproj +++ b/src/Orchard.Specs/Orchard.Specs.csproj @@ -188,11 +188,6 @@ True True - - True - True - Settings.feature - Text.feature True @@ -365,10 +360,6 @@ HostComponents.config - - SpecFlowSingleFileGenerator - Settings.feature.cs - SpecFlowSingleFileGenerator Text.feature.cs diff --git a/src/Orchard.Specs/Settings.feature b/src/Orchard.Specs/Settings.feature deleted file mode 100644 index d45673639..000000000 --- a/src/Orchard.Specs/Settings.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Settings - -In order to manage my site -As a privileged user -I want to be able to see and change site settings - -Scenario: Adding a new site culture and selecting it as the default works - - Given I have installed Orchard - When I go to "Admin/Settings/Index" - Then I should not see "hu-HU" - When I have "hu-HU" as the default culture - And I go to "Admin/Settings/Index" - Then I should see "" diff --git a/src/Orchard.Specs/Settings.feature.cs b/src/Orchard.Specs/Settings.feature.cs deleted file mode 100644 index 83e95acf9..000000000 --- a/src/Orchard.Specs/Settings.feature.cs +++ /dev/null @@ -1,93 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by SpecFlow (http://www.specflow.org/). -// SpecFlow Version:1.9.0.77 -// SpecFlow Generator Version:1.9.0.0 -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -namespace Orchard.Specs -{ - using TechTalk.SpecFlow; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("Settings")] - public partial class SettingsFeature - { - - private static TechTalk.SpecFlow.ITestRunner testRunner; - -#line 1 "Settings.feature" -#line hidden - - [NUnit.Framework.TestFixtureSetUpAttribute()] - public virtual void FeatureSetup() - { - testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); - TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Settings", "\r\nIn order to manage my site\r\nAs a privileged user\r\nI want to be able to see and " + - "change site settings", ProgrammingLanguage.CSharp, ((string[])(null))); - testRunner.OnFeatureStart(featureInfo); - } - - [NUnit.Framework.TestFixtureTearDownAttribute()] - public virtual void FeatureTearDown() - { - testRunner.OnFeatureEnd(); - testRunner = null; - } - - [NUnit.Framework.SetUpAttribute()] - public virtual void TestInitialize() - { - } - - [NUnit.Framework.TearDownAttribute()] - public virtual void ScenarioTearDown() - { - testRunner.OnScenarioEnd(); - } - - public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioStart(scenarioInfo); - } - - public virtual void ScenarioCleanup() - { - testRunner.CollectScenarioErrors(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Adding a new site culture and selecting it as the default works")] - public virtual void AddingANewSiteCultureAndSelectingItAsTheDefaultWorks() - { - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Adding a new site culture and selecting it as the default works", ((string[])(null))); -#line 7 -this.ScenarioSetup(scenarioInfo); -#line 9 - testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); -#line 10 - testRunner.When("I go to \"Admin/Settings/Index\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line 11 - testRunner.Then("I should not see \"hu-HU\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line 12 - testRunner.When("I have \"hu-HU\" as the default culture", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line 13 - testRunner.And("I go to \"Admin/Settings/Index\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line 14 - testRunner.Then("I should see \"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden - this.ScenarioCleanup(); - } - } -} -#pragma warning restore -#endregion