| 1 |
<?php |
| 2 |
|
| 3 |
namespace Extendify\Tests\Integration\Shared\Services\Import; |
| 4 |
|
| 5 |
use Extendify\Shared\Services\Import\Post; |
| 6 |
use WP_UnitTestCase; |
| 7 |
|
| 8 |
class PostTest extends WP_UnitTestCase |
| 9 |
{ |
| 10 |
public function test_is_locked_returns_true_when_lock_is_fresh() |
| 11 |
{ |
| 12 |
$postId = self::factory()->post->create(); |
| 13 |
update_post_meta($postId, '_edit_lock', time() . ':1'); |
| 14 |
|
| 15 |
$this->assertTrue(Post::isLocked($postId)); |
| 16 |
} |
| 17 |
|
| 18 |
public function test_is_locked_returns_false_when_lock_is_expired() |
| 19 |
{ |
| 20 |
$postId = self::factory()->post->create(); |
| 21 |
// Set a lock that expired 200s ago (window is 150s). |
| 22 |
update_post_meta($postId, '_edit_lock', (time() - 200) . ':1'); |
| 23 |
|
| 24 |
$this->assertFalse(Post::isLocked($postId)); |
| 25 |
} |
| 26 |
|
| 27 |
public function test_is_locked_returns_false_when_no_lock() |
| 28 |
{ |
| 29 |
$postId = self::factory()->post->create(); |
| 30 |
|
| 31 |
$this->assertFalse(Post::isLocked($postId)); |
| 32 |
} |
| 33 |
} |
| 34 |
|