test: FakeChangeLog and SchemaFixture instead of repeated mocks (T2)
- tests/Support/FakeChangeLog extends ChangeLog: records record()/recordPartial() calls, increasing ids, optional failure; new FakeChangeLog(id) / partialsOnly() / any(id) / forbidden() mirror what the replaced mocks allowed. assertRecorded() / assertPartials() check count and the named arguments. Calls a fake does not allow throw and are also verified in TestCase::tearDown (one assertion per test that uses a fake), so swallowed change-log calls still fail like a never() expectation. - All ChangeLog mocks of ability/integration tests replaced (the admin tests that stub query/purge/clear keep their mocks); expectException tests that checked the partial log now catch and assert. - SchemaFixture::managed(?divi) replaces the 21 isManaged-only ContentSchema mocks; DiviFixtures::schema() uses it. Tests 1397 -> 1404 (FakeChangeLogTest); no test has fewer assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,10 +5,9 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\WordPress\Menus;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuAssignLocationAbility;
|
||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
|
||||
final class MenuAssignLocationAbilityTest extends TestCase
|
||||
{
|
||||
@@ -29,28 +28,26 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
public function testAssignsAndReportsThePreviousMenu(): void
|
||||
{
|
||||
Functions\expect('set_theme_mod')->once()->with('nav_menu_locations', ['primary-menu' => 8]);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('record')
|
||||
->with(
|
||||
'lit/menu-assign-location',
|
||||
'menu_location',
|
||||
'primary-menu',
|
||||
'Menü 8 der Position primary-menu zugewiesen'
|
||||
)
|
||||
->andReturn(6);
|
||||
$log = new FakeChangeLog(6);
|
||||
|
||||
$result = (new MenuAssignLocationAbility($log))->execute(['location' => 'primary-menu', 'menu_id' => 8]);
|
||||
|
||||
self::assertSame(3, $result['previous_menu_id']);
|
||||
self::assertSame('assigned', $result['changed'][0]['action']);
|
||||
self::assertSame(6, $result['log_id']);
|
||||
$log->assertRecorded([
|
||||
'ability' => 'lit/menu-assign-location',
|
||||
'object_type' => 'menu_location',
|
||||
'object_id' => 'primary-menu',
|
||||
'summary' => 'Menü 8 der Position primary-menu zugewiesen',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testRemovingAnAssignmentNeedsConfirmation(): void
|
||||
{
|
||||
Functions\expect('set_theme_mod')->never();
|
||||
|
||||
$result = (new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class)))
|
||||
$result = (new MenuAssignLocationAbility(FakeChangeLog::forbidden()))
|
||||
->execute(['location' => 'primary-menu', 'menu_id' => 0]);
|
||||
|
||||
self::assertSame('lit_confirm_required', $result->get_error_code());
|
||||
@@ -63,15 +60,7 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
public function testZeroRemovesTheAssignmentAndNamesTheRemovedMenu(): void
|
||||
{
|
||||
Functions\expect('set_theme_mod')->once()->with('nav_menu_locations', []);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('record')
|
||||
->with(
|
||||
'lit/menu-assign-location',
|
||||
'menu_location',
|
||||
'primary-menu',
|
||||
'Menü "Hauptmenü" (ID 3) von der Position primary-menu entfernt'
|
||||
)
|
||||
->andReturn(7);
|
||||
$log = new FakeChangeLog(7);
|
||||
|
||||
$result = (new MenuAssignLocationAbility($log))
|
||||
->execute(['location' => 'primary-menu', 'menu_id' => 0, 'confirm' => true]);
|
||||
@@ -80,14 +69,19 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
self::assertSame(3, $result['previous_menu_id']);
|
||||
self::assertStringContainsString('"Hauptmenü" (ID 3)', $result['summary']);
|
||||
self::assertSame(7, $result['log_id']);
|
||||
$log->assertRecorded([
|
||||
'ability' => 'lit/menu-assign-location',
|
||||
'object_type' => 'menu_location',
|
||||
'object_id' => 'primary-menu',
|
||||
'summary' => 'Menü "Hauptmenü" (ID 3) von der Position primary-menu entfernt',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testRemovingFromAnEmptyLocationNeedsNoConfirmation(): void
|
||||
{
|
||||
Functions\when('get_nav_menu_locations')->justReturn([]);
|
||||
Functions\expect('set_theme_mod')->once()->with('nav_menu_locations', []);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->allows('record')->andReturn(8);
|
||||
$log = new FakeChangeLog(8);
|
||||
|
||||
$result = (new MenuAssignLocationAbility($log))->execute(['location' => 'primary-menu', 'menu_id' => 0]);
|
||||
|
||||
@@ -97,7 +91,7 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
|
||||
public function testDescribesTheConfirmationForRemoval(): void
|
||||
{
|
||||
$ability = new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuAssignLocationAbility(FakeChangeLog::forbidden());
|
||||
|
||||
self::assertArrayHasKey('confirm', $ability->inputSchema()['properties']);
|
||||
self::assertStringContainsString('confirm: true', $ability->description());
|
||||
@@ -107,7 +101,7 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
{
|
||||
Functions\expect('set_theme_mod')->never();
|
||||
|
||||
$result = (new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class)))
|
||||
$result = (new MenuAssignLocationAbility(FakeChangeLog::forbidden()))
|
||||
->execute(['location' => 'primary-menu', 'menu_id' => 99]);
|
||||
|
||||
self::assertSame('lit_not_found', $result->get_error_code());
|
||||
@@ -117,7 +111,7 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
{
|
||||
Functions\when('current_user_can')->justReturn(false);
|
||||
|
||||
$ability = new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuAssignLocationAbility(FakeChangeLog::forbidden());
|
||||
$input = ['location' => 'primary-menu', 'menu_id' => 8];
|
||||
|
||||
self::assertSame('lit_forbidden', $ability->permission($input)->get_error_code());
|
||||
@@ -125,7 +119,7 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
||||
|
||||
public function testIsDestructiveBecauseItReplacesTheMenuOfTheLocation(): void
|
||||
{
|
||||
$ability = new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuAssignLocationAbility(FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame(['readonly' => false, 'destructive' => true, 'idempotent' => true], $ability->annotations());
|
||||
}
|
||||
|
||||
@@ -5,10 +5,9 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\WordPress\Menus;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuCreateAbility;
|
||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
use WP_Error;
|
||||
|
||||
final class MenuCreateAbilityTest extends TestCase
|
||||
@@ -18,7 +17,7 @@ final class MenuCreateAbilityTest extends TestCase
|
||||
Functions\when('get_registered_nav_menus')->justReturn(['primary-menu' => 'Hauptmenü']);
|
||||
Functions\expect('wp_create_nav_menu')->never();
|
||||
|
||||
$ability = new MenuCreateAbility(Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuCreateAbility(FakeChangeLog::forbidden());
|
||||
$result = $ability->execute(['name' => 'Neu', 'location' => 'nope']);
|
||||
|
||||
self::assertSame('lit_validation_failed', $result->get_error_code());
|
||||
@@ -31,7 +30,7 @@ final class MenuCreateAbilityTest extends TestCase
|
||||
new WP_Error('menu_exists', 'Der Menüname existiert bereits.')
|
||||
);
|
||||
|
||||
$result = (new MenuCreateAbility(Mockery::mock(ChangeLog::class)))->execute(['name' => 'Hauptmenü']);
|
||||
$result = (new MenuCreateAbility(FakeChangeLog::forbidden()))->execute(['name' => 'Hauptmenü']);
|
||||
|
||||
self::assertSame('lit_validation_failed', $result->get_error_code());
|
||||
}
|
||||
@@ -45,23 +44,26 @@ final class MenuCreateAbilityTest extends TestCase
|
||||
'nav_menu_locations',
|
||||
['footer-menu' => 2, 'primary-menu' => 8]
|
||||
);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('record')
|
||||
->with('lit/menu-create', 'nav_menu', '8', 'Menü "Neu" angelegt (Position primary-menu)')
|
||||
->andReturn(5);
|
||||
$log = new FakeChangeLog(5);
|
||||
|
||||
$result = (new MenuCreateAbility($log))->execute(['name' => 'Neu', 'location' => 'primary-menu']);
|
||||
|
||||
self::assertSame(8, $result['menu_id']);
|
||||
self::assertSame('created', $result['changed'][0]['action']);
|
||||
self::assertSame(5, $result['log_id']);
|
||||
$log->assertRecorded([
|
||||
'ability' => 'lit/menu-create',
|
||||
'object_type' => 'nav_menu',
|
||||
'object_id' => '8',
|
||||
'summary' => 'Menü "Neu" angelegt (Position primary-menu)',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testPermissionNeedsThemeOptionRights(): void
|
||||
{
|
||||
Functions\when('current_user_can')->justReturn(false);
|
||||
|
||||
$ability = new MenuCreateAbility(Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuCreateAbility(FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame('lit_forbidden', $ability->permission(['name' => 'Neu'])->get_error_code());
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace LIT\MCP\Tests\Unit\Integrations\WordPress\Menus;
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuOperations;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuSetItemsAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuTree;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuWriter;
|
||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
use RuntimeException;
|
||||
@@ -37,7 +37,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
{
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->expects('apply')->never();
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$stale = $ability->execute(['menu_id' => 3, 'menu_rev' => 'abcdefabcdef', 'items' => [['id' => 10]]]);
|
||||
$missing = $ability->execute(['menu_id' => 3, 'items' => [['id' => 10]]]);
|
||||
@@ -55,8 +55,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->allows('plan')->andReturn(['errors' => [], 'removals' => [], 'warnings' => []]);
|
||||
$writer->allows('apply')->andReturn(['created' => 0, 'updated' => 1, 'removed' => 0]);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->allows('record')->andReturn(30);
|
||||
$log = new FakeChangeLog(30);
|
||||
|
||||
$result = (new MenuSetItemsAbility($writer, new MenuOperations(), $log))->execute(
|
||||
['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => [['id' => 10]]]
|
||||
@@ -67,7 +66,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
|
||||
public function testItemsAndOperationsAreMutuallyExclusive(): void
|
||||
{
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame('lit_validation_failed', $ability->execute(['menu_id' => 3, 'menu_rev' => self::rev()])->get_error_code());
|
||||
self::assertSame(
|
||||
@@ -80,7 +79,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
public function testUnknownMenuIsNotFound(): void
|
||||
{
|
||||
Functions\when('wp_get_nav_menu_object')->justReturn(false);
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame('lit_not_found', $ability->execute(['menu_id' => 9, 'items' => []])->get_error_code());
|
||||
}
|
||||
@@ -89,7 +88,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
{
|
||||
Functions\expect('wp_update_nav_menu_item')->never();
|
||||
Functions\expect('wp_delete_post')->never();
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$result = $ability->execute(['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => []]);
|
||||
|
||||
@@ -102,7 +101,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
Functions\when('wp_parse_url')->alias('parse_url');
|
||||
Functions\expect('wp_update_nav_menu_item')->never();
|
||||
Functions\expect('wp_delete_post')->never();
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$result = $ability->execute([
|
||||
'menu_id' => 3, 'menu_rev' => self::rev(),
|
||||
@@ -118,7 +117,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
{
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->expects('apply')->never();
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$result = $ability->execute(['menu_id' => 3, 'menu_rev' => self::rev(), 'operations' => [['op' => 'move', 'id' => 99]]]);
|
||||
|
||||
@@ -130,8 +129,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->allows('plan')->andReturn(['errors' => [], 'removals' => [], 'warnings' => []]);
|
||||
$writer->expects('apply')->andReturn(['created' => 1, 'updated' => 1, 'removed' => 0]);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('record')->with('lit/menu-set-items', 'nav_menu', '3', Mockery::type('string'))->andReturn(21);
|
||||
$log = new FakeChangeLog(21);
|
||||
|
||||
$result = (new MenuSetItemsAbility($writer, new MenuOperations(), $log))->execute([
|
||||
'menu_id' => 3, 'menu_rev' => self::rev(),
|
||||
@@ -141,6 +139,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
self::assertSame('Home', $result['previous_items'][0]['title']);
|
||||
self::assertSame(21, $result['log_id']);
|
||||
self::assertStringContainsString('1 neu, 1 geändert, 0 entfernt', $result['summary']);
|
||||
$log->assertRecorded(['ability' => 'lit/menu-set-items', 'object_type' => 'nav_menu', 'object_id' => '3']);
|
||||
}
|
||||
|
||||
public function testConfirmedRemovalsAreWrittenAndTheOldTreeIsReturned(): void
|
||||
@@ -151,8 +150,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
);
|
||||
$writer->expects('apply')->with(3, [], Mockery::type('array'))
|
||||
->andReturn(['created' => 0, 'updated' => 0, 'removed' => 1]);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->allows('record')->andReturn(22);
|
||||
$log = new FakeChangeLog(22);
|
||||
|
||||
$result = (new MenuSetItemsAbility($writer, new MenuOperations(), $log))->execute(
|
||||
['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => [], 'confirm' => true]
|
||||
@@ -169,8 +167,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
Functions\when('wp_get_nav_menu_items')->justReturn($items);
|
||||
Functions\expect('wp_delete_post')->never();
|
||||
Functions\expect('wp_update_nav_menu_item')->never();
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('record')->never();
|
||||
$log = FakeChangeLog::forbidden();
|
||||
|
||||
$result = (new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), $log))->execute(
|
||||
['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => MenuTree::build($items)]
|
||||
@@ -187,7 +184,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->expects('plan')->with(Mockery::type('array'), Mockery::type('array'), true)
|
||||
->andReturn(['errors' => ['items.0' => 'x'], 'removals' => [], 'warnings' => []]);
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$result = $ability->execute(
|
||||
['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => [['type' => 'post', 'object_id' => 7]], 'allow_unpublished' => true]
|
||||
@@ -205,8 +202,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
);
|
||||
Functions\when('get_post_type')->justReturn('page');
|
||||
Functions\expect('wp_update_nav_menu_item')->once()->andReturn(60);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->allows('record')->andReturn(24);
|
||||
$log = new FakeChangeLog(24);
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), $log);
|
||||
$input = ['menu_id' => 3, 'menu_rev' => self::rev(), 'operations' => [['op' => 'add', 'item' => ['type' => 'post', 'object_id' => 7]]]];
|
||||
|
||||
@@ -226,7 +222,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
new \WP_Post(['ID' => 7, 'post_type' => 'page', 'post_status' => 'private', 'post_title' => 'Intern'])
|
||||
);
|
||||
Functions\expect('wp_update_nav_menu_item')->never();
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
$result = $ability->execute([
|
||||
'menu_id' => 3, 'menu_rev' => self::rev(),
|
||||
@@ -243,8 +239,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->allows('plan')->andReturn(['errors' => [], 'removals' => [], 'warnings' => []]);
|
||||
$writer->expects('apply')->andThrow(WriteFailed::rolledBack('Menü nicht gespeichert.'));
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->shouldNotReceive('recordPartial');
|
||||
$log = FakeChangeLog::forbidden();
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), $log);
|
||||
|
||||
$this->expectException(WriteFailed::class);
|
||||
@@ -256,12 +251,16 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->allows('plan')->andReturn(['errors' => [], 'removals' => [], 'warnings' => []]);
|
||||
$writer->expects('apply')->andThrow(WriteFailed::partial('Menü nicht gespeichert.'));
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('recordPartial')->with('lit/menu-set-items', 'nav_menu', '3', Mockery::type('string'));
|
||||
$log = FakeChangeLog::partialsOnly();
|
||||
$ability = new MenuSetItemsAbility($writer, new MenuOperations(), $log);
|
||||
|
||||
$this->expectException(WriteFailed::class);
|
||||
$ability->execute(['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => [['id' => 10]]]);
|
||||
try {
|
||||
$ability->execute(['menu_id' => 3, 'menu_rev' => self::rev(), 'items' => [['id' => 10]]]);
|
||||
self::fail('WriteFailed expected');
|
||||
} catch (WriteFailed $e) {
|
||||
self::assertFalse($e->rolledBack);
|
||||
}
|
||||
$log->assertPartials(['ability' => 'lit/menu-set-items', 'object_type' => 'nav_menu', 'object_id' => '3']);
|
||||
}
|
||||
|
||||
public function testAChangeLogFailureIsOnlyAWarning(): void
|
||||
@@ -269,8 +268,7 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
$writer = Mockery::mock(MenuWriter::class);
|
||||
$writer->allows('plan')->andReturn(['errors' => [], 'removals' => [], 'warnings' => ['"X" ist nicht veröffentlicht']]);
|
||||
$writer->allows('apply')->andReturn(['created' => 0, 'updated' => 1, 'removed' => 0]);
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->allows('record')->andThrow(new RuntimeException('db down'));
|
||||
$log = new FakeChangeLog(1, new RuntimeException('db down'));
|
||||
$file = (string) tempnam(sys_get_temp_dir(), 'lit');
|
||||
$errorLog = ini_set('error_log', $file);
|
||||
|
||||
@@ -290,14 +288,14 @@ final class MenuSetItemsAbilityTest extends TestCase
|
||||
public function testPermissionNeedsThemeOptionRights(): void
|
||||
{
|
||||
Functions\when('current_user_can')->justReturn(false);
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame('lit_forbidden', $ability->permission(['menu_id' => 3, 'menu_rev' => self::rev()])->get_error_code());
|
||||
}
|
||||
|
||||
public function testIsDestructiveAndDescribesWhenConfirmIsNeeded(): void
|
||||
{
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), Mockery::mock(ChangeLog::class));
|
||||
$ability = new MenuSetItemsAbility(new MenuWriter(), new MenuOperations(), FakeChangeLog::forbidden());
|
||||
|
||||
self::assertSame(['readonly' => false, 'destructive' => true, 'idempotent' => false], $ability->annotations());
|
||||
self::assertStringContainsString('confirm: true', $ability->description());
|
||||
|
||||
Reference in New Issue
Block a user