-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathTagsTest.php
More file actions
76 lines (64 loc) · 1.86 KB
/
TagsTest.php
File metadata and controls
76 lines (64 loc) · 1.86 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
<?php
/**
* This file is part of the Cloudinary PHP package.
*
* (c) Cloudinary
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cloudinary\Test\Integration\Admin;
use Cloudinary\Api\Exception\ApiError;
use Cloudinary\Test\Integration\IntegrationTestCase;
use PHPUnit\Framework\Constraint\IsType;
/**
* Class TagsTest
*/
final class TagsTest extends IntegrationTestCase
{
private static $PREFIX_TAG;
private static $TAG_WITH_PREFIX;
/**
* @throws ApiError
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::$PREFIX_TAG = 'tags_prefix_tag_' . self::$UNIQUE_TEST_TAG;
self::$TAG_WITH_PREFIX = self::$PREFIX_TAG . self::$UNIQUE_TEST_TAG;
self::createTestAssets(
[
[
'options' => ['tags' => [self::$TAG_WITH_PREFIX]],
],
]
);
}
public static function tearDownAfterClass()
{
self::cleanupTestAssets();
parent::tearDownAfterClass();
}
/**
* List tags of images
*
* @throws ApiError
*/
public function testListTagsOfImages()
{
$result = self::$adminApi->tags(['max_results' => 2]);
self::assertObjectStructure($result, ['tags' => IsType::TYPE_ARRAY]);
self::assertCount(2, $result['tags']);
self::assertIsString($result['tags'][0]);
}
/**
* List all tags with a given prefix
*/
public function testListTagsWithPrefix()
{
$result = self::$adminApi->tags(['prefix' => self::$PREFIX_TAG]);
self::assertObjectStructure($result, ['tags' => IsType::TYPE_ARRAY]);
self::assertCount(1, $result['tags']);
self::assertContains(self::$TAG_WITH_PREFIX, $result['tags']);
}
}