blob: 521aa8fc351bbaecb4847b5d8a9bc12cdc3f5729 (
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
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\CoreUpdater\Test\Unit;
use Piwik\Plugins\CoreUpdater\Model;
/**
* @group CoreUpdater
* @group ModelTest
* @group Unit
* @group Plugins
*/
class ModelTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Model
*/
private $model;
public function setUp()
{
parent::setUp();
$this->model = new Model();
}
public function test_getPluginsFromDirectoy_shouldReturnEmptyArray_IfNoPluginsExist()
{
$plugins = $this->model->getPluginsFromDirectoy(PIWIK_INCLUDE_PATH . '/config');
$this->assertEquals(array(), $plugins);
}
public function test_getPluginsFromDirectoy_shouldReturnAllDirectoriesWithinPlugins()
{
$plugins = $this->model->getPluginsFromDirectoy(PIWIK_INCLUDE_PATH);
$this->assertGreaterThan(40, count($plugins));
$this->assertContains('/plugins/API', $plugins);
$this->assertContains('/plugins/Actions', $plugins);
$this->assertContains('/plugins/Annotations', $plugins);
$this->assertNotContains('/plugins/.', $plugins);
$this->assertNotContains('/plugins/..', $plugins);
$this->assertNotContains('/plugins', $plugins);
$this->assertNotContains('/plugins/', $plugins);
foreach ($plugins as $plugin) {
$this->assertTrue(is_dir(PIWIK_INCLUDE_PATH . $plugin));
$this->assertStringStartsWith('/plugins/', $plugin);
$this->assertTrue(12 <= strlen($plugin)); // make sure it does not return something like '/plugins'.
}
}
}
|