Exemple #1
0
 /**
  * Setup before each test
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_cms = Cms::getInstance();
     $dumper = new PimpleDumper();
     $this->_cms->register($dumper);
     $this->helper = new Helper();
 }
Exemple #2
0
 public function testTranslate()
 {
     $cms = Cms::getInstance();
     runBench(['translate' => function () use($cms) {
         $cms['lang']->translate('January');
     }], ['count' => 1000]);
 }
Exemple #3
0
 public function testInstances()
 {
     $cms = Cms::getInstance();
     $helpers = array("db" => '\\JBZoo\\CrossCMS\\AbstractDatabase', "response" => '\\JBZoo\\CrossCMS\\AbstractResponse', "session" => '\\JBZoo\\CrossCMS\\AbstractSession', "request" => '\\JBZoo\\CrossCMS\\AbstractRequest', "config" => '\\JBZoo\\CrossCMS\\AbstractConfig', "header" => '\\JBZoo\\CrossCMS\\AbstractHeader', "mailer" => '\\JBZoo\\CrossCMS\\AbstractMailer', "events" => '\\JBZoo\\CrossCMS\\AbstractEvents', "cache" => '\\JBZoo\\CrossCMS\\AbstractCache', "http" => '\\JBZoo\\CrossCMS\\AbstractHttp', "env" => '\\JBZoo\\CrossCMS\\AbstractEnv', "path" => '\\JBZoo\\Path\\Path');
     foreach ($helpers as $key => $className) {
         isClass($className, $cms[$key]);
     }
 }
Exemple #4
0
 /**
  * @param string $aliasPath
  * @param string $exceptPath
  * @dataProvider providerWordpress
  */
 public function testWordpress($aliasPath, $exceptPath)
 {
     $cms = Cms::getInstance();
     if ($cms['type'] === Cms::TYPE_WORDPRESS) {
         $path = $this->_cms['path'];
         isSame(realpath($exceptPath), realpath($path->get($aliasPath . ':')));
     }
 }
Exemple #5
0
 public function test()
 {
     $cms = Cms::getInstance();
     $version = $cms['env']->getVersion();
     isTrue(version_compare('1.0.0', $version, '<'));
     isFalse($cms['env']->isAdmin());
     isTrue($cms['env']->isSite());
     isTrue($cms['env']->isCli());
     isContain('http:', $cms['env']->getRootUrl());
 }
Exemple #6
0
 /**
  * @expectedException Exception
  */
 public function testInvalidQuery()
 {
     $cms = Cms::getInstance();
     if ($cms['type'] == Cms::TYPE_WORDPRESS) {
         skip('Stupid Wordpress can\'t handle exceptions...');
     }
     $db = $this->_getDb();
     $select = new Select('information_schema.qwerty123');
     $db->fetchRow($select);
 }
Exemple #7
0
 /**
  * @param $testName
  * @param $request
  * @return Data
  */
 public function request($testName, $request)
 {
     $cms = Cms::getInstance();
     $host = Env::get('TEST_HOST', '127.0.0.1');
     $port = Env::get('TEST_PORT');
     $url = Url::create(['host' => $host, 'port' => $port]);
     $result = httpRequest($url, array_merge(['jbzoo-phpunit' => 1, 'jbzoo-phpunit-test' => $this->getTestName($testName), 'jbzoo-phpunit-type' => strtolower($cms['type'])], $request), 'GET', ['allow_redirects' => false, 'exceptions' => false, 'timeout' => 60, 'verify' => false]);
     if (!$result->getCode()) {
         var_dump($result);
     }
     return $result;
 }
Exemple #8
0
 public function testConfig()
 {
     $cms = Cms::getInstance();
     isTrue(is_bool($cms['config']->isDebug()));
     isTrue(is_string($cms['config']->sitename()));
     isTrue(is_string($cms['config']->sitedesc()));
     isTrue(is_string($cms['config']->email()));
     isTrue(is_string($cms['config']->dbHost()));
     isTrue(is_string($cms['config']->dbName()));
     isTrue(is_string($cms['config']->dbUser()));
     isTrue(is_string($cms['config']->dbPass()));
     isTrue(is_string($cms['config']->dbPrefix()));
     isTrue(is_string($cms['config']->dbType()));
     isTrue(is_string($cms['config']->timezone()));
 }
Exemple #9
0
 protected function _eventInitTests()
 {
     /* Events:init *************************************************************************************************/
     if ($this->_request('test-events-init')) {
         $this->_cms->on('cms.init.site', function () {
             echo $_REQUEST['test-events-init']['init.site'];
         });
         $this->_cms->on('cms.init.admin', function () {
             echo $_REQUEST['test-events-init']['init.admin'];
         }, EventManager::LOW);
         $this->_cms->on('cms.init', function () {
             echo $_REQUEST['test-events-init']['init'];
         }, EventManager::HIGH);
         // Execute Trigger
         $this->_cms->trigger(AbstractEvents::EVENT_INIT);
     }
 }
Exemple #10
0
 public function testGetEventManager()
 {
     $cms = Cms::getInstance();
     isClass('\\JBZoo\\Event\\EventManager', $cms['events']->getManager());
 }
Exemple #11
0
 /**
  * @return \JBZoo\CrossCMS\AbstractSession
  */
 protected function _getSession()
 {
     $cms = Cms::getInstance();
     return $cms['session'];
 }
Exemple #12
0
 /**
  * @return \JBZoo\CrossCMS\AbstractUser
  */
 protected function _getUser()
 {
     $cms = Cms::getInstance();
     return $cms['user'];
 }
Exemple #13
0
<?php

/**
 * JBZoo CrossCMS
 *
 * 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   CrossCMS
 * @license   MIT
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
 * @link      https://github.com/JBZoo/CrossCMS
 * @author    Denis Smetannikov <*****@*****.**>
 */
namespace PHPSTORM_META;

/** @noinspection PhpUnusedLocalVariableInspection */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
$STATIC_METHOD_TYPES = [\JBZoo\CrossCMS\Cms::_('') => ["db" instanceof \JBZoo\CrossCMS\AbstractDatabase, "response" instanceof \JBZoo\CrossCMS\AbstractResponse, "session" instanceof \JBZoo\CrossCMS\AbstractSession, "request" instanceof \JBZoo\CrossCMS\AbstractRequest, "config" instanceof \JBZoo\CrossCMS\AbstractConfig, "assets" instanceof \JBZoo\CrossCMS\AbstractHeader, "mailer" instanceof \JBZoo\CrossCMS\AbstractMailer, "events" instanceof \JBZoo\CrossCMS\AbstractEvents, "cache" instanceof \JBZoo\CrossCMS\AbstractCache, "http" instanceof \JBZoo\CrossCMS\AbstractHttp, "lang" instanceof \JBZoo\CrossCMS\AbstractLang, "user" instanceof \JBZoo\CrossCMS\AbstractUser, "date" instanceof \JBZoo\CrossCMS\AbstractDate, "libs" instanceof \JBZoo\CrossCMS\AbstractLibs, "env" instanceof \JBZoo\CrossCMS\AbstractEnv, "path" instanceof \JBZoo\Path\Path]];
Exemple #14
0
Description: JBZoo PHPUnit Plugin for unit-testing
Author: Denis Smetannikov <*****@*****.**>
Version: 1.0
Author URI: http://jbzoo.com
*/
use JBZoo\CrossCMS\AbstractEvents;
use JBZoo\CrossCMS\Cms;
use JBZoo\Event\EventManager;
use JBZoo\Utils\Vars;
if (!class_exists('\\JBZoo\\CrossCMS\\Cms')) {
    if ($autoloadPath = realpath(ABSPATH . '/../../vendor/autoload.php')) {
        require_once $autoloadPath;
    }
}
if (isset($_REQUEST['jbzoo-phpunit']) && class_exists('\\JBZoo\\CrossCMS\\Cms')) {
    $cms = Cms::getInstance();
    /* Header *********************************************************************************************************/
    add_action('wp', function () use($cms) {
        if (isset($_REQUEST['test-header-jsfile'])) {
            $cms['header']->jsFile('http://site.com/' . $_REQUEST['test-header-jsfile'] . 'js');
        }
        if (isset($_REQUEST['test-header-jscode'])) {
            $cms['header']->jsCode($_REQUEST['test-header-jscode']);
        }
        if (isset($_REQUEST['test-header-cssfile'])) {
            $cms['header']->cssFile('http://site.com/' . $_REQUEST['test-header-cssfile'] . 'css');
        }
        if (isset($_REQUEST['test-header-csscode'])) {
            $cms['header']->cssCode($_REQUEST['test-header-csscode']);
        }
        if (isset($_REQUEST['test-header-title'])) {
Exemple #15
0
 /**
  * @return \JBZoo\CrossCMS\AbstractDate
  */
 protected function _getDate()
 {
     $cms = Cms::getInstance();
     return $cms['date'];
 }
Exemple #16
0
 /**
  * @return \JBZoo\CrossCMS\AbstractLang
  */
 protected function _getLang()
 {
     $cms = Cms::getInstance();
     return $cms['lang'];
 }