# extendify/3.0.4/tests/Integration/Agent/Controllers/WPControllerTest.php

Extendify, version 3.0.4. 32 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.4/code/tests/Integration/Agent/Controllers/WPControllerTest.php
- Raw: https://pluginprobe.com/plugins/extendify/3.0.4/raw/tests/Integration/Agent/Controllers/WPControllerTest.php
- Modified: 2026-03-24T14:55:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.0.4/code/tests/Integration/Agent/Controllers/WPControllerTest.php#L10-L20`.

```php
<?php

namespace Extendify\Tests\Integration\Agent\Controllers;

use Extendify\Agent\Controllers\WPController;
use Extendify\Shared\Services\Import\Post;
use WP_UnitTestCase;

class WPControllerTest extends WP_UnitTestCase
{
    public function test_lock_post_prevents_importer_update()
    {
        $postId = self::factory()->post->create(['post_content' => '<p>original</p>']);
        $post = get_post($postId);

        $user = self::factory()->user->create();
        wp_set_current_user($user);

        $request = new \WP_REST_Request();
        $request->set_param('postId', $postId);
        WPController::lockPost($request);

        // Attempt to update as the cron user (no user).
        wp_set_current_user(0);
        $result = Post::update($post, '<p>imported content</p>');

        $this->assertWPError($result);
        $this->assertSame(1005, $result->get_error_code());
        $this->assertSame('<p>original</p>', get_post($postId)->post_content);
    }
}

```
