-
Notifications
You must be signed in to change notification settings - Fork 14
/
SitemapsControllerTest.php
106 lines (92 loc) · 2.1 KB
/
SitemapsControllerTest.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* Test class for Sitemap\SitemapsController Class
*/
namespace Sitemap\Test\TestCase\Controller;
use Cake\Core\Configure;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\IntegrationTestCase;
use Sitemap\Controller\SitemapsController;
/**
* \Sitemap\Test\TestCase\Controller\SitemapsControllerTestCase
*/
class SitemapsControllerTestCase extends IntegrationTestCase {
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'plugin.sitemap.pages',
];
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->Pages = TableRegistry::get('Pages');
$sitemapConfig = [];
$this->Pages->addBehavior('Sitemap.Sitemap', $sitemapConfig);
$this->setupSession();
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->Pages);
parent::tearDown();
}
/**
* setup Session properties needed for the controller level tests
*
* @return void
*/
public function setupSession() {
$this->session([]);
}
/**
* Test index method with no models defined
*
* @return void
* @covers \Sitemap\Controller\SitemapsController::index
*/
public function testIndexNoModels() {
$Controller = $this->getMock(
'\Sitemap\Controller\SitemapsController',
['set']
);
$Controller->expects($this->once())
->method('set')
->with('data', [])
->will($this->returnValue(true));
$Controller->index();
}
/**
* Test index method with no models defined
*
* @return void
* @covers \Sitemap\Controller\SitemapsController::index
*/
public function testIndexWithModels() {
Configure::write('Sitemap.tables', ['Pages']);
$pagesFindQuery = $this->Pages->find('forSitemap');
$Controller = $this->getMock(
'\Sitemap\Controller\SitemapsController',
['set', 'loadModel']
);
$Controller->expects($this->once())
->method('set')
->with('data', ['Pages' => $pagesFindQuery])
->will($this->returnValue(true));
$Controller->expects($this->once())
->method('loadModel')
->with('Pages')
->will($this->returnValue(true));
$Controller->Pages = $this->Pages;
$Controller->index();
}
}