blob: 1cc42e0948d19334e2ad2c7d05137e75e32742a3 (
plain)
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
87
88
89
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Unit\Category;
use Piwik\Cache;
use Piwik\Category\Subcategory;
/**
* @group Category
* @group Subcategory
* @group SubcategoryTest
*/
class SubcategoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Subcategory
*/
private $subcategory;
public function setUp(): void
{
parent::setUp();
$this->subcategory = new Subcategory();
}
public function test_categoryId_set_get()
{
$this->subcategory->setCategoryId('testCategory');
$this->assertSame('testCategory', $this->subcategory->getCategoryId());
}
public function test_getCategoryId_shouldBeEmptyStringByDefault()
{
$this->assertSame('', $this->subcategory->getCategoryId());
}
public function test_name_set_get()
{
$this->subcategory->setName('testName');
$this->assertSame('testName', $this->subcategory->getName());
}
public function test_getName_shouldBeEmptyStringByDefault()
{
$this->assertSame('', $this->subcategory->getName());
}
public function test_getName_ShouldDefaultToId_IfNoNameIsSet()
{
$this->subcategory->setId('myTestId');
$this->assertSame('myTestId', $this->subcategory->getName());
$this->assertSame('myTestId', $this->subcategory->getId());
}
public function test_order_set_get()
{
$this->subcategory->setOrder(99);
$this->assertSame(99, $this->subcategory->getOrder());
$this->subcategory->setOrder('98');
$this->assertSame(98, $this->subcategory->getOrder());
}
public function test_getOrder_shouldReturnADefaultValue()
{
$this->assertSame(99, $this->subcategory->getOrder());
}
public function test_id_set_get()
{
$this->subcategory->setId('myCustomId');
$this->assertSame('myCustomId', $this->subcategory->getId());
}
public function test_getId_shouldBeEmptyStringByDefault()
{
$this->assertSame('', $this->subcategory->getId());
}
}
|