-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathContentTest.php
More file actions
86 lines (75 loc) · 2.23 KB
/
Copy pathContentTest.php
File metadata and controls
86 lines (75 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
/**
* This file is part of the cloudplaydev/confluencePHPClient.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CloudPlayDev\Tests\ConfluenceClient\Entity;
use CloudPlayDev\ConfluenceClient\Entity\AbstractContent;
use CloudPlayDev\ConfluenceClient\Entity\ContentAttachment;
use CloudPlayDev\ConfluenceClient\Entity\ContentPage;
use CloudPlayDev\ConfluenceClient\Entity\ContentSearchResult;
use CloudPlayDev\ConfluenceClient\Exception\HydrationException;
use PHPUnit\Framework\TestCase;
/**
* Class ConfluencePageModelTest
*/
class ContentTest extends TestCase
{
/**
* Test get space
*/
public function testGetSpace(): void
{
$confluencePage = new ContentPage();
self::assertNull($confluencePage->getSpace());
}
/**
* Test set space
*/
public function testSetSpace(): void
{
$confluencePage = new ContentPage();
$confluencePage->setSpace('TEST');
static::assertSame('TEST', $confluencePage->getSpace());
}
/**
* Test set id
*/
public function testSetId(): void
{
$confluencePage = new ContentPage();
$confluencePage->setId(123);
self::assertSame(123, $confluencePage->getId());
}
public function testLoadAttachment(): void
{
$attachment = AbstractContent::load(self::attachmentPayload());
self::assertInstanceOf(ContentAttachment::class, $attachment);
self::assertSame('attachment', $attachment->getType());
}
public function testSearchResultLoadsAttachment(): void
{
$searchResult = ContentSearchResult::load([
'size' => 1,
'results' => [self::attachmentPayload()],
]);
self::assertInstanceOf(ContentAttachment::class, $searchResult->getResultAt(0));
}
/**
* @return mixed[]
*/
private static function attachmentPayload(): array
{
return [
'id' => '123456',
'type' => 'attachment',
'title' => 'example.pdf',
'_links' => [
'self' => 'https://example.test/rest/api/content/123456',
],
];
}
}