From 94b73c20baa8c3e9f3c3db96be48e2acc8b59057 Mon Sep 17 00:00:00 2001 From: Daniel Valadas Date: Wed, 14 Aug 2019 22:46:55 -0400 Subject: [PATCH] Update development with fixes from v9.4.0-rc (#2941) * Fix error running unit tests (#2940) When running tests, the following error occurs: VSTest: Could not locate executable. https://github.com/cake-build/cake/issues/1522#issuecomment-341612194 indicates that there's an issue using VS 2019, and presents a workaround to find the correct path * DNN-31366 - Deleted page can still be selected as parent page (#2925) * DNN-31366 - TabController HasChildren returns false if all children are deleted * Simplify HasChildren condition --- Build/Cake/unit-tests.cake | 32 ++++++++---- .../Library/Entities/Tabs/TabController.cs | 51 +++++++++++++++++-- 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/Build/Cake/unit-tests.cake b/Build/Cake/unit-tests.cake index 4e7058869db..ffaaa3382c1 100644 --- a/Build/Cake/unit-tests.cake +++ b/Build/Cake/unit-tests.cake @@ -2,7 +2,7 @@ Task("EnsureAllProjectsBuilt") .IsDependentOn("UpdateDnnManifests") .IsDependentOn("Restore-NuGet-Packages") - .Does(() => + .Does(() => { MSBuild("DNN_Platform.sln", new MSBuildSettings { Verbosity = Verbosity.Minimal, @@ -13,21 +13,31 @@ Task("EnsureAllProjectsBuilt") Task("UnitTests") .IsDependentOn("EnsureAllProjectsBuilt") - .Does(() => + .Does(() => { var testAssemblies = GetFiles($@"**\bin\{configuration}\DotNetNuke.Tests.*.dll"); testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Data.dll"); testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Integration.dll"); testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Utilities.dll"); testAssemblies -= GetFiles(@"**\DotNetNuke.Tests.Urls.dll"); - - foreach(var file in testAssemblies) { - VSTest(file.FullPath, new VSTestSettings() { - Logger = $"trx;LogFileName={file.GetFilename()}.xml", - Parallel = true, - EnableCodeCoverage = true, - FrameworkVersion = VSTestFrameworkVersion.NET45, - TestAdapterPath = @"tools\NUnitTestAdapter.2.1.1\tools" - }); + + foreach (var file in testAssemblies) { + VSTest(file.FullPath, FixToolPath(new VSTestSettings() { + Logger = $"trx;LogFileName={file.GetFilename()}.xml", + Parallel = true, + EnableCodeCoverage = true, + FrameworkVersion = VSTestFrameworkVersion.NET45, + TestAdapterPath = @"tools\NUnitTestAdapter.2.1.1\tools" + })); } }); + +// https://github.com/cake-build/cake/issues/1522 +VSTestSettings FixToolPath(VSTestSettings settings) +{ + #tool vswhere + settings.ToolPath = + VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.VisualStudio.PackageGroup.TestTools.Core" }) + .CombineWithFilePath(File(@"Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe")); + return settings; +} diff --git a/DNN Platform/Library/Entities/Tabs/TabController.cs b/DNN Platform/Library/Entities/Tabs/TabController.cs index 3d013baf22a..20933161bfb 100644 --- a/DNN Platform/Library/Entities/Tabs/TabController.cs +++ b/DNN Platform/Library/Entities/Tabs/TabController.cs @@ -2473,7 +2473,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i false, false, false, - false); + false, + true); } /// @@ -2497,7 +2498,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i includeDeleted, includeURL, false, - false); + false, + true); } /// @@ -2525,7 +2527,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i includeDeleted, includeURL, checkViewPermisison, - checkEditPermission); + checkEditPermission, + true); } /// @@ -2544,6 +2547,45 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i public static List GetPortalTabs(List tabs, int excludeTabId, bool includeNoneSpecified, string noneSpecifiedText, bool includeHidden, bool includeDeleted, bool includeURL, bool checkViewPermisison, bool checkEditPermission) + { + return GetPortalTabs( + tabs, + excludeTabId, + includeNoneSpecified, + noneSpecifiedText, + includeHidden, + includeDeleted, + includeURL, + checkViewPermisison, + checkEditPermission, + true); + } + + /// + /// Gets the portal tabs. + /// + /// The tabs. + /// The exclude tab id. + /// if set to true [include none specified]. + /// The none specified text. + /// if set to true [include hidden]. + /// if set to true [include deleted]. + /// if set to true [include URL]. + /// if set to true [check view permisison]. + /// if set to true [check edit permission]. + /// The value of this parameter affects property. + /// + public static List GetPortalTabs( + List tabs, + int excludeTabId, + bool includeNoneSpecified, + string noneSpecifiedText, + bool includeHidden, + bool includeDeleted, + bool includeURL, + bool checkViewPermisison, + bool checkEditPermission, + bool includeDeletedChildren) { var listTabs = new List(); if (includeNoneSpecified) @@ -2580,6 +2622,9 @@ public static List GetPortalTabs(List tabs, int excludeTabId, listTabs.Add(tab); } } + + // HasChildren should be true in case there is at least one not deleted child + tab.HasChildren = tab.HasChildren && (includeDeletedChildren || GetTabsByParent(tab.TabID, tab.PortalID).Any(a => !a.IsDeleted)); } } return listTabs;