-
-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathMODxControllerTestCase.php
66 lines (60 loc) · 2.04 KB
/
MODxControllerTestCase.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
<?php
/*
* This file is part of the MODX Revolution package.
*
* Copyright (c) MODX, LLC
*
* For complete copyright and license information, see the COPYRIGHT and LICENSE
* files found in the top-level directory of this distribution.
*
* @package modx-test
*/
/**
* Abstract class extending MODxTestCase for controller-specific testing
*
* @package modx-test
* @subpackage modx
*/
abstract class MODxControllerTestCase extends MODxTestCase {
/** @var modManagerController $controller */
public $controller;
/**
* The short path to the controller, ie, "context/update"
* @var string $controllerPath
*/
public $controllerPath;
/**
* The name of the controller class to load, ie, "ContextUpdateManagerController"
* @var string $controllerName
*/
public $controllerName;
public function setUp(): void
{
parent::setUp();
/* load smarty template engine */
$templatePath = $this->modx->getOption('manager_path') . 'templates/default/';
$this->modx->getService('smarty', 'smarty.modSmarty', '', array(
'template_dir' => $templatePath,
));
$this->modx->smarty->setCachePath('mgr/smarty/default/');
$this->modx->smarty->assign('_config',$this->modx->config);
$this->modx->smarty->assignByRef('modx',$this->modx);
$this->modx->loadClass('modManagerController',MODX_CORE_PATH.'model/modx/',true,true);
require_once MODX_MANAGER_PATH.'controllers/default/'.$this->controllerPath.'.class.php';
$className = $this->controllerName;
if (!empty($className)) {
$this->controller = new $className($this->modx,array(
'namespace' => 'core',
'namespace_name' => 'core',
'namespace_path' => MODX_MANAGER_PATH,
'controller' => $this->controllerPath,
));
$this->controller->setProperties($_REQUEST);
}
}
public function tearDown(): void
{
parent::tearDown();
$this->controller = null;
}
}