/** * Cms constructor. * @param array $values */ public function __construct(array $values = array()) { parent::__construct($values); $this['type'] = $this->_getCMSType(); $this['ns'] = __NAMESPACE__ . '\\' . $this['type'] . '\\'; $this['db'] = function ($cms) { SqlBuilder::set($cms['type']); // init SQLBuilder Driver $className = $cms['ns'] . 'Database'; $database = new $className($cms); return $database; }; $this['path'] = function ($cms) { $className = $cms['ns'] . 'Path'; /** @var AbstractPath $helper */ $helper = new $className($cms); $path = Path::getInstance('crosscms'); $path->setRoot($helper->getRoot()); $preDefinedPaths = ['upload' => $helper->getUpload(), 'cache' => $helper->getCache(), 'tmpl' => $helper->getTmpl(), 'logs' => $helper->getLogs(), 'tmp' => $helper->getTmp(), 'crosscms' => __DIR__ . '/../src']; foreach ($preDefinedPaths as $alias => $pathValue) { if (!is_dir($pathValue)) { mkdir($pathValue, 0755, true); } $path->set($alias, $pathValue); } return $path; }; $this['events'] = function ($cms) { $eventManager = new EventManager(); $className = $cms['ns'] . 'Events'; $helper = new $className($cms, $eventManager); return $helper; }; $this['lang'] = function ($cms) { $className = $cms['ns'] . 'Lang'; /** @var AbstractLang $helper */ $helper = new $className($cms); $lang = new Lang($helper->getCode()); $helper->setCustomLang($lang); return $helper; }; }
<?php /** * JBZoo SqlBuilder * * This file is part of the JBZoo CCK package. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package SqlBuilder * @license MIT * @copyright Copyright (C) JBZoo.com, All rights reserved. * @link https://github.com/JBZoo/SqlBuilder * @author Denis Smetannikov <*****@*****.**> */ namespace JBZoo\PHPUnit; // @codingStandardsIgnoreFile // @codeCoverageIgnoreStart use JBZoo\SqlBuilder\SqlBuilder; // init life hack $connection = mysqli_connect($_ENV['mysql_host'], $_ENV['mysql_user'], $_ENV['mysql_pass'], $_ENV['mysql_db'], $_ENV['mysql_port']); SqlBuilder::set('mysqli', $connection, 't_'); // @codeCoverageIgnoreEnd
/** * @expectedException \JBZoo\SqlBuilder\Exception */ public function testUndefinedDriver() { SqlBuilder::set('undefined', ''); }