Add ancestor endpoints and remove explicit parent context (#15746)
* Remove explicit parent context in API outputs * Add ancestor endpoints for document and data type (experimental for now) * Add ancestor endpoints for doctypes, media, mediatypes, partial views, scripts, static files, stylesheets and templates * Add unit tests for ancestor ID parsing * Add ancestor endpoint for dictionary items * Update OpenApi.json * Fix merge and regenerate OpenApi.json * Regenerate OpenApi.json * Rename "folder" to "parent" for consistency * Fix merge * Fix merge * Include "self" in ancestor endpoints * Handle ancestors for root items correctly * Remove "type" from recycle bin items * Tests against fixed values instead of calculated ones. --------- Co-authored-by: Sven Geusens <sge@umbraco.dk>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Extensions;
|
||||
using Umbraco.Cms.Core.Models.Entities;
|
||||
using Range = System.Range;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Extensions;
|
||||
|
||||
[TestFixture]
|
||||
public class TreeEntityExtensionsTests
|
||||
{
|
||||
[TestCase("-1,1234", new int[] { })]
|
||||
[TestCase("-1,1234,5678", new int[] { 1234 })]
|
||||
[TestCase("-1,1234,5678,9012", new int[] { 5678, 1234 })]
|
||||
[TestCase("-1,1234,5678,9012,2345", new int[] { 9012, 5678, 1234 })]
|
||||
public void Parse_Ancestor_Ids_Excludes_Root_And_Self(string path, int[] expectedIds)
|
||||
{
|
||||
var entityMock = new Mock<ITreeEntity>();
|
||||
entityMock.SetupGet(m => m.Path).Returns(path);
|
||||
|
||||
var result = entityMock.Object.AncestorIds();
|
||||
Assert.AreEqual(expectedIds.Length, result.Length);
|
||||
Assert.That(expectedIds, Is.EquivalentTo(result));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user