* Add content and media sorting to the Management API * Rename "id" to "key" throughout the ContentEditingService * Update Open API json file * Use "key" instead of "id" in ContentEditingServiceBase * Use "key" instead of "id" in IMediaEditingService and MediaEditingService * Turn delegates into abstracts + fix bug that allowed deleting items outside of the recycle bin * Use PUT instead of POST * Update src/Umbraco.Core/Services/MediaEditingService.cs Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * Update src/Umbraco.Core/Services/MediaEditingService.cs Co-authored-by: Bjarke Berg <mail@bergmania.dk> * Update Open API JSON --------- Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Co-authored-by: Bjarke Berg <mail@bergmania.dk>
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
|
|
|
public partial class ContentEditingServiceTests
|
|
{
|
|
[TestCase(true)]
|
|
[TestCase(false)]
|
|
public async Task Can_Move_To_Recycle_Bin(bool variant)
|
|
{
|
|
var content = await (variant ? CreateVariantContent() : CreateInvariantContent());
|
|
var result = await ContentEditingService.MoveToRecycleBinAsync(content.Key, Constants.Security.SuperUserKey);
|
|
|
|
Assert.IsTrue(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
|
|
|
// re-get and verify move
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
|
Assert.IsNotNull(content);
|
|
Assert.IsTrue(content.Trashed);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Cannot_Move_Non_Existing_To_Recycle_Bin()
|
|
{
|
|
var result = await ContentEditingService.DeleteAsync(Guid.NewGuid(), Constants.Security.SuperUserKey);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.NotFound, result.Status);
|
|
}
|
|
|
|
[TestCase(true)]
|
|
[TestCase(false)]
|
|
public async Task Cannot_Move_To_Recycle_Bin_If_Already_In_Recycle_Bin(bool variant)
|
|
{
|
|
var content = await (variant ? CreateVariantContent() : CreateInvariantContent());
|
|
await ContentEditingService.MoveToRecycleBinAsync(content.Key, Constants.Security.SuperUserKey);
|
|
var result = await ContentEditingService.MoveToRecycleBinAsync(content.Key, Constants.Security.SuperUserKey);
|
|
|
|
Assert.IsFalse(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.InTrash, result.Status);
|
|
|
|
// re-get and verify that it still is in the recycle bin
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
|
Assert.IsNotNull(content);
|
|
Assert.IsTrue(content.Trashed);
|
|
}
|
|
}
|