mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-10-19 01:03:12 -04:00
fix editing blog post
This commit is contained in:
@@ -29,11 +29,10 @@ class BlogTest extends TestCase {
|
||||
$manager = new Manager\Blog();
|
||||
$initial = $manager->headlines();
|
||||
$this->blog = $manager->create(
|
||||
title : 'phpunit blog',
|
||||
body : 'phpunit blog body',
|
||||
notify : false,
|
||||
thread : null,
|
||||
user : $this->userList[0],
|
||||
title: 'phpunit blog',
|
||||
body: 'phpunit blog body',
|
||||
thread: null,
|
||||
user: $this->userList[0],
|
||||
);
|
||||
$this->assertEquals(
|
||||
$this->blog->id,
|
||||
@@ -41,14 +40,11 @@ class BlogTest extends TestCase {
|
||||
'blog-find'
|
||||
);
|
||||
$this->assertEquals($this->blog->id, $manager->latestId(), 'blog-latest');
|
||||
$this->assertTrue(Helper::recentDate($this->blog->created()), 'blog-created-date');
|
||||
$this->assertTrue(Helper::recentEpoch($this->blog->createdEpoch()), 'blog-created-date');
|
||||
$this->assertEquals('phpunit blog body', $this->blog->body(), 'blog-body');
|
||||
$this->assertTrue(Helper::recentDate($this->blog->created()), 'blog-created-date');
|
||||
$this->assertLessThan(2, time() - $manager->latestEpoch(), 'blog-created-epoch');
|
||||
$this->assertLessThan(2, time() - $this->blog->createdEpoch(), 'blog-created-epoch');
|
||||
$this->assertFalse($this->blog->notify(), 'blog-no-notify');
|
||||
$this->assertEquals($this->blog->createdEpoch(), $manager->latestEpoch(), 'blog-created-epoch');
|
||||
$this->assertEquals('phpunit blog', $this->blog->title(), 'blog-title');
|
||||
$this->assertEquals(0, $this->blog->threadId(), 'blog-thread-id');
|
||||
$this->assertNull($this->blog->threadId(), 'blog-thread-id');
|
||||
$this->assertEquals($this->userList[0]->id, $this->blog->userId(), 'blog-userId');
|
||||
$this->assertEquals(
|
||||
"<a href=\"blog.php?id={$this->blog->id}#blog{$this->blog->id}\">phpunit blog</a>",
|
||||
@@ -66,50 +62,48 @@ class BlogTest extends TestCase {
|
||||
$find = $manager->findById($this->blog->id);
|
||||
$this->assertEquals($this->blog->id, $find?->id, 'blog-find');
|
||||
$this->assertEquals(
|
||||
(int)strtotime((string)$find?->created()),
|
||||
$find?->createdEpoch(),
|
||||
$manager->latestEpoch(),
|
||||
'blog-epoch'
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(Blog::class, $this->blog->flush(), 'blog-flush');
|
||||
$this->assertEquals(1, $this->blog->remove(), 'blog-remove');
|
||||
unset($this->blog);
|
||||
}
|
||||
|
||||
public function testBlogThread(): void {
|
||||
$title = 'blog ' . randomString(10);
|
||||
$manager = new Manager\Blog();
|
||||
$this->blog = $manager->create(
|
||||
title : $title,
|
||||
body : "$title body",
|
||||
notify : false,
|
||||
thread : new Manager\ForumThread()
|
||||
title: $title,
|
||||
body: "$title body",
|
||||
thread: new Manager\ForumThread()
|
||||
->create(
|
||||
new Forum(ANNOUNCEMENT_FORUM_ID),
|
||||
$this->userList[0],
|
||||
"thread $title title",
|
||||
"thread $title body",
|
||||
),
|
||||
user : $this->userList[0],
|
||||
user: $this->userList[0],
|
||||
);
|
||||
$this->assertFalse($this->blog->notify(), 'blog-no-notify');
|
||||
$this->assertEquals(
|
||||
"thread $title title",
|
||||
$this->blog->thread()?->title(),
|
||||
'blog-thread-title',
|
||||
);
|
||||
$this->assertEquals(1, $this->blog->removeThread(), 'blog-thread-detach');
|
||||
$this->assertEquals(1, $this->blog->remove(), 'blog-thread-remove');
|
||||
$this->assertTrue($this->blog->setField('id_thread', null)->modify(), 'blog-thread-remove');
|
||||
$this->assertEquals(1, $this->blog->remove(), 'blog-remove');
|
||||
unset($this->blog);
|
||||
}
|
||||
|
||||
public function testBlogWitness(): void {
|
||||
$manager = new Manager\Blog();
|
||||
$this->blog = $manager->create(
|
||||
title : 'phpunit blog witness',
|
||||
body : 'phpunit blog witness body',
|
||||
notify : false,
|
||||
thread : null,
|
||||
user : $this->userList[0],
|
||||
title: 'phpunit blog witness',
|
||||
body: 'phpunit blog witness body',
|
||||
thread: null,
|
||||
user: $this->userList[0],
|
||||
);
|
||||
|
||||
$witness = new WitnessTable\UserReadBlog();
|
||||
@@ -122,13 +116,11 @@ class BlogTest extends TestCase {
|
||||
$manager = new Manager\Blog();
|
||||
$title = 'phpunit blog notif';
|
||||
$this->blog = $manager->create(
|
||||
title : $title,
|
||||
body : 'phpunit blog notif body',
|
||||
thread : null,
|
||||
notify : true,
|
||||
user : $this->userList[0],
|
||||
title: $title,
|
||||
body: 'phpunit blog notif body',
|
||||
thread: null,
|
||||
user: $this->userList[0],
|
||||
);
|
||||
$this->assertTrue($this->blog->notify(), 'blog-notify');
|
||||
|
||||
$notifier = new User\Notification($this->userList[1]);
|
||||
// if this fails, the CI database has drifted (or another UT has clobbered the expected value here)
|
||||
|
||||
Reference in New Issue
Block a user