예제 #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();
 }
예제 #2
0
 public function testTranslate()
 {
     $cms = Cms::getInstance();
     runBench(['translate' => function () use($cms) {
         $cms['lang']->translate('January');
     }], ['count' => 1000]);
 }
예제 #3
0
파일: CmsTest.php 프로젝트: JBZoo/CrossCMS
 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]);
     }
 }
예제 #4
0
파일: PathTest.php 프로젝트: JBZoo/CrossCMS
 /**
  * @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 . ':')));
     }
 }
예제 #5
0
파일: EnvTest.php 프로젝트: JBZoo/CrossCMS
 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());
 }
예제 #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);
 }
예제 #7
0
파일: Helper.php 프로젝트: JBZoo/CrossCMS
 /**
  * @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;
 }
예제 #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()));
 }
예제 #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);
     }
 }
예제 #10
0
 public function testGetEventManager()
 {
     $cms = Cms::getInstance();
     isClass('\\JBZoo\\Event\\EventManager', $cms['events']->getManager());
 }
예제 #11
0
 /**
  * @return \JBZoo\CrossCMS\AbstractSession
  */
 protected function _getSession()
 {
     $cms = Cms::getInstance();
     return $cms['session'];
 }
예제 #12
0
파일: UserTest.php 프로젝트: JBZoo/CrossCMS
 /**
  * @return \JBZoo\CrossCMS\AbstractUser
  */
 protected function _getUser()
 {
     $cms = Cms::getInstance();
     return $cms['user'];
 }
예제 #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]];
예제 #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'])) {
예제 #15
0
파일: DateTest.php 프로젝트: JBZoo/CrossCMS
 /**
  * @return \JBZoo\CrossCMS\AbstractDate
  */
 protected function _getDate()
 {
     $cms = Cms::getInstance();
     return $cms['date'];
 }
예제 #16
0
파일: LangTest.php 프로젝트: JBZoo/CrossCMS
 /**
  * @return \JBZoo\CrossCMS\AbstractLang
  */
 protected function _getLang()
 {
     $cms = Cms::getInstance();
     return $cms['lang'];
 }