public static function tearDownAfterClass() { /** @var modX $modx */ $modx =& MODxTestHarness::getFixture('modX', 'modx'); $modx->getService('registry', 'registry.modRegistry'); $modx->registry->removeRegister('register'); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $snippet = $modx->getObject('modSnippet',array('name' => 'UnitTestSnippet')); if ($snippet) $snippet->remove(); $snippet = $modx->getObject('modSnippet',array('name' => 'UnitTestSnippet2')); if ($snippet) $snippet->remove(); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $category = $modx->getObject('modCategory',array('category' => 'UnitTestCategory')); if ($category) $category->remove(); $category = $modx->getObject('modCategory',array('category' => 'UnitTestCategory2')); if ($category) $category->remove(); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $tv = $modx->getObject('modTemplateVar',array('name' => 'UnitTestTv')); if ($tv) $tv->remove(); $tv = $modx->getObject('modTemplateVar',array('name' => 'UnitTestTv2')); if ($tv) $tv->remove(); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $namespace = $modx->getObject('modNamespace',array('name' => 'unittest')); $namespace->remove(); $modx->removeCollection('modAction',array('namespace' => 'unittest')); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $template = $modx->getObject('modTemplate',array('templatename' => 'UnitTestTemplate')); if ($template) $template->remove(); $template = $modx->getObject('modTemplate',array('templatename' => 'UnitTestTemplate2')); if ($template) $template->remove(); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $ctx = $modx->getObject('modContext', 'unittest'); if ($ctx) { $ctx->remove(); } }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $plugin = $modx->getObject('modPlugin',array('name' => 'UnitTestPlugin')); if ($plugin) $plugin->remove(); $plugin = $modx->getObject('modPlugin',array('name' => 'UnitTestPlugin2')); if ($plugin) $plugin->remove(); $plugin = $modx->getObject('modPlugin',array('name' => 'UnitTestPlugin3')); if ($plugin) $plugin->remove(); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx = MODxTestHarness::_getConnection(); $propertyset = $modx->getObject('modPropertySet',array('name' => 'UnitTestPropertySet')); if ($propertyset) $propertyset->remove(); $propertyset = $modx->getObject('modPropertySet',array('name' => 'UnitTestPropertySet2')); if ($propertyset) $propertyset->remove(); $propertyset = $modx->getObject('modPropertySet',array('name' => 'UnitTestPropertySet3')); if ($propertyset) $propertyset->remove(); }
public static function tearDownAfterClass() { if (!empty(self::$scope)) { $modx =& MODxTestHarness::getFixture('modX', 'modx'); if (array_key_exists('keys', self::$scope)) { $modx->unsetPlaceholder(self::$scope['keys']); } if (array_key_exists('restore', self::$scope)) { $modx->toPlaceholders(self::$scope['restore']); } } }
/** * Ensure all tests have a reference to the MODX object */ public function setUp() { $this->modx =& MODxTestHarness::getFixture('modX', 'modx'); if ($this->modx->request) { $this->modx->request->loadErrorHandler(); $this->modx->error->reset(); } /* setup some basic test-environment options to allow us to simulate a site */ $this->modx->setOption('http_host', 'unit.modx.com'); $this->modx->setOption('base_url', '/'); $this->modx->setOption('site_url', 'http://unit.modx.com/'); }
/** * Cleanup data after this test. */ public static function tearDownAfterClass() { $modx =& MODxTestHarness::_getConnection(); $chunk = $modx->getObject('modChunk',array('name' => 'UnitTestChunk')); if ($chunk) $chunk->remove(); $chunk = $modx->getObject('modChunk',array('name' => 'UnitTestChunk2')); if ($chunk) $chunk->remove(); $chunk = $modx->getObject('modChunk',array('name' => 'UnitTestChunk3')); if ($chunk) $chunk->remove(); $chunk = $modx->getObject('modChunk',array('name' => 'Untitled Chunk')); if ($chunk) $chunk->remove(); $category = $modx->getObject('modCategory',array('category' => 'UnitTestChunks')); if ($category) $category->remove(); }
/** * Ensure all tests have a reference to the MODX object */ public function setUp() { $this->modx =& MODxTestHarness::getFixture('modX', 'modx'); if ($this->modx->request) { $this->modx->request->loadErrorHandler(); $this->modx->error->reset(); } /* setup some basic test-environment options to allow us to simulate a site */ $this->modx->setOption('http_host', 'unit.modx.com'); $this->modx->setOption('base_url', '/'); $this->modx->setOption('site_url', 'http://unit.modx.com/'); $corePath = $this->modx->getOption('base_path') . 'extras/minishop/core/components/minishop2/'; require_once $corePath . 'model/minishop2/minishop2.class.php'; $this->modx->setOption('minishop2.assets_path', $this->modx->getOption('base_path') . 'extras/minishop/assets/components/minishop2/'); $this->modx->setOption('minishop2.assets_url', $this->modx->getOption('base_url') . 'extras/minishop/assets/components/minishop2/'); $this->modx->miniShop2 = new miniShop2($this->modx); $this->modx->lexicon->load('minishop2:default'); $this->path = array('processors_path' => $this->modx->getOption('processorsPath', $this->modx->miniShop2->config, $corePath . 'processors/')); }
/** * Grab a persistent instance of the xPDO class to share connection data * across multiple tests and test suites. * * @param array $options An array of configuration parameters. * @return xPDO An xPDO object instance. */ public static function _getConnection($options = array()) { if (is_object(MODxTestHarness::$modx)) { return MODxTestHarness::$modx; } /* include config.core.php */ $properties = array(); require_once strtr(realpath(dirname(dirname(dirname(__FILE__)))) . '/config.core.php', '\\', '/'); require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'; require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; include_once strtr(realpath(dirname(__FILE__)) . '/properties.inc.php', '\\', '/'); $modx = new modX(null, $properties); $ctx = !empty($options['ctx']) ? $options['ctx'] : 'web'; $modx->initialize($ctx); $debug = !empty($options['debug']); $modx->setDebug($debug); $modx->user = $modx->newObject('modUser'); $modx->user->set('id', $modx->getOption('modx.test.user.id', 1)); $modx->user->set('username', $modx->getOption('modx.test.user.username', 'test')); MODxTestHarness::$modx = $modx; return $modx; }
/** * Grab a persistent instance of the xPDO class to share connection data * across multiple tests and test suites. * * @param array $options An array of configuration parameters. * @return xPDO An xPDO object instance. */ public static function _getConnection($options = array()) { $modx = MODxTestHarness::$modx; if (is_object($modx)) { if (!$modx->request) { $modx->getRequest(); } if (!$modx->error) { $modx->request->loadErrorHandler(); } $modx->error->reset(); MODxTestHarness::$modx = $modx; return MODxTestHarness::$modx; } /* include config.core.php */ $properties = array(); require_once strtr(realpath(dirname(dirname(dirname(__FILE__)))) . '/config.core.php','\\','/'); require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php'; require_once MODX_CORE_PATH.'model/modx/modx.class.php'; include_once strtr(realpath(dirname(__FILE__)) . '/properties.inc.php','\\','/'); if (!defined('MODX_REQP')) { define('MODX_REQP',false); } $modx = new modX(null,$properties); $ctx = !empty($options['ctx']) ? $options['ctx'] : 'web'; $modx->initialize($ctx); $debug = !empty($options['debug']); $modx->setDebug($debug); if (!empty($properties['logTarget'])) $modx->setLogTarget($properties['logTarget']); if (!empty($properties['logLevel'])) $modx->setLogLevel($properties['logLevel']); $modx->user = $modx->newObject('modUser'); $modx->user->set('id',$modx->getOption('modx.test.user.id',null,1)); $modx->user->set('username',$modx->getOption('modx.test.user.username',null,'test')); $modx->getRequest(); $modx->getParser(); $modx->request->loadErrorHandler(); MODxTestHarness::$modx = $modx; return $modx; }
/** * Create or grab a reference to a static xPDO/modX instance. * * The instances can be reused by multiple tests and test suites. * * @param string $class A fixture class to get an instance of. * @param string $name A unique identifier for the fixture. * @param boolean $new * @param array $options An array of configuration options for the fixture. * @return object|null An instance of the specified fixture class or null on failure. */ public static function &getFixture($class, $name, $new = false, array $options = array()) { if (!$new && array_key_exists($name, self::$fixtures) && self::$fixtures[$name] instanceof $class) { $fixture =& self::$fixtures[$name]; } else { $properties = array(); include_once dirname(dirname(dirname(__FILE__))) . '/core/model/modx/modx.class.php'; include dirname(__FILE__) . '/properties.inc.php'; self::$properties = $properties; if (array_key_exists('debug', self::$properties)) { self::$debug = (bool) self::$properties['debug']; } $fixture = null; $driver = self::$properties['xpdo_driver']; switch ($class) { case 'modX': if (!defined('MODX_REQP')) { define('MODX_REQP', false); } if (!defined('MODX_CONFIG_KEY')) { define('MODX_CONFIG_KEY', array_key_exists('config_key', self::$properties) ? self::$properties['config_key'] : 'test'); } $fixture = new modX(null, self::$properties["{$driver}_array_options"]); if ($fixture instanceof modX) { $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : modX::LOG_LEVEL_WARN; $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML'); $fixture->setLogLevel($logLevel); $fixture->setLogTarget($logTarget); if (!empty(self::$debug)) { $fixture->setDebug(self::$properties['debug']); } $fixture->initialize(self::$properties['context']); $fixture->user = $fixture->newObject('modUser'); $fixture->user->set('id', $fixture->getOption('modx.test.user.id', null, 1)); $fixture->user->set('username', $fixture->getOption('modx.test.user.username', null, 'test')); $fixture->getRequest(); $fixture->getParser(); $fixture->request->loadErrorHandler(); } break; case 'xPDO': $fixture = new xPDO(self::$properties["{$driver}_string_dsn_test"], self::$properties["{$driver}_string_username"], self::$properties["{$driver}_string_password"], self::$properties["{$driver}_array_options"], self::$properties["{$driver}_array_driverOptions"]); if ($fixture instanceof xPDO) { $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN; $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML'); $fixture->setLogLevel($logLevel); $fixture->setLogTarget($logTarget); if (!empty(self::$debug)) { $fixture->setDebug(self::$properties['debug']); } } break; default: $fixture = new $class($options); break; } if ($fixture !== null && $fixture instanceof $class) { self::$fixtures[$name] = $fixture; } else { die("Error setting fixture {$name} of expected class {$class}."); } } return $fixture; }
/** * Test data provider for getList processor */ public function providerGetDirectoryList() { $modx = MODxTestHarness::_getConnection(); return array( array('manager/',true), array('manager/assets',true), array('fakedirectory/',false), array('assets',true,$modx->getOption('manager_path'),$modx->getOption('manager_url')), ); }
/** * Test data provider for getList processor */ public function providerGetDirectoryList() { $this->modx = MODxTestHarness::_getConnection(); return array(array('manager/', true), array('manager/assets', true), array('fakedirectory/', false), array('assets', true, MODX_BASE_PATH . 'manager/', MODX_BASE_URL . 'manager/')); }
/** * Ensure all tests have a reference to the MODX object */ public function setUp() { $this->modx =& MODxTestHarness::_getConnection(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $modx =& MODxTestHarness::getFixture('modX', 'modx'); $modx->getService('registry', 'registry.modRegistry'); }
public static function setUpBeforeClass() { $modx =& MODxTestHarness::getFixture('modX', 'modx'); include dirname(__FILE__) . '/modtagelement.mock.php'; }
public function testVerifyMODx() { $modx = MODxTestHarness::_getConnection(); $success = is_object($modx) && $modx instanceof modX; $this->assertTrue($success); }