blob: 981fbbb00d3057aa89a1747fd114bd106d6aca70 (
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
/**
* Piwik - 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\Integration\Plugin;
use Piwik\Category\Category;
use Piwik\Category\Subcategory;
use Piwik\Container\StaticContainer;
use Piwik\Plugin\Categories;
use Piwik\Settings\Storage;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group Categories
* @group CategoriesTest
*/
class CategoriesTest extends IntegrationTestCase
{
/**
* @var Categories
*/
private $categories;
public function setUp(): void
{
parent::setUp();
$_GET['idSite'] = 1;
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2015-01-01 00:00:00');
}
$this->categories = new Categories(StaticContainer::get('Piwik\Plugin\Manager'));
}
public function tearDown(): void
{
parent::tearDown();
unset($_GET['idSite']);
}
public function test_getAllCategories_shouldOnlyFindCategories()
{
$categories = $this->categories->getAllCategories();
$this->assertGreaterThanOrEqual(4, count($categories));
foreach ($categories as $category) {
$this->assertTrue($category instanceof Category);
}
}
public function test_getAllCategories_shouldHaveACategoryIdDefined()
{
$categories = $this->categories->getAllCategories();
foreach ($categories as $category) {
$this->assertNotEmpty($category->getId());
}
}
public function test_getAllSubcategories_shouldOnlyFindSubcategories()
{
$subcategories = $this->categories->getAllSubcategories();
$this->assertGreaterThanOrEqual(10, count($subcategories));
foreach ($subcategories as $subcategory) {
$this->assertTrue($subcategory instanceof Subcategory);
$this->assertNotEmpty($subcategory->getId());
}
}
public function test_getAllSubcategories_shouldHaveACategoryIdAndSubcategoryIdDefined()
{
$subcategories = $this->categories->getAllSubcategories();
foreach ($subcategories as $subcategory) {
$this->assertNotEmpty($subcategory->getId());
$this->assertNotEmpty($subcategory->getCategoryId());
}
}
}
|