diff --git a/src/Umbraco.Tests/DocumentLookups/BaseTest.cs b/src/Umbraco.Tests/DocumentLookups/BaseTest.cs index 183c21d681..f6b959b095 100644 --- a/src/Umbraco.Tests/DocumentLookups/BaseTest.cs +++ b/src/Umbraco.Tests/DocumentLookups/BaseTest.cs @@ -89,11 +89,18 @@ namespace Umbraco.Tests.DocumentLookups ]> - - - + + + + + + + + + - + + diff --git a/src/Umbraco.Tests/DocumentLookups/LookupByAliasTests.cs b/src/Umbraco.Tests/DocumentLookups/LookupByAliasTests.cs new file mode 100644 index 0000000000..bd59149efc --- /dev/null +++ b/src/Umbraco.Tests/DocumentLookups/LookupByAliasTests.cs @@ -0,0 +1,33 @@ +using System.Configuration; +using NUnit.Framework; +using Umbraco.Web.Routing; +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic.template; + +namespace Umbraco.Tests.DocumentLookups +{ + [TestFixture] + public class LookupByAliasTests : BaseTest + { + [TestCase("/this/is/my/alias", 1046)] + [TestCase("/anotheralias", 1046)] + [TestCase("/page2/alias", 1173)] + [TestCase("/2ndpagealias", 1173)] + [TestCase("/only/one/alias", 1174)] + [TestCase("/ONLY/one/Alias", 1174)] + public void Lookup_By_Url_Alias(string urlAsString, int nodeMatch) + { + var template = Template.MakeNew("test", new User(0)); + var routingContext = GetRoutingContext(urlAsString, template); + var url = routingContext.UmbracoContext.UmbracoUrl; //very important to use the cleaned up umbraco url + var docRequest = new DocumentRequest(url, routingContext); + var lookup = new LookupByAlias(); + Umbraco.Core.Configuration.GlobalSettings.HttpContext = routingContext.UmbracoContext.HttpContext; + + var result = lookup.TrySetDocument(docRequest); + + Assert.IsTrue(result); + Assert.AreEqual(docRequest.NodeId, nodeMatch); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs b/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs index 47e49801ed..2ca7856754 100644 --- a/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs +++ b/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs @@ -7,12 +7,6 @@ using umbraco.cms.businesslogic.template; namespace Umbraco.Tests.DocumentLookups { - [TestFixture] - public class LookupByAliasTests : BaseTest - { - - } - [TestFixture] public class LookupByNiceUrlTests : BaseTest { diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index c29112cbba..e8b99d7221 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -61,6 +61,7 @@ + diff --git a/src/Umbraco.Web/Routing/LookupByAlias.cs b/src/Umbraco.Web/Routing/LookupByAlias.cs index ab15ab9df0..39fd43d43e 100644 --- a/src/Umbraco.Web/Routing/LookupByAlias.cs +++ b/src/Umbraco.Web/Routing/LookupByAlias.cs @@ -34,9 +34,9 @@ namespace Umbraco.Web.Routing docRequest.Uri.AbsolutePath); if (node != null) - { - LogHelper.Debug("Path \"{0}\" is an alias for id={1}", () => docRequest.Uri.AbsolutePath, () => docRequest.NodeId); + { docRequest.Node = node; + LogHelper.Debug("Path \"{0}\" is an alias for id={1}", () => docRequest.Uri.AbsolutePath, () => docRequest.NodeId); } }