diff --git a/app/.gitkeep b/app/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/phinx.php b/app/phinx.php
index 2bbe52f2..7e6632fb 100644
--- a/app/phinx.php
+++ b/app/phinx.php
@@ -8,7 +8,7 @@
* @link https://www.phptesting.org/
*/
-require_once(dirname(__FILE__) . '../bootstrap.php');
+require_once(dirname(__DIR__) . '/bootstrap.php');
$writeServers = $config->get('b8.database.servers.write');
diff --git a/bin/console b/bin/console
index 92ed9756..03fcecd2 100755
--- a/bin/console
+++ b/bin/console
@@ -8,13 +8,8 @@
* @link http://www.phptesting.org/
*/
-define('PHPCI_IS_CONSOLE', true);
-
-require_once(dirname(__DIR__) . '/bootstrap.php');
-
use PHPCI\Command\RunCommand;
use PHPCI\Command\RebuildCommand;
-use PHPCI\Command\GenerateCommand;
use PHPCI\Command\UpdateCommand;
use PHPCI\Command\InstallCommand;
use PHPCI\Command\DaemonCommand;
@@ -27,13 +22,16 @@ use PHPCI\Service\BuildService;
use Symfony\Component\Console\Application;
use b8\Store\Factory;
+define('PHPCI_IS_CONSOLE', true);
+
+require_once(dirname(__DIR__) . '/bootstrap.php');
+
$application = new Application();
$application->add(new RunCommand($loggerConfig->getFor('RunCommand')));
$application->add(new RebuildCommand($loggerConfig->getFor('RunCommand')));
$application->add(new InstallCommand);
$application->add(new UpdateCommand($loggerConfig->getFor('UpdateCommand')));
-$application->add(new GenerateCommand);
$application->add(new DaemonCommand($loggerConfig->getFor('DaemonCommand')));
$application->add(new PollCommand($loggerConfig->getFor('PollCommand')));
$application->add(new CreateAdminCommand(Factory::getStore('User')));
diff --git a/bin/daemonise b/bin/daemonise
index c04767bc..0e6d879c 100755
--- a/bin/daemonise
+++ b/bin/daemonise
@@ -8,13 +8,13 @@
* @link http://www.phptesting.org/
*/
+use PHPCI\Command\DaemoniseCommand;
+use Symfony\Component\Console\Application;
+
define('PHPCI_IS_CONSOLE', true);
require_once(dirname(__DIR__) . '/bootstrap.php');
-use PHPCI\Command\DaemoniseCommand;
-use Symfony\Component\Console\Application;
-
$application = new Application();
$application->add(new DaemoniseCommand($loggerConfig->getFor('DaemoniseCommand')));
$application->run();
diff --git a/bootstrap.php b/bootstrap.php
index 059db5b3..25968cd3 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -7,73 +7,67 @@
* @link http://www.phptesting.org/
*/
-// Let PHP take a guess as to the default timezone, if the user hasn't set one:
use PHPCI\Logging\LoggerConfig;
-$timezone = ini_get('date.timezone');
-if (empty($timezone)) {
- date_default_timezone_set('UTC');
+if (!defined('ROOT_DIR')) {
+ define('ROOT_DIR', __DIR__ . DIRECTORY_SEPARATOR);
}
-$configFile = dirname(__FILE__) . '/app/config.yml';
-$configEnv = getenv('phpci_config_file');
-$usingCustomConfigFile = false;
-
-if (!empty($configEnv) && file_exists($configEnv)) {
- $configFile = $configEnv;
- $usingCustomConfigFile = true;
+if (!defined('PHPCI_DIR')) {
+ define('PHPCI_DIR', ROOT_DIR . 'src' . DIRECTORY_SEPARATOR . 'PHPCI' . DIRECTORY_SEPARATOR);
}
-// If we don't have a config file at all, fail at this point and tell the user to install:
-if (!file_exists($configFile) && (!defined('PHPCI_IS_CONSOLE') || !PHPCI_IS_CONSOLE)) {
- $message = 'PHPCI has not yet been installed - Please use the command "./console phpci:install" ';
- $message .= '(or "php ./console phpci:install" for Windows) to install it.';
-
- die($message);
+if (!defined('PHPCI_PUBLIC_DIR')) {
+ define('PHPCI_PUBLIC_DIR', ROOT_DIR . 'public' . DIRECTORY_SEPARATOR);
}
-// If composer has not been run, fail at this point and tell the user to install:
-if (!file_exists(dirname(__FILE__) . '/vendor/autoload.php') && defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
- $message = 'Please install PHPCI with "composer install" (or "php composer.phar install"';
- $message .= ' for Windows) before using console';
-
- file_put_contents('php://stderr', $message);
- exit(1);
+if (!defined('PHPCI_APP_DIR')) {
+ define('PHPCI_APP_DIR', ROOT_DIR . 'app' . DIRECTORY_SEPARATOR);
}
-// Load Composer autoloader:
-require_once(dirname(__FILE__) . '/vendor/autoload.php');
+if (!defined('PHPCI_BIN_DIR')) {
+ define('PHPCI_BIN_DIR', ROOT_DIR . 'bin' . DIRECTORY_SEPARATOR);
+}
+
+if (!defined('PHPCI_RUNTIME_DIR')) {
+ define('PHPCI_RUNTIME_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR);
+}
+
+if (!defined('PHPCI_BUILDS_DIR')) {
+ define('PHPCI_BUILDS_DIR', ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR . 'builds' . DIRECTORY_SEPARATOR);
+}
+
+if (!defined('IS_WIN')) {
+ define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false));
+}
+
+require_once(ROOT_DIR . 'vendor/autoload.php');
\PHPCI\ErrorHandler::register();
if (defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
- $loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/app/loggerconfig.php");
+ $loggerConfig = LoggerConfig::newFromFile(PHPCI_APP_DIR . "loggerconfig.php");
}
// Load configuration if present:
$conf = [];
$conf['b8']['app']['namespace'] = 'PHPCI';
$conf['b8']['app']['default_controller'] = 'Home';
-$conf['b8']['view']['path'] = dirname(__FILE__) . '/src/PHPCI/View/';
-$conf['using_custom_file'] = $usingCustomConfigFile;
+$conf['b8']['view']['path'] = PHPCI_DIR . 'View' . DIRECTORY_SEPARATOR;
$config = new b8\Config($conf);
+$configFile = PHPCI_APP_DIR . 'config.yml';
if (file_exists($configFile)) {
$config->loadYaml($configFile);
}
-/**
- * Allow to modify PHPCI configuration without modify versioned code.
- * Daemons should be killed to apply changes in the file.
- *
- * @ticket 781
- */
-$localVarsFile = dirname(__FILE__) . '/local_vars.php';
-if (is_readable($localVarsFile)) {
- require_once $localVarsFile;
+if (!defined('PHPCI_URL') && !empty($config)) {
+ define('PHPCI_URL', $config->get('phpci.url', '') . '/');
}
-require_once(dirname(__FILE__) . '/vars.php');
+if (!defined('PHPCI_IS_CONSOLE')) {
+ define('PHPCI_IS_CONSOLE', false);
+}
\PHPCI\Helper\Lang::init($config);
diff --git a/src/B8Framework/Application.php b/src/B8Framework/Application.php
index 54c989d5..77e1def4 100755
--- a/src/B8Framework/Application.php
+++ b/src/B8Framework/Application.php
@@ -2,7 +2,6 @@
namespace b8;
-use b8\Config;
use b8\Exception\HttpException\NotFoundException;
use b8\Http;
use b8\View;
diff --git a/src/B8Framework/Config.php b/src/B8Framework/Config.php
index bbd83f51..48f54307 100755
--- a/src/B8Framework/Config.php
+++ b/src/B8Framework/Config.php
@@ -5,7 +5,7 @@ namespace b8;
use Symfony\Component\Yaml\Parser as YamlParser;
if (!defined('B8_PATH')) {
- define('B8_PATH', dirname(__FILE__) . '/');
+ define('B8_PATH', __DIR__ . '/');
}
class Config
diff --git a/src/B8Framework/Database/CodeGenerator.php b/src/B8Framework/Database/CodeGenerator.php
deleted file mode 100755
index 7cc13576..00000000
--- a/src/B8Framework/Database/CodeGenerator.php
+++ /dev/null
@@ -1,153 +0,0 @@
-_db = $db;
- $this->_ns = $namespaces;
- $this->_path = $path;
- $this->_map = new Map($this->_db);
- $this->_tables = $this->_map->generate();
- $this->_counts = $includeCountQueries;
- }
-
- protected function getNamespace($modelName)
- {
- return array_key_exists($modelName, $this->_ns) ? $this->_ns[$modelName] : $this->_ns['default'];
- }
-
- public function getPath($namespace)
- {
- return array_key_exists($namespace, $this->_path) ? $this->_path[$namespace] : $this->_path['default'];
- }
-
- public function generateModels()
- {
- print PHP_EOL . 'GENERATING MODELS' . PHP_EOL . PHP_EOL;
-
- foreach($this->_tables as $tableName => $table)
- {
- $namespace = $this->getNamespace($table['php_name']);
- $modelPath = $this->getPath($namespace) . str_replace('\\', '/', $namespace) . '/Model/';
- $basePath = $modelPath . 'Base/';
- $modelFile = $modelPath . $table['php_name'] . '.php';
- $baseFile = $basePath . $table['php_name'] . 'Base.php';
-
- if (!is_dir($basePath)) {
- @mkdir($basePath, 0777, true);
- }
-
- $model = $this->_processTemplate($tableName, $table, 'ModelTemplate');
- $base = $this->_processTemplate($tableName, $table, 'BaseModelTemplate');
-
- print '-- ' . $table['php_name'] . PHP_EOL;
-
- if(!is_file($modelFile))
- {
- print '-- -- Writing new Model' . PHP_EOL;
- file_put_contents($modelFile, $model);
- }
-
- print '-- -- Writing base Model' . PHP_EOL;
- file_put_contents($baseFile, $base);
- }
- }
-
- public function generateStores()
- {
- print PHP_EOL . 'GENERATING STORES' . PHP_EOL . PHP_EOL;
-
- foreach($this->_tables as $tableName => $table)
- {
- $namespace = $this->getNamespace($table['php_name']);
- $storePath = $this->getPath($namespace) . str_replace('\\', '/', $namespace) . '/Store/';
- $basePath = $storePath . 'Base/';
- $storeFile = $storePath . $table['php_name'] . 'Store.php';
- $baseFile = $basePath . $table['php_name'] . 'StoreBase.php';
-
- if (!is_dir($basePath)) {
- @mkdir($basePath, 0777, true);
- }
-
- $model = $this->_processTemplate($tableName, $table, 'StoreTemplate');
- $base = $this->_processTemplate($tableName, $table, 'BaseStoreTemplate');
-
- print '-- ' . $table['php_name'] . PHP_EOL;
-
- if(!is_file($storeFile))
- {
- print '-- -- Writing new Store' . PHP_EOL;
- file_put_contents($storeFile, $model);
- }
-
- print '-- -- Writing base Store' . PHP_EOL;
- file_put_contents($baseFile, $base);
- }
- }
-
- public function generateControllers()
- {
- print PHP_EOL . 'GENERATING CONTROLLERS' . PHP_EOL . PHP_EOL;
-
- @mkdir($this->_path . 'Controller/Base/', 0777, true);
-
- foreach($this->_tables as $tableName => $table)
- {
- $namespace = $this->getNamespace($table['php_name']);
- $controllerPath = $this->getPath($namespace) . str_replace('\\', '/', $namespace) . '/Controller/';
- $basePath = $controllerPath . 'Base/';
- $controllerFile = $controllerPath . $table['php_name'] . 'Controller.php';
- $baseFile = $basePath . $table['php_name'] . 'ControllerBase.php';
-
- if (!is_dir($basePath)) {
- @mkdir($basePath, 0777, true);
- }
-
- $model = $this->_processTemplate($tableName, $table, 'ControllerTemplate');
- $base = $this->_processTemplate($tableName, $table, 'BaseControllerTemplate');
-
- print '-- ' . $table['php_name'] . PHP_EOL;
-
- if(!is_file($controllerFile))
- {
- print '-- -- Writing new Controller' . PHP_EOL;
- file_put_contents($controllerFile, $model);
- }
-
- print '-- -- Writing base Controller' . PHP_EOL;
- file_put_contents($baseFile, $base);
- }
- }
-
- protected function _processTemplate($tableName, $table, $template)
- {
- $tpl = Template::createFromFile($template, B8_PATH . 'Database/CodeGenerator/');
- $tpl->appNamespace = $this->getNamespace($table['php_name']);
- $tpl->name = $tableName;
- $tpl->table = $table;
- $tpl->counts = $this->_counts;
- $tpl->addFunction('get_namespace', function($args, $view) {
- return $this->getNamespace($view->getVariable($args['model']));
- });
-
- return $tpl->render();
- }
-}
\ No newline at end of file
diff --git a/src/B8Framework/Database/CodeGenerator/BaseControllerTemplate.html b/src/B8Framework/Database/CodeGenerator/BaseControllerTemplate.html
deleted file mode 100755
index 68871652..00000000
--- a/src/B8Framework/Database/CodeGenerator/BaseControllerTemplate.html
+++ /dev/null
@@ -1,22 +0,0 @@
- null,
-{/loop}
- );
-
- /**
- * @var array
- */
- protected $getters = array(
- // Direct property getters:
-{loop table.columns}
- '{@item.name}' => 'get{@item.php_name}',
-{/loop}
-
- // Foreign key getters:
-{loop table.relationships.toOne}
- '{@item.php_name}' => 'get{@item.php_name}',
-{/loop}
- );
-
- /**
- * @var array
- */
- protected $setters = array(
- // Direct property setters:
-{loop table.columns}
- '{@item.name}' => 'set{@item.php_name}',
-{/loop}
-
- // Foreign key setters:
-{loop table.relationships.toOne}
- '{@item.php_name}' => 'set{@item.php_name}',
-{/loop}
- );
-
- /**
- * @var array
- */
- public $columns = array(
-{loop table.columns}
- '{@item.name}' => array(
- 'type' => '{@item.type}',
-{if item.length}
- 'length' => {@item.length},
-{/if}
-{if item.null}
- 'nullable' => true,
-{/if}
-{if item.is_primary_key}
- 'primary_key' => true,
-{/if}
-{if item.auto}
- 'auto_increment' => true,
-{/if}
-{if item.default_is_null}
- 'default' => null,
-{/if}
-{ifnot item.default_is_null}
-{if item.default}
- 'default' => {if item.default.isNumeric}{@item.default}{/if}{ifnot item.default.isNumeric}'{@item.default}'{/ifnot},
-{/if}
-{/ifnot}
- ),
-{/loop}
- );
-
- /**
- * @var array
- */
- public $indexes = array(
-{loop table.indexes}
- '{@item.name}' => array({if item.unique}'unique' => true, {/if}'columns' => '{@item.columns}'),
-{/loop}
- );
-
- /**
- * @var array
- */
- public $foreignKeys = array(
-{loop table.relationships.toOne}
- '{@item.fk_name}' => array(
- 'local_col' => '{@item.from_col}',
- 'update' => '{@item.fk_update}',
- 'delete' => '{@item.fk_delete}',
- 'table' => '{@item.table}',
- 'col' => '{@item.col}'
- ),
-{/loop}
- );
-
-{loop table.columns}
- /**
- * Get the value of {@item.php_name} / {@item.name}.
- *
-{if item.validate_int}
- * @return int
-{/if}{if item.validate_string}
- * @return string
-{/if}{if item.validate_float}
- * @return float
-{/if}{if item.validate_date}
- * @return \DateTime
-{/if}
- */
- public function get{@item.php_name}()
- {
- $rtn = $this->data['{@item.name}'];
-
-{if item.validate_date}
- if (!empty($rtn)) {
- $rtn = new \DateTime($rtn);
- }
-
-{/if}
- return $rtn;
- }
-
-{/loop}
-{loop table.columns}
- /**
- * Set the value of {@item.php_name} / {@item.name}.
- *
-{if item.validate_null}
- * Must not be null.
-{/if}{if item.validate_int}
- * @param $value int
-{/if}{if item.validate_string}
- * @param $value string
-{/if}{if item.validate_float}
- * @param $value float
-{/if}{if item.validate_date}
- * @param $value \DateTime
-{/if}
- */
- public function set{@item.php_name}($value)
- {
-{if item.validate_null}
- $this->_validateNotNull('{@item.php_name}', $value);
-{/if}
-{if item.validate_int}
- $this->_validateInt('{@item.php_name}', $value);
-{/if}
-{if item.validate_string}
- $this->_validateString('{@item.php_name}', $value);
-{/if}
-{if item.validate_float}
- $this->_validateFloat('{@item.php_name}', $value);
-{/if}
-{if item.validate_date}
- $this->_validateDate('{@item.php_name}', $value);
-{/if}
-
- if ($this->data['{@item.name}'] === $value) {
- return;
- }
-
- $this->data['{@item.name}'] = $value;
-
- $this->_setModified('{@item.name}');
- }
-
-{/loop}{loop table.relationships.toOne}
- /**
- * Get the {@item.table_php_name} model for this {@parent.table.php_name} by {@item.col_php}.
- *
- * @uses \{@parent.appNamespace}\Store\{@item.table_php_name}Store::getBy{@item.col_php}()
- * @uses \{@parent.appNamespace}\Model\{@item.table_php_name}
- * @return \{@parent.appNamespace}\Model\{@item.table_php_name}
- */
- public function get{@item.php_name}()
- {
- $key = $this->get{@item.from_col_php}();
-
- if (empty($key)) {
- return null;
- }
-
- $cacheKey = 'Cache.{@item.table_php_name}.' . $key;
- $rtn = $this->cache->get($cacheKey, null);
-
- if (empty($rtn)) {
- $rtn = Factory::getStore('{@item.table_php_name}', '{get_namespace model: item.table_php_name}')->getBy{@item.col_php}($key);
- $this->cache->set($cacheKey, $rtn);
- }
-
- return $rtn;
- }
-
- /**
- * Set {@item.php_name} - Accepts an ID, an array representing a {@item.table_php_name} or a {@item.table_php_name} model.
- *
- * @param $value mixed
- */
- public function set{@item.php_name}($value)
- {
- // Is this an instance of {@item.table_php_name}?
- if ($value instanceof \{@parent.appNamespace}\Model\{@item.table_php_name}) {
- return $this->set{@item.php_name}Object($value);
- }
-
- // Is this an array representing a {@item.table_php_name} item?
- if (is_array($value) && !empty($value['{@item.col}'])) {
- return $this->set{@item.from_col_php}($value['{@item.col}']);
- }
-
- // Is this a scalar value representing the ID of this foreign key?
- return $this->set{@item.from_col_php}($value);
- }
-
- /**
- * Set {@item.php_name} - Accepts a {@item.table_php_name} model.
- *
- * @param $value \{@parent.appNamespace}\Model\{@item.table_php_name}
- */
- public function set{@item.php_name}Object(\{@parent.appNamespace}\Model\{@item.table_php_name} $value)
- {
- return $this->set{@item.from_col_php}($value->get{@item.col_php}());
- }
-
-{/loop}{loop table.relationships.toMany}
- /**
- * Get {@item.table_php} models by {@item.from_col_php} for this {@parent.table.php_name}.
- *
- * @uses \{@parent.appNamespace}\Store\{@item.table_php}Store::getBy{@item.from_col_php}()
- * @uses \{@parent.appNamespace}\Model\{@item.table_php}
- * @return \{@parent.appNamespace}\Model\{@item.table_php}[]
- */
- public function get{@item.php_name}()
- {
- return Factory::getStore('{@item.table_php}', '{get_namespace model: item.table_php_name}')->getBy{@item.from_col_php}($this->get{@item.col_php}());
- }
-
-{/loop}}
diff --git a/src/B8Framework/Database/CodeGenerator/BaseStoreTemplate.html b/src/B8Framework/Database/CodeGenerator/BaseStoreTemplate.html
deleted file mode 100755
index de651549..00000000
--- a/src/B8Framework/Database/CodeGenerator/BaseStoreTemplate.html
+++ /dev/null
@@ -1,101 +0,0 @@
-getBy{@table.primary_key.php_name}($value, $useConnection);
- }
-{/if}
-{ifnot table.primary_key}
-
- public function getByPrimaryKey($value, $useConnection = 'read')
- {
- throw new \Exception('getByPrimaryKey is not implemented for this store, as the table has no primary key.');
- }
-{/ifnot}
-{loop table.columns}
-{if item.unique_indexed}
-
- public function getBy{@item.php_name}($value, $useConnection = 'read')
- {
- if (is_null($value)) {
- throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
- }
-
- $query = 'SELECT * FROM `{@parent.name}` WHERE `{@item.name}` = :{@item.name} LIMIT 1';
- $stmt = Database::getConnection($useConnection)->prepare($query);
- $stmt->bindValue(':{@item.name}', $value);
-
- if ($stmt->execute()) {
- if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
- return new {@parent.table.php_name}($data);
- }
- }
-
- return null;
- }
-{/if}
-{if item.many_indexed}
-
- public function getBy{@item.php_name}($value, $limit = 1000, $useConnection = 'read')
- {
- if (is_null($value)) {
- throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
- }
-
-{if counts}
- $query = 'SELECT COUNT(*) AS cnt FROM `{@parent.name}` WHERE `{@item.name}` = :{@item.name}';
- $stmt = Database::getConnection($useConnection)->prepare($query);
- $stmt->bindValue(':{@item.name}', $value);
-
- if ($stmt->execute()) {
- $res = $stmt->fetch(\PDO::FETCH_ASSOC);
- $count = (int)$res['cnt'];
- } else {
- $count = 0;
- }
-{/if}
-
- $query = 'SELECT * FROM `{@parent.name}` WHERE `{@item.name}` = :{@item.name} LIMIT :limit';
- $stmt = Database::getConnection($useConnection)->prepare($query);
- $stmt->bindValue(':{@item.name}', $value);
- $stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
-
- if ($stmt->execute()) {
- $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
-
- $map = function ($item) {
- return new {@parent.table.php_name}($item);
- };
- $rtn = array_map($map, $res);
-
- {ifnot counts}$count = count($rtn);{/ifnot}
-
- return array('items' => $rtn, 'count' => $count);
- } else {
- return array('items' => array(), 'count' => 0);
- }
- }
-{/if}
-{/loop}
-}
diff --git a/src/B8Framework/Database/CodeGenerator/ControllerTemplate.html b/src/B8Framework/Database/CodeGenerator/ControllerTemplate.html
deleted file mode 100755
index 61e94afe..00000000
--- a/src/B8Framework/Database/CodeGenerator/ControllerTemplate.html
+++ /dev/null
@@ -1,20 +0,0 @@
-errorCode;
- }
+ public function getErrorCode()
+ {
+ return $this->errorCode;
+ }
- public function getStatusMessage()
- {
- return $this->statusMessage;
- }
+ public function getStatusMessage()
+ {
+ return $this->statusMessage;
+ }
- public function getHttpHeader()
- {
- return 'HTTP/1.1 ' . $this->errorCode . ' ' . $this->statusMessage;
- }
-}
\ No newline at end of file
+ public function getHttpHeader()
+ {
+ return 'HTTP/1.1 ' . $this->errorCode . ' ' . $this->statusMessage;
+ }
+}
diff --git a/src/B8Framework/Exception/HttpException/BadRequestException.php b/src/B8Framework/Exception/HttpException/BadRequestException.php
index 89b5df96..3e9c2f7e 100755
--- a/src/B8Framework/Exception/HttpException/BadRequestException.php
+++ b/src/B8Framework/Exception/HttpException/BadRequestException.php
@@ -1,10 +1,11 @@
_action;
- }
+ public function getAction()
+ {
+ return $this->_action;
+ }
- public function setAction($action)
- {
- $this->_action = $action;
- }
+ public function setAction($action)
+ {
+ $this->_action = $action;
+ }
- public function getMethod()
- {
- return $this->_method;
- }
+ public function getMethod()
+ {
+ return $this->_method;
+ }
- public function setMethod($method)
- {
- $this->_method = $method;
- }
+ public function setMethod($method)
+ {
+ $this->_method = $method;
+ }
- protected function _onPreRender(View &$view)
- {
- $view->action = $this->getAction();
- $view->method = $this->getMethod();
+ protected function _onPreRender(View &$view)
+ {
+ $view->action = $this->getAction();
+ $view->method = $this->getMethod();
- parent::_onPreRender($view);
- }
+ parent::_onPreRender($view);
+ }
- public function __toString()
- {
- return $this->render();
- }
-}
\ No newline at end of file
+ public function __toString()
+ {
+ return $this->render();
+ }
+}
diff --git a/src/B8Framework/Form/ControlGroup.php b/src/B8Framework/Form/ControlGroup.php
index cb20f1f6..87848f2c 100755
--- a/src/B8Framework/Form/ControlGroup.php
+++ b/src/B8Framework/Form/ControlGroup.php
@@ -4,4 +4,4 @@ namespace b8\Form;
class ControlGroup extends FieldSet
{
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Form/Element.php b/src/B8Framework/Form/Element.php
index 648f305f..ab1157db 100755
--- a/src/B8Framework/Form/Element.php
+++ b/src/B8Framework/Form/Element.php
@@ -7,112 +7,107 @@ use b8\Config;
abstract class Element
{
- protected $_name;
- protected $_id;
- protected $_label;
- protected $_css;
- protected $_ccss;
- protected $_parent;
+ protected $_name;
+ protected $_id;
+ protected $_label;
+ protected $_css;
+ protected $_ccss;
+ protected $_parent;
- public function __construct($name = null)
- {
- if(!is_null($name))
- {
- $this->setName($name);
- }
- }
+ public function __construct($name = null)
+ {
+ if (!is_null($name)) {
+ $this->setName($name);
+ }
+ }
- public function getName()
- {
- return $this->_name;
- }
+ public function getName()
+ {
+ return $this->_name;
+ }
- public function setName($name)
- {
- $this->_name = strtolower(preg_replace('/([^a-zA-Z0-9_\-])/', '', $name));
+ public function setName($name)
+ {
+ $this->_name = strtolower(preg_replace('/([^a-zA-Z0-9_\-])/', '', $name));
return $this;
- }
+ }
- public function getId()
- {
- return !$this->_id ? 'element-'.$this->_name : $this->_id;
- }
+ public function getId()
+ {
+ return !$this->_id ? 'element-' . $this->_name : $this->_id;
+ }
- public function setId($id)
- {
- $this->_id = $id;
+ public function setId($id)
+ {
+ $this->_id = $id;
return $this;
- }
+ }
- public function getLabel()
- {
- return $this->_label;
- }
+ public function getLabel()
+ {
+ return $this->_label;
+ }
- public function setLabel($label)
- {
- $this->_label = $label;
+ public function setLabel($label)
+ {
+ $this->_label = $label;
return $this;
- }
+ }
- public function getClass()
- {
- return $this->_css;
- }
+ public function getClass()
+ {
+ return $this->_css;
+ }
- public function setClass($class)
- {
- $this->_css = $class;
+ public function setClass($class)
+ {
+ $this->_css = $class;
return $this;
- }
+ }
- public function getContainerClass()
- {
- return $this->_ccss;
- }
+ public function getContainerClass()
+ {
+ return $this->_ccss;
+ }
- public function setContainerClass($class)
- {
- $this->_ccss = $class;
+ public function setContainerClass($class)
+ {
+ $this->_ccss = $class;
return $this;
- }
+ }
- public function setParent(Element $parent)
- {
- $this->_parent = $parent;
+ public function setParent(Element $parent)
+ {
+ $this->_parent = $parent;
return $this;
- }
+ }
- public function render($viewFile = null)
- {
- $viewPath = Config::getInstance()->get('b8.view.path');
+ public function render($viewFile = null)
+ {
+ $viewPath = Config::getInstance()->get('b8.view.path');
- if(is_null($viewFile))
- {
- $class = explode('\\', get_called_class());
- $viewFile = end($class);
- }
+ if (is_null($viewFile)) {
+ $class = explode('\\', get_called_class());
+ $viewFile = end($class);
+ }
- if(file_exists($viewPath . 'Form/' . $viewFile . '.phtml'))
- {
- $view = new View('Form/' . $viewFile);
- }
- else
- {
- $view = new View($viewFile, B8_PATH . 'Form/View/');
- }
+ if (file_exists($viewPath . 'Form/' . $viewFile . '.phtml')) {
+ $view = new View('Form/' . $viewFile);
+ } else {
+ $view = new View($viewFile, B8_PATH . 'Form/View/');
+ }
- $view->name = $this->getName();
- $view->id = $this->getId();
- $view->label = $this->getLabel();
- $view->css = $this->getClass();
- $view->ccss = $this->getContainerClass();
- $view->parent = $this->_parent;
+ $view->name = $this->getName();
+ $view->id = $this->getId();
+ $view->label = $this->getLabel();
+ $view->css = $this->getClass();
+ $view->ccss = $this->getContainerClass();
+ $view->parent = $this->_parent;
- $this->_onPreRender($view);
+ $this->_onPreRender($view);
- return $view->render();
- }
+ return $view->render();
+ }
- abstract protected function _onPreRender(View &$view);
-}
\ No newline at end of file
+ abstract protected function _onPreRender(View &$view);
+}
diff --git a/src/B8Framework/Form/Element/Button.php b/src/B8Framework/Form/Element/Button.php
index f46472f0..5250573e 100755
--- a/src/B8Framework/Form/Element/Button.php
+++ b/src/B8Framework/Form/Element/Button.php
@@ -1,19 +1,19 @@
type = 'button';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'button';
+ }
+}
diff --git a/src/B8Framework/Form/Element/Checkbox.php b/src/B8Framework/Form/Element/Checkbox.php
index 07607ebf..ec8fa60d 100755
--- a/src/B8Framework/Form/Element/Checkbox.php
+++ b/src/B8Framework/Form/Element/Checkbox.php
@@ -1,48 +1,46 @@
_checkedValue;
- }
+ public function getCheckedValue()
+ {
+ return $this->_checkedValue;
+ }
- public function setCheckedValue($value)
- {
- $this->_checkedValue = $value;
- }
+ public function setCheckedValue($value)
+ {
+ $this->_checkedValue = $value;
+ }
- public function setValue($value)
- {
- if(is_bool($value) && $value == true)
- {
- $this->_value = $this->getCheckedValue();
- $this->_checked = true;
- return;
- }
+ public function setValue($value)
+ {
+ if (is_bool($value) && $value == true) {
+ $this->_value = $this->getCheckedValue();
+ $this->_checked = true;
+ return;
+ }
- if($value == $this->getCheckedValue())
- {
- $this->_value = $this->getCheckedValue();
- $this->_checked = true;
- return;
- }
+ if ($value == $this->getCheckedValue()) {
+ $this->_value = $this->getCheckedValue();
+ $this->_checked = true;
+ return;
+ }
- $this->_value = $value;
- $this->_checked = false;
- }
+ $this->_value = $value;
+ $this->_checked = false;
+ }
- public function _onPreRender(View &$view)
- {
- parent::_onPreRender($view);
- $view->checkedValue = $this->getCheckedValue();
- $view->checked = $this->_checked;
- }
-}
\ No newline at end of file
+ public function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->checkedValue = $this->getCheckedValue();
+ $view->checked = $this->_checked;
+ }
+}
diff --git a/src/B8Framework/Form/Element/CheckboxGroup.php b/src/B8Framework/Form/Element/CheckboxGroup.php
index e924dfaf..0b8b7165 100755
--- a/src/B8Framework/Form/Element/CheckboxGroup.php
+++ b/src/B8Framework/Form/Element/CheckboxGroup.php
@@ -1,8 +1,9 @@
_value != $_COOKIE[$this->getName()])
- {
- return false;
- }
+ public function validate()
+ {
+ if ($this->_value != $_COOKIE[$this->getName()]) {
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- protected function _onPreRender(View &$view)
- {
- parent::_onPreRender($view);
- $csrf = md5(microtime(true));
- $view->csrf = $csrf;
- setcookie($this->getName(), $csrf);
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $csrf = md5(microtime(true));
+ $view->csrf = $csrf;
+ setcookie($this->getName(), $csrf);
+ }
+}
diff --git a/src/B8Framework/Form/Element/Email.php b/src/B8Framework/Form/Element/Email.php
index 3913de65..922e1a97 100755
--- a/src/B8Framework/Form/Element/Email.php
+++ b/src/B8Framework/Form/Element/Email.php
@@ -1,18 +1,19 @@
type = 'email';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'email';
+ }
+}
diff --git a/src/B8Framework/Form/Element/Hidden.php b/src/B8Framework/Form/Element/Hidden.php
index 6687b9c5..5643903f 100755
--- a/src/B8Framework/Form/Element/Hidden.php
+++ b/src/B8Framework/Form/Element/Hidden.php
@@ -1,9 +1,9 @@
type = 'password';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'password';
+ }
+}
diff --git a/src/B8Framework/Form/Element/Radio.php b/src/B8Framework/Form/Element/Radio.php
index 4afd18fc..d45e0c94 100755
--- a/src/B8Framework/Form/Element/Radio.php
+++ b/src/B8Framework/Form/Element/Radio.php
@@ -1,8 +1,7 @@
type = 'submit';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'submit';
+ }
+}
diff --git a/src/B8Framework/Form/Element/Text.php b/src/B8Framework/Form/Element/Text.php
index 4f6c92a7..658e40b8 100755
--- a/src/B8Framework/Form/Element/Text.php
+++ b/src/B8Framework/Form/Element/Text.php
@@ -1,14 +1,14 @@
type = 'text';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'text';
+ }
+}
diff --git a/src/B8Framework/Form/Element/TextArea.php b/src/B8Framework/Form/Element/TextArea.php
index 1e623632..2c640ea3 100755
--- a/src/B8Framework/Form/Element/TextArea.php
+++ b/src/B8Framework/Form/Element/TextArea.php
@@ -1,26 +1,26 @@
_rows;
- }
+ public function getRows()
+ {
+ return $this->_rows;
+ }
- public function setRows($rows)
- {
- $this->_rows = $rows;
- }
+ public function setRows($rows)
+ {
+ $this->_rows = $rows;
+ }
- protected function _onPreRender(View &$view)
- {
- parent::_onPreRender($view);
- $view->rows = $this->getRows();
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->rows = $this->getRows();
+ }
+}
diff --git a/src/B8Framework/Form/Element/Url.php b/src/B8Framework/Form/Element/Url.php
index 4cad534f..6ce621d8 100755
--- a/src/B8Framework/Form/Element/Url.php
+++ b/src/B8Framework/Form/Element/Url.php
@@ -1,18 +1,19 @@
type = 'url';
- }
-}
\ No newline at end of file
+ protected function _onPreRender(View &$view)
+ {
+ parent::_onPreRender($view);
+ $view->type = 'url';
+ }
+}
diff --git a/src/B8Framework/Form/FieldSet.php b/src/B8Framework/Form/FieldSet.php
index db9cfbc5..6899e9a6 100755
--- a/src/B8Framework/Form/FieldSet.php
+++ b/src/B8Framework/Form/FieldSet.php
@@ -89,4 +89,4 @@ class FieldSet extends Element
{
return $this->_children[$fieldName];
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Form/Input.php b/src/B8Framework/Form/Input.php
index 55fcd387..1c6d591d 100755
--- a/src/B8Framework/Form/Input.php
+++ b/src/B8Framework/Form/Input.php
@@ -2,8 +2,7 @@
namespace b8\Form;
-use b8\Form\Element,
- b8\View;
+use b8\Form\Element, b8\View;
class Input extends Element
{
@@ -115,4 +114,4 @@ class Input extends Element
$view->pattern = $this->_pattern;
$view->required = $this->_required;
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Form/View/Button.phtml b/src/B8Framework/Form/View/Button.phtml
index afd5efdb..ccce383c 100755
--- a/src/B8Framework/Form/View/Button.phtml
+++ b/src/B8Framework/Form/View/Button.phtml
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/src/B8Framework/Form/View/Checkbox.phtml b/src/B8Framework/Form/View/Checkbox.phtml
index cd6731a8..3c875490 100755
--- a/src/B8Framework/Form/View/Checkbox.phtml
+++ b/src/B8Framework/Form/View/Checkbox.phtml
@@ -1,17 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/B8Framework/Form/View/CheckboxGroup.phtml b/src/B8Framework/Form/View/CheckboxGroup.phtml
index 09f4021c..4b97193a 100755
--- a/src/B8Framework/Form/View/CheckboxGroup.phtml
+++ b/src/B8Framework/Form/View/CheckboxGroup.phtml
@@ -1,11 +1,11 @@
\ No newline at end of file
+
+
+
+
+
+
diff --git a/src/B8Framework/Form/View/ControlGroup.phtml b/src/B8Framework/Form/View/ControlGroup.phtml
index 3bf88b21..1eeaace7 100755
--- a/src/B8Framework/Form/View/ControlGroup.phtml
+++ b/src/B8Framework/Form/View/ControlGroup.phtml
@@ -1,6 +1,5 @@
-
-
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/src/B8Framework/Form/View/Csrf.phtml b/src/B8Framework/Form/View/Csrf.phtml
index 42b0e74b..52461951 100755
--- a/src/B8Framework/Form/View/Csrf.phtml
+++ b/src/B8Framework/Form/View/Csrf.phtml
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/src/B8Framework/Form/View/FieldSet.phtml b/src/B8Framework/Form/View/FieldSet.phtml
index fbc1fe75..debd66d7 100755
--- a/src/B8Framework/Form/View/FieldSet.phtml
+++ b/src/B8Framework/Form/View/FieldSet.phtml
@@ -1,9 +1,9 @@
\ No newline at end of file
+
+
+
+
diff --git a/src/B8Framework/Form/View/Form.phtml b/src/B8Framework/Form/View/Form.phtml
index 3f85d73e..fbbbe31a 100755
--- a/src/B8Framework/Form/View/Form.phtml
+++ b/src/B8Framework/Form/View/Form.phtml
@@ -1,6 +1,5 @@
\ No newline at end of file
+
+
+
+
diff --git a/src/B8Framework/Form/View/Hidden.phtml b/src/B8Framework/Form/View/Hidden.phtml
index 28c4fdbf..9395fd54 100755
--- a/src/B8Framework/Form/View/Hidden.phtml
+++ b/src/B8Framework/Form/View/Hidden.phtml
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/src/B8Framework/Form/View/Radio.phtml b/src/B8Framework/Form/View/Radio.phtml
index 8c15983c..4e66573b 100755
--- a/src/B8Framework/Form/View/Radio.phtml
+++ b/src/B8Framework/Form/View/Radio.phtml
@@ -1,18 +1,19 @@
-
-
-
+
+
+
+
\ No newline at end of file
+
+
+
+
+
diff --git a/src/B8Framework/Form/View/Select.phtml b/src/B8Framework/Form/View/Select.phtml
index a5dbd957..68224377 100755
--- a/src/B8Framework/Form/View/Select.phtml
+++ b/src/B8Framework/Form/View/Select.phtml
@@ -1,17 +1,18 @@
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/B8Framework/Form/View/Text.phtml b/src/B8Framework/Form/View/Text.phtml
index 401db77d..37deba14 100755
--- a/src/B8Framework/Form/View/Text.phtml
+++ b/src/B8Framework/Form/View/Text.phtml
@@ -1,13 +1,14 @@
-
-
-
+
+
+
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/B8Framework/Form/View/TextArea.phtml b/src/B8Framework/Form/View/TextArea.phtml
index dfe17e8a..b9a3660e 100755
--- a/src/B8Framework/Form/View/TextArea.phtml
+++ b/src/B8Framework/Form/View/TextArea.phtml
@@ -1,13 +1,13 @@
-
-
-
+
+
+
+
\ No newline at end of file
+
+
+
+
+
diff --git a/src/B8Framework/Http/Request.php b/src/B8Framework/Http/Request.php
index c3ffd11f..c5b9782a 100755
--- a/src/B8Framework/Http/Request.php
+++ b/src/B8Framework/Http/Request.php
@@ -21,7 +21,7 @@ class Request
{
$this->parseInput();
- $this->data['path'] = $this->getRequestPath();
+ $this->data['path'] = $this->getRequestPath();
$this->data['parts'] = array_values(array_filter(explode('/', $this->data['path'])));
}
diff --git a/src/B8Framework/Http/Response/JsonResponse.php b/src/B8Framework/Http/Response/JsonResponse.php
index 6043ac1f..ff065220 100755
--- a/src/B8Framework/Http/Response/JsonResponse.php
+++ b/src/B8Framework/Http/Response/JsonResponse.php
@@ -27,4 +27,4 @@ class JsonResponse extends Response
return json_encode(null);
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Http/Response/RedirectResponse.php b/src/B8Framework/Http/Response/RedirectResponse.php
index fa289278..b400fefb 100755
--- a/src/B8Framework/Http/Response/RedirectResponse.php
+++ b/src/B8Framework/Http/Response/RedirectResponse.php
@@ -6,22 +6,22 @@ use b8\Http\Response;
class RedirectResponse extends Response
{
- public function __construct(Response $createFrom = null)
- {
- parent::__construct($createFrom);
+ public function __construct(Response $createFrom = null)
+ {
+ parent::__construct($createFrom);
- $this->setContent(null);
- $this->setResponseCode(302);
- }
+ $this->setContent(null);
+ $this->setResponseCode(302);
+ }
- public function hasLayout()
- {
- return false;
- }
+ public function hasLayout()
+ {
+ return false;
+ }
- public function flush()
- {
- parent::flush();
- die;
- }
-}
\ No newline at end of file
+ public function flush()
+ {
+ parent::flush();
+ die;
+ }
+}
diff --git a/src/B8Framework/Http/Router.php b/src/B8Framework/Http/Router.php
index 7b164a63..481d3fce 100755
--- a/src/B8Framework/Http/Router.php
+++ b/src/B8Framework/Http/Router.php
@@ -4,17 +4,16 @@ namespace b8\Http;
use b8\Application;
use b8\Config;
-use b8\Http\Request;
class Router
{
/**
- * @var \b8\Http\Request;
+ * @var Request;
*/
protected $request;
/**
- * @var \b8\Http\Config;
+ * @var Config;
*/
protected $config;
@@ -126,4 +125,4 @@ class Router
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/HttpClient.php b/src/B8Framework/HttpClient.php
index 402fe1f4..761cc0ac 100755
--- a/src/B8Framework/HttpClient.php
+++ b/src/B8Framework/HttpClient.php
@@ -164,4 +164,4 @@ class HttpClient
return $rtn;
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Image.php b/src/B8Framework/Image.php
index d091c12a..f3806d9b 100755
--- a/src/B8Framework/Image.php
+++ b/src/B8Framework/Image.php
@@ -7,7 +7,6 @@ class Image
public static $cachePath = '/tmp/';
public static $sourcePath = './';
-
/**
* @var \Imagick
*/
@@ -146,4 +145,4 @@ class Image
return $rtn;
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Model.php b/src/B8Framework/Model.php
index 01e7e07e..fb59a189 100755
--- a/src/B8Framework/Model.php
+++ b/src/B8Framework/Model.php
@@ -118,9 +118,6 @@ class Model
$this->modified[$column] = $column;
}
- //----------------
- // Validation
- //----------------
protected function _validateString($name, $value)
{
if (!is_string($value) && !is_null($value)) {
diff --git a/src/B8Framework/Store.php b/src/B8Framework/Store.php
index c843c681..f2542645 100755
--- a/src/B8Framework/Store.php
+++ b/src/B8Framework/Store.php
@@ -313,4 +313,4 @@ abstract class Store
return $field;
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/Type/Cache.php b/src/B8Framework/Type/Cache.php
index e02eecf4..bc12ff56 100755
--- a/src/B8Framework/Type/Cache.php
+++ b/src/B8Framework/Type/Cache.php
@@ -4,14 +4,21 @@ namespace b8\Type;
interface Cache
{
- public function get($key, $default = null);
- public function set($key, $value = null, $ttl = 0);
- public function delete($key);
- public function contains($key);
- public function isEnabled();
+ public function get($key, $default = null);
- public function __get($key);
- public function __set($key, $value = null);
- public function __unset($key);
- public function __isset($key);
-}
\ No newline at end of file
+ public function set($key, $value = null, $ttl = 0);
+
+ public function delete($key);
+
+ public function contains($key);
+
+ public function isEnabled();
+
+ public function __get($key);
+
+ public function __set($key, $value = null);
+
+ public function __unset($key);
+
+ public function __isset($key);
+}
diff --git a/src/B8Framework/Type/RestUser.php b/src/B8Framework/Type/RestUser.php
index 61b3e45d..6b4d0f5f 100755
--- a/src/B8Framework/Type/RestUser.php
+++ b/src/B8Framework/Type/RestUser.php
@@ -4,5 +4,5 @@ namespace b8\Type;
interface RestUser
{
- public function checkPermission($permission, $resource);
-}
\ No newline at end of file
+ public function checkPermission($permission, $resource);
+}
diff --git a/src/B8Framework/View/Helper/Format.php b/src/B8Framework/View/Helper/Format.php
index ea0628f0..0295d6dd 100755
--- a/src/B8Framework/View/Helper/Format.php
+++ b/src/B8Framework/View/Helper/Format.php
@@ -4,8 +4,8 @@ namespace b8\View\Helper;
class Format
{
- public function Currency($number, $symbol = true)
- {
- return ($symbol ? '£' : '') . number_format($number, 2, '.', ',');
- }
-}
\ No newline at end of file
+ public function Currency($number, $symbol = true)
+ {
+ return ($symbol ? '£' : '') . number_format($number, 2, '.', ',');
+ }
+}
diff --git a/src/B8Framework/View/Template.php b/src/B8Framework/View/Template.php
index 6200cef0..e650152b 100755
--- a/src/B8Framework/View/Template.php
+++ b/src/B8Framework/View/Template.php
@@ -7,7 +7,7 @@ use b8\View;
class Template extends View
{
public static $templateFunctions = [];
- protected static $extension = 'html';
+ protected static $extension = 'html';
public function __construct($viewCode)
{
@@ -267,9 +267,9 @@ class Template extends View
$rtn = '';
foreach ($working as $key => $val) {
// Make sure we support nesting loops:
- $keyWas = isset($this->key) ? $this->key : null;
- $valWas = isset($this->value) ? $this->value : null;
- $itemWas = isset($this->item) ? $this->item : null;
+ $keyWas = isset($this->key) ? $this->key : null;
+ $valWas = isset($this->value) ? $this->value : null;
+ $itemWas = isset($this->item) ? $this->item : null;
// Set up the necessary variables within the stack:
$this->parent = $this;
@@ -537,4 +537,4 @@ class Template extends View
return $this->{$helper}()->{$function}();
}
-}
\ No newline at end of file
+}
diff --git a/src/B8Framework/View/UserView.php b/src/B8Framework/View/UserView.php
index 954f9a42..541606c1 100755
--- a/src/B8Framework/View/UserView.php
+++ b/src/B8Framework/View/UserView.php
@@ -2,8 +2,6 @@
namespace b8\View;
-use b8\View\Template;
-
class UserView extends Template
{
public function __construct($string)
@@ -11,4 +9,4 @@ class UserView extends Template
trigger_error('Use of UserView is now deprecated. Please use Template instead.', E_USER_NOTICE);
parent::__construct($string);
}
-}
\ No newline at end of file
+}
diff --git a/src/PHPCI/Application.php b/src/PHPCI/Application.php
index 264c5423..ef5823fd 100644
--- a/src/PHPCI/Application.php
+++ b/src/PHPCI/Application.php
@@ -64,7 +64,7 @@ class Application extends b8\Application
} else {
$_SESSION['phpci_login_redirect'] = substr($request->getPath(), 1);
$response = new RedirectResponse($response);
- $response->setHeader('Location', PHPCI_URL.'session/login');
+ $response->setHeader('Location', PHPCI_URL . 'session/login');
}
return false;
diff --git a/src/PHPCI/Builder.php b/src/PHPCI/Builder.php
index 8300f9fe..a2bbf2f6 100644
--- a/src/PHPCI/Builder.php
+++ b/src/PHPCI/Builder.php
@@ -110,7 +110,7 @@ class Builder implements LoggerAwareInterface
$this->buildLogger = new BuildLogger($logger, $build);
$pluginFactory = $this->buildPluginFactory($build);
- $pluginFactory->addConfigFromFile(PHPCI_DIR . "/app/pluginconfig.php");
+ $pluginFactory->addConfigFromFile(PHPCI_APP_DIR . "pluginconfig.php");
$this->pluginExecutor = new Plugin\Util\Executor($pluginFactory, $this->buildLogger);
$executorClass = 'PHPCI\Helper\UnixCommandExecutor';
@@ -120,7 +120,7 @@ class Builder implements LoggerAwareInterface
$this->commandExecutor = new $executorClass(
$this->buildLogger,
- PHPCI_DIR,
+ ROOT_DIR,
$this->quiet,
$this->verbose
);
diff --git a/src/PHPCI/Command/DaemonCommand.php b/src/PHPCI/Command/DaemonCommand.php
index dba50ced..631ccfa7 100644
--- a/src/PHPCI/Command/DaemonCommand.php
+++ b/src/PHPCI/Command/DaemonCommand.php
@@ -62,19 +62,19 @@ class DaemonCommand extends Command
->setDescription('Initiates the daemon to run commands.')
->addArgument(
'state', InputArgument::REQUIRED, 'start|stop|status'
- )
- ->addOption(
- 'pid-file', 'p', InputOption::VALUE_REQUIRED,
+ )->addOption(
+ 'pid-file',
+ 'p',
+ InputOption::VALUE_REQUIRED,
'Path of the PID file',
- implode(DIRECTORY_SEPARATOR,
- [PHPCI_DIR, 'daemon', 'daemon.pid'])
- )
- ->addOption(
- 'log-file', 'l', InputOption::VALUE_REQUIRED,
+ (ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR . 'daemon' . DIRECTORY_SEPARATOR . 'daemon.pid')
+ )->addOption(
+ 'log-file',
+ 'l',
+ InputOption::VALUE_REQUIRED,
'Path of the log file',
- implode(DIRECTORY_SEPARATOR,
- [PHPCI_DIR, 'daemon', 'daemon.log'])
- );
+ (ROOT_DIR . 'runtime' . DIRECTORY_SEPARATOR . 'daemon' . DIRECTORY_SEPARATOR . 'daemon.log')
+ );
}
/**
@@ -113,8 +113,8 @@ class DaemonCommand extends Command
$this->logger->info("Trying to start the daemon");
- $cmd = "nohup %s/daemonise phpci:daemonise > %s 2>&1 &";
- $command = sprintf($cmd, PHPCI_DIR, $this->logFilePath);
+ $cmd = "nohup %sdaemonise phpci:daemonise > %s 2>&1 &";
+ $command = sprintf($cmd, PHPCI_BIN_DIR, $this->logFilePath);
$output = $exitCode = null;
exec($command, $output, $exitCode);
diff --git a/src/PHPCI/Command/DaemoniseCommand.php b/src/PHPCI/Command/DaemoniseCommand.php
index 601d8636..c683ce47 100644
--- a/src/PHPCI/Command/DaemoniseCommand.php
+++ b/src/PHPCI/Command/DaemoniseCommand.php
@@ -65,14 +65,14 @@ class DaemoniseCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $cmd = "echo %s > '%s/daemon/daemon.pid'";
- $command = sprintf($cmd, getmypid(), PHPCI_DIR);
+ $cmd = "echo %s > '%sdaemon/daemon.pid'";
+ $command = sprintf($cmd, getmypid(), PHPCI_RUNTIME_DIR);
exec($command);
$this->output = $output;
- $this->run = true;
- $this->sleep = 0;
- $runner = new RunCommand($this->logger);
+ $this->run = true;
+ $this->sleep = 0;
+ $runner = new RunCommand($this->logger);
$runner->setMaxBuilds(1);
$runner->setDaemon(true);
diff --git a/src/PHPCI/Command/GenerateCommand.php b/src/PHPCI/Command/GenerateCommand.php
deleted file mode 100644
index 096d1a76..00000000
--- a/src/PHPCI/Command/GenerateCommand.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
-* @package PHPCI
-* @subpackage Console
-*/
-class GenerateCommand extends Command
-{
- protected function configure()
- {
- $this
- ->setName('phpci:generate')
- ->setDescription('Generate models and stores from the database.');
- }
-
- /**
- * Generates Model and Store classes by reading database meta data.
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $gen = new CodeGenerator(
- Database::getConnection(),
- ['default' => 'PHPCI'],
- ['default' => PHPCI_DIR],
- false
- );
-
- $gen->generateModels();
- $gen->generateStores();
- }
-}
diff --git a/src/PHPCI/Command/InstallCommand.php b/src/PHPCI/Command/InstallCommand.php
index b7c80aa9..46840068 100644
--- a/src/PHPCI/Command/InstallCommand.php
+++ b/src/PHPCI/Command/InstallCommand.php
@@ -35,8 +35,8 @@ class InstallCommand extends Command
protected function configure()
{
- $defaultPath = PHPCI_DIR . 'PHPCI/config.yml';
-
+ $defaultPath = PHPCI_APP_DIR . 'config.yml';
+
$this
->setName('phpci:install')
->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url'))
@@ -363,8 +363,8 @@ class InstallCommand extends Command
{
$output->write(Lang::get('setting_up_db'));
- $phinxBinary = escapeshellarg(PHPCI_DIR . 'vendor/bin/phinx');
- $phinxScript = escapeshellarg(PHPCI_DIR . 'app/phinx.php');
+ $phinxBinary = escapeshellarg(ROOT_DIR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'phinx');
+ $phinxScript = escapeshellarg(PHPCI_APP_DIR . 'phinx.php');
shell_exec($phinxBinary . ' migrate -c ' . $phinxScript);
$output->writeln(''.Lang::get('ok').'');
diff --git a/src/PHPCI/Command/PollCommand.php b/src/PHPCI/Command/PollCommand.php
index bbd2b7f9..d3894c5a 100644
--- a/src/PHPCI/Command/PollCommand.php
+++ b/src/PHPCI/Command/PollCommand.php
@@ -51,7 +51,7 @@ class PollCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
$parser = new Parser();
- $yaml = file_get_contents(APPLICATION_PATH . 'PHPCI/config.yml');
+ $yaml = file_get_contents(PHPCI_APP_DIR . 'config.yml');
$this->settings = $parser->parse($yaml);
$token = $this->settings['phpci']['github']['token'];
diff --git a/src/PHPCI/Command/UpdateCommand.php b/src/PHPCI/Command/UpdateCommand.php
index 2ac94db0..bd8b18bf 100644
--- a/src/PHPCI/Command/UpdateCommand.php
+++ b/src/PHPCI/Command/UpdateCommand.php
@@ -53,7 +53,7 @@ class UpdateCommand extends Command
$output->write(Lang::get('updating_phpci'));
- shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'app/phinx.php"');
+ shell_exec(ROOT_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_APP_DIR . 'phinx.php"');
$output->writeln(''.Lang::get('ok').'');
}
diff --git a/src/PHPCI/Controller/BuildController.php b/src/PHPCI/Controller/BuildController.php
index 76ce96c1..38f018ed 100644
--- a/src/PHPCI/Controller/BuildController.php
+++ b/src/PHPCI/Controller/BuildController.php
@@ -107,9 +107,9 @@ class BuildController extends \PHPCI\Controller
*/
protected function getUiPlugins()
{
- $rtn = [];
- $path = APPLICATION_PATH . 'public/assets/js/build-plugins/';
- $dir = opendir($path);
+ $rtn = [];
+ $path = PHPCI_PUBLIC_DIR . 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'build-plugins' . DIRECTORY_SEPARATOR;
+ $dir = opendir($path);
while ($item = readdir($dir)) {
if (substr($item, 0, 1) == '.' || substr($item, -3) != '.js') {
diff --git a/src/PHPCI/Controller/PluginController.php b/src/PHPCI/Controller/PluginController.php
index 64cb1463..8f718fda 100644
--- a/src/PHPCI/Controller/PluginController.php
+++ b/src/PHPCI/Controller/PluginController.php
@@ -35,11 +35,9 @@ class PluginController extends \PHPCI\Controller
$this->view->installedPackages = $json['require'];
$pluginInfo = new PluginInformationCollection();
- $pluginInfo->add(FilesPluginInformation::newFromDir(
- PHPCI_DIR . "PHPCI/Plugin/"
- ));
+ $pluginInfo->add(FilesPluginInformation::newFromDir(PHPCI_DIR . "Plugin" . DIRECTORY_SEPARATOR));
$pluginInfo->add(ComposerPluginInformation::buildFromYaml(
- PHPCI_DIR . "vendor/composer/installed.json"
+ ROOT_DIR . "vendor" . DIRECTORY_SEPARATOR . "composer" . DIRECTORY_SEPARATOR . "installed.json"
));
$this->view->plugins = $pluginInfo->getInstalledPlugins();
@@ -55,7 +53,7 @@ class PluginController extends \PHPCI\Controller
*/
protected function getComposerJson()
{
- $json = file_get_contents(APPLICATION_PATH . 'composer.json');
+ $json = file_get_contents(ROOT_DIR . 'composer.json');
return json_decode($json, true);
}
}
diff --git a/src/PHPCI/Controller/SettingsController.php b/src/PHPCI/Controller/SettingsController.php
index 0b3b1526..f0bbd2c7 100644
--- a/src/PHPCI/Controller/SettingsController.php
+++ b/src/PHPCI/Controller/SettingsController.php
@@ -40,7 +40,7 @@ class SettingsController extends Controller
parent::init();
$parser = new Parser();
- $yaml = file_get_contents(PHPCI_CONFIG_FILE);
+ $yaml = file_get_contents(PHPCI_APP_DIR . 'config.yml');
$this->settings = $parser->parse($yaml);
}
@@ -76,7 +76,7 @@ class SettingsController extends Controller
$authSettings = $this->settings['phpci']['authentication_settings'];
}
- $this->view->configFile = PHPCI_CONFIG_FILE;
+ $this->view->configFile = PHPCI_APP_DIR . 'config.yml';
$this->view->basicSettings = $this->getBasicForm($basicSettings);
$this->view->buildSettings = $this->getBuildForm($buildSettings);
$this->view->github = $this->getGithubForm();
@@ -242,7 +242,7 @@ class SettingsController extends Controller
{
$dumper = new Dumper();
$yaml = $dumper->dump($this->settings, 4);
- file_put_contents(PHPCI_CONFIG_FILE, $yaml);
+ file_put_contents(PHPCI_APP_DIR . 'config.yml', $yaml);
if (error_get_last()) {
$error_get_last = error_get_last();
@@ -387,7 +387,7 @@ class SettingsController extends Controller
*/
protected function canWriteConfig()
{
- return is_writeable(PHPCI_CONFIG_FILE);
+ return is_writeable(PHPCI_APP_DIR . 'config.yml');
}
/**
diff --git a/src/PHPCI/Helper/BaseCommandExecutor.php b/src/PHPCI/Helper/BaseCommandExecutor.php
index f9f62bf8..68b2d1e5 100644
--- a/src/PHPCI/Helper/BaseCommandExecutor.php
+++ b/src/PHPCI/Helper/BaseCommandExecutor.php
@@ -59,11 +59,11 @@ abstract class BaseCommandExecutor implements CommandExecutor
*/
public function __construct(BuildLogger $logger, $rootDir, &$quiet = false, &$verbose = false)
{
- $this->logger = $logger;
- $this->quiet = $quiet;
+ $this->logger = $logger;
+ $this->quiet = $quiet;
$this->verbose = $verbose;
$this->lastOutput = [];
- $this->rootDir = rtrim($rootDir, '/\\') . DIRECTORY_SEPARATOR;
+ $this->rootDir = $rootDir;
}
/**
@@ -158,9 +158,9 @@ abstract class BaseCommandExecutor implements CommandExecutor
foreach ($binary as $bin) {
$this->logger->log(Lang::get('looking_for_binary', $bin), LogLevel::DEBUG);
- if (is_dir($composerBin) && is_file($composerBin.'/'.$bin)) {
+ if (is_dir($composerBin) && is_file($composerBin . DIRECTORY_SEPARATOR . $bin)) {
$this->logger->log(Lang::get('found_in_path', $composerBin, $bin), LogLevel::DEBUG);
- return $composerBin . '/' . $bin;
+ return $composerBin . DIRECTORY_SEPARATOR . $bin;
}
if (is_file($this->rootDir . $bin)) {
@@ -168,9 +168,9 @@ abstract class BaseCommandExecutor implements CommandExecutor
return $this->rootDir . $bin;
}
- if (is_file($this->rootDir . 'vendor/bin/' . $bin)) {
+ if (is_file($this->rootDir . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . $bin)) {
$this->logger->log(Lang::get('found_in_path', 'vendor/bin', $bin), LogLevel::DEBUG);
- return $this->rootDir . 'vendor/bin/' . $bin;
+ return $this->rootDir . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . $bin;
}
$findCmdResult = $this->findGlobalBinary($bin);
@@ -202,14 +202,14 @@ abstract class BaseCommandExecutor implements CommandExecutor
public function getComposerBinDir($path)
{
if (is_dir($path)) {
- $composer = $path.'/composer.json';
+ $composer = $path . DIRECTORY_SEPARATOR . 'composer.json';
if (is_file($composer)) {
$json = json_decode(file_get_contents($composer));
if (isset($json->config->{"bin-dir"})) {
- return $path.'/'.$json->config->{"bin-dir"};
- } elseif (is_dir($path . '/vendor/bin')) {
- return $path . '/vendor/bin';
+ return $path . DIRECTORY_SEPARATOR . $json->config->{"bin-dir"};
+ } elseif (is_dir($path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin')) {
+ return $path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin';
}
}
}
diff --git a/src/PHPCI/Helper/Diff.php b/src/PHPCI/Helper/Diff.php
index a66d5a8d..38afacc0 100644
--- a/src/PHPCI/Helper/Diff.php
+++ b/src/PHPCI/Helper/Diff.php
@@ -9,10 +9,6 @@
namespace PHPCI\Helper;
-use b8\Cache;
-use b8\Config;
-use b8\HttpClient;
-
/**
* Provides some basic diff processing functionality.
* @package PHPCI\Helper
diff --git a/src/PHPCI/Helper/Lang.php b/src/PHPCI/Helper/Lang.php
index 84ad434e..d829f83a 100644
--- a/src/PHPCI/Helper/Lang.php
+++ b/src/PHPCI/Helper/Lang.php
@@ -103,11 +103,9 @@ class Lang
public static function getLanguageOptions()
{
$languages = [];
-
foreach (self::$languages as $language) {
- $strings = [];
- require(PHPCI_DIR . 'src/PHPCI/Languages/lang.' . $language . '.php');
- $languages[$language] = $strings['language_name'];
+ $strings = include_once(PHPCI_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php');
+ $languages[$language] = !empty($strings['language_name']) ? $strings['language_name'] : $language;
}
return $languages;
@@ -172,16 +170,14 @@ class Lang
*/
protected static function loadLanguage($language = null)
{
- $language = $language
- ? $language
- : self::$language;
- $langFile = PHPCI_DIR . 'src/PHPCI/Languages/lang.' . $language . '.php';
+ $language = $language ? $language : self::$language;
+ $langFile = PHPCI_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php';
if (!file_exists($langFile)) {
return null;
}
- require($langFile);
+ $strings = include_once($langFile);
if (is_null($strings) || !is_array($strings) || !count($strings)) {
return null;
@@ -196,7 +192,7 @@ class Lang
protected static function loadAvailableLanguages()
{
$matches = [];
- foreach (glob(PHPCI_DIR . 'src/PHPCI/Languages/lang.*.php') as $file) {
+ foreach (glob(PHPCI_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.*.php') as $file) {
if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) {
self::$languages[] = $matches[1];
}
diff --git a/src/PHPCI/Languages/lang.da.php b/src/PHPCI/Languages/lang.da.php
index a061476e..829c4b5d 100644
--- a/src/PHPCI/Languages/lang.da.php
+++ b/src/PHPCI/Languages/lang.da.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Dansk',
'language' => 'Sprog',
diff --git a/src/PHPCI/Languages/lang.de.php b/src/PHPCI/Languages/lang.de.php
index 2f9078e8..f1399687 100644
--- a/src/PHPCI/Languages/lang.de.php
+++ b/src/PHPCI/Languages/lang.de.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Deutsch',
'language' => 'Sprache',
diff --git a/src/PHPCI/Languages/lang.el.php b/src/PHPCI/Languages/lang.el.php
index 2d5e5bfd..bd51a22e 100644
--- a/src/PHPCI/Languages/lang.el.php
+++ b/src/PHPCI/Languages/lang.el.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Ελληνικά',
'language' => 'Γλώσσα',
diff --git a/src/PHPCI/Languages/lang.en.php b/src/PHPCI/Languages/lang.en.php
index 069412db..9dff9b22 100644
--- a/src/PHPCI/Languages/lang.en.php
+++ b/src/PHPCI/Languages/lang.en.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings =[
+return [
'language_name' => 'English',
'language' => 'Language',
diff --git a/src/PHPCI/Languages/lang.es.php b/src/PHPCI/Languages/lang.es.php
index a687bca5..38b545c0 100644
--- a/src/PHPCI/Languages/lang.es.php
+++ b/src/PHPCI/Languages/lang.es.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Español',
'language' => 'Lenguaje',
diff --git a/src/PHPCI/Languages/lang.fr.php b/src/PHPCI/Languages/lang.fr.php
index 8aad8284..2950a80f 100644
--- a/src/PHPCI/Languages/lang.fr.php
+++ b/src/PHPCI/Languages/lang.fr.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Français',
'language' => 'Langue',
diff --git a/src/PHPCI/Languages/lang.it.php b/src/PHPCI/Languages/lang.it.php
index 0c8604d2..0e4931ae 100644
--- a/src/PHPCI/Languages/lang.it.php
+++ b/src/PHPCI/Languages/lang.it.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Italiano',
'language' => 'Lingua',
diff --git a/src/PHPCI/Languages/lang.nl.php b/src/PHPCI/Languages/lang.nl.php
index f397bc0b..5f2d1a84 100644
--- a/src/PHPCI/Languages/lang.nl.php
+++ b/src/PHPCI/Languages/lang.nl.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Nederlands',
'language' => 'Taal',
diff --git a/src/PHPCI/Languages/lang.pl.php b/src/PHPCI/Languages/lang.pl.php
index bc7afeef..2f83d413 100644
--- a/src/PHPCI/Languages/lang.pl.php
+++ b/src/PHPCI/Languages/lang.pl.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Polski',
'language' => 'Język',
diff --git a/src/PHPCI/Languages/lang.ru.php b/src/PHPCI/Languages/lang.ru.php
index ae727310..fcd223fc 100644
--- a/src/PHPCI/Languages/lang.ru.php
+++ b/src/PHPCI/Languages/lang.ru.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Pусский',
'language' => 'язык',
diff --git a/src/PHPCI/Languages/lang.uk.php b/src/PHPCI/Languages/lang.uk.php
index f091c4e1..b8d0e891 100644
--- a/src/PHPCI/Languages/lang.uk.php
+++ b/src/PHPCI/Languages/lang.uk.php
@@ -7,7 +7,7 @@
* @link https://www.phptesting.org/
*/
-$strings = [
+return [
'language_name' => 'Українська',
'language' => 'Мова',
diff --git a/src/PHPCI/Model/Build.php b/src/PHPCI/Model/Build.php
index b0ef4971..6b3322fc 100644
--- a/src/PHPCI/Model/Build.php
+++ b/src/PHPCI/Model/Build.php
@@ -135,7 +135,7 @@ class Build extends BuildBase
*/
protected function getZeroConfigPlugins(Builder $builder)
{
- $pluginDir = PHPCI_DIR . 'PHPCI/Plugin/';
+ $pluginDir = PHPCI_DIR . 'Plugin' . DIRECTORY_SEPARATOR;
$dir = new \DirectoryIterator($pluginDir);
$config = [
@@ -257,8 +257,8 @@ class Build extends BuildBase
}
if (empty($this->currentBuildPath)) {
- $buildDirectory = $this->getId() . '_' . substr(md5(microtime(true)), 0, 5);
- $this->currentBuildPath = PHPCI_BUILD_ROOT_DIR . $buildDirectory . DIRECTORY_SEPARATOR;
+ $buildDirectory = $this->getId() . '_' . substr(md5(microtime(true)), 0, 5);
+ $this->currentBuildPath = PHPCI_BUILDS_DIR . $buildDirectory . DIRECTORY_SEPARATOR;
}
return $this->currentBuildPath;
diff --git a/src/PHPCI/Plugin/PhpTalLint.php b/src/PHPCI/Plugin/PhpTalLint.php
index fe9fefa1..d5124a25 100644
--- a/src/PHPCI/Plugin/PhpTalLint.php
+++ b/src/PHPCI/Plugin/PhpTalLint.php
@@ -202,10 +202,10 @@ class PhpTalLint implements PHPCI\Plugin
list($suffixes, $tales) = $this->getFlags();
- $lint = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
+ $lint = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
$lint .= 'vendor' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR;
$lint .= 'tools' . DIRECTORY_SEPARATOR . 'phptal_lint.php';
- $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"';
+ $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"';
$this->phpci->executeCommand($cmd, $suffixes, $tales, $this->phpci->buildPath . $path);
diff --git a/src/PHPCI/Plugin/Shell.php b/src/PHPCI/Plugin/Shell.php
index afb2659b..a97e07fe 100644
--- a/src/PHPCI/Plugin/Shell.php
+++ b/src/PHPCI/Plugin/Shell.php
@@ -79,10 +79,6 @@ class Shell implements \PHPCI\Plugin
*/
public function execute()
{
- if (!defined('ENABLE_SHELL_PLUGIN') || !ENABLE_SHELL_PLUGIN) {
- throw new \Exception(Lang::get('shell_not_enabled'));
- }
-
$success = true;
foreach ($this->commands as $command) {
diff --git a/src/PHPCI/View/layout.phtml b/src/PHPCI/View/layout.phtml
index 7f6fe56e..457c62f0 100644
--- a/src/PHPCI/View/layout.phtml
+++ b/src/PHPCI/View/layout.phtml
@@ -313,7 +313,7 @@
-
+
diff --git a/tests/B8Framework/CodeGenerationTest.php b/tests/B8Framework/CodeGenerationTest.php
deleted file mode 100644
index e7822fe2..00000000
--- a/tests/B8Framework/CodeGenerationTest.php
+++ /dev/null
@@ -1,573 +0,0 @@
-set('b8.app.namespace', 'Generation');
-
- self::$_db = Database::getConnection('write');
-
- self::$_db->query('DROP TABLE IF EXISTS tres');
- self::$_db->query('DROP TABLE IF EXISTS dos');
- self::$_db->query('DROP TABLE IF EXISTS uno');
-
- self::$_base = dirname(__FILE__) . '/data/generation/';
- $gen = new Generator(self::$_db, 'Test', self::$_base . 'models/');
- $gen->generate();
- }
-
- public static function tearDownAfterClass()
- {
- self::$_db->query('DROP TABLE IF EXISTS tres');
- self::$_db->query('DROP TABLE IF EXISTS dos');
- self::$_db->query('DROP TABLE IF EXISTS uno');
-
- unlink(self::$_base . 'Generation/Model/Base/UnoBase.php');
- unlink(self::$_base . 'Generation/Model/Base/DosBase.php');
- unlink(self::$_base . 'Generation/Model/Base/TresBase.php');
- unlink(self::$_base . 'Generation/Store/Base/UnoStoreBase.php');
- unlink(self::$_base . 'Generation/Store/Base/DosStoreBase.php');
- unlink(self::$_base . 'Generation/Store/Base/TresStoreBase.php');
- unlink(self::$_base . 'Generation/Controller/Base/UnoControllerBase.php');
- unlink(self::$_base . 'Generation/Controller/Base/DosControllerBase.php');
- unlink(self::$_base . 'Generation/Controller/Base/TresControllerBase.php');
- unlink(self::$_base . 'Generation/Model/Uno.php');
- unlink(self::$_base . 'Generation/Model/Dos.php');
- unlink(self::$_base . 'Generation/Model/Tres.php');
- unlink(self::$_base . 'Generation/Store/UnoStore.php');
- unlink(self::$_base . 'Generation/Store/DosStore.php');
- unlink(self::$_base . 'Generation/Store/TresStore.php');
- unlink(self::$_base . 'Generation/Controller/UnoController.php');
- unlink(self::$_base . 'Generation/Controller/DosController.php');
- unlink(self::$_base . 'Generation/Controller/TresController.php');
- }
-
- public function testGenerate()
- {
- error_reporting(E_ALL);
- $codeGenerator = new CodeGenerator(self::$_db, 'Generation', self::$_base . 'Generation/');
- $codeGenerator->generateModels();
- $codeGenerator->generateStores();
- $codeGenerator->generateControllers();
-
- $this->assertFileExists(self::$_base . 'Generation/Model/Base/UnoBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Model/Base/DosBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Model/Base/TresBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/Base/UnoStoreBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/Base/DosStoreBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/Base/TresStoreBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/Base/UnoControllerBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/Base/DosControllerBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/Base/TresControllerBase.php');
- $this->assertFileExists(self::$_base . 'Generation/Model/Uno.php');
- $this->assertFileExists(self::$_base . 'Generation/Model/Dos.php');
- $this->assertFileExists(self::$_base . 'Generation/Model/Tres.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/UnoStore.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/DosStore.php');
- $this->assertFileExists(self::$_base . 'Generation/Store/TresStore.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/UnoController.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/DosController.php');
- $this->assertFileExists(self::$_base . 'Generation/Controller/TresController.php');
- }
-
- /**
- * @depends testGenerate
- */
- public function testGeneratedModels()
- {
- if (!defined('APPLICATION_PATH')) {
- define('APPLICATION_PATH', self::$_base);
- }
-
- require_once(self::$_base . 'Generation/Model/Base/UnoBase.php');
- require_once(self::$_base . 'Generation/Model/Base/DosBase.php');
- require_once(self::$_base . 'Generation/Model/Base/TresBase.php');
- require_once(self::$_base . 'Generation/Model/Uno.php');
- require_once(self::$_base . 'Generation/Model/Dos.php');
- require_once(self::$_base . 'Generation/Model/Tres.php');
- require_once(self::$_base . 'ArrayPropertyModel.php');
-
- $uno = new Generation\Model\Uno();
- $dos = new Generation\Model\Dos();
- $tres = new Generation\Model\Tres();
-
- $this->assertTrue($uno instanceof b8\Model);
- $this->assertTrue($dos instanceof b8\Model);
- $this->assertTrue($tres instanceof b8\Model);
-
- $this->assertTrue($uno instanceof Generation\Model\Base\UnoBase);
- $this->assertTrue($dos instanceof Generation\Model\Base\DosBase);
- $this->assertTrue($tres instanceof Generation\Model\Base\TresBase);
-
- $this->assertTrue($uno->getTableName() == 'uno');
- $this->assertTrue($dos->getTableName() == 'dos');
- $this->assertTrue($tres->getTableName() == 'tres');
-
- $uno->setId(1);
- $uno->setFieldDatetime(new DateTime());
- $this->assertTrue($uno->getFieldDatetime() instanceof DateTime);
-
- $unoArray = $uno->toArray();
- $this->assertArrayHasKey('field_varchar', $unoArray);
- $this->assertTrue($unoArray['field_datetime'] instanceof DateTime);
-
- Generation\Model\Uno::$sleepable = ['id', 'field_varchar'];
- $unoArray = $uno->toArray();
- $this->assertArrayHasKey('field_varchar', $unoArray);
- $this->assertFalse(array_key_exists('field_datetime', $unoArray));
-
- $tres->setField($uno);
- $this->assertTrue($tres->getFieldInt() == 1);
-
- $this->assertTrue(in_array('id', $uno->getModified()));
- $this->assertTrue(is_array($uno->getDataArray()));
-
- $uno->setValues(['field_int' => 100, 'field_bob' => 100]);
- $this->assertFalse(in_array('field_bob', $uno->getModified()));
- $this->assertTrue($uno->getFieldInt() === 100);
-
- $uno->setFieldInt(true);
- $this->assertTrue($uno->getFieldInt() === 1);
-
- $caught = false;
-
- try {
- $uno->setFieldInt('invalid');
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $uno->setFieldInt('500');
- $this->assertTrue($uno->getFieldInt() === 500);
-
- $caught = false;
-
- try {
- $uno->setFieldFloat('invalid');
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $uno->setFieldFloat('4.12');
- $this->assertTrue($uno->getFieldFloat() === 4.12);
-
-
- $uno->setFieldDatetime('2014-01-01');
- $this->assertTrue($uno->getFieldDatetime() instanceof DateTime);
-
- $caught = false;
-
- try {
- $uno->setFieldDatetime(2012);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $caught = false;
-
- try {
- $uno->setFieldInt(null);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $caught = false;
-
- try {
- $uno->setValues(['field_int' => 'null']);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $uno->setValues(['field_int' => 'true']);
- $this->assertTrue($uno->getFieldInt() === 1);
-
- $uno->setValues(['field_int' => 'false']);
- $this->assertTrue($uno->getFieldInt() === 0);
-
- $caught = false;
-
- try {
- $uno->setFieldVarchar(false);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $caught = false;
-
- try {
- $uno->setFieldVarchar('Hi');
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertFalse($caught);
-
- // Test toArray() with an array property:
- $aModel = new Generation\ArrayPropertyModel();
- $array = $aModel->toArray();
-
- $this->assertArrayHasKey('array_property', $array);
- $this->assertTrue(is_array($array['array_property']));
- $this->assertTrue(is_array($array['array_property']['three']));
- $this->assertTrue($array['array_property']['one'] == 'two');
- }
-
- /**
- * @depends testGeneratedModels
- */
- public function testGeneratedStores()
- {
- require_once(self::$_base . 'Generation/Store/Base/UnoStoreBase.php');
- require_once(self::$_base . 'Generation/Store/Base/DosStoreBase.php');
- require_once(self::$_base . 'Generation/Store/Base/TresStoreBase.php');
- require_once(self::$_base . 'Generation/Store/UnoStore.php');
- require_once(self::$_base . 'Generation/Store/DosStore.php');
- require_once(self::$_base . 'Generation/Store/TresStore.php');
-
- $uno = new Generation\Store\UnoStore();
- $dos = new Generation\Store\DosStore();
- $tres = new Generation\Store\TresStore();
-
- $this->assertTrue($uno instanceof b8\Store);
- $this->assertTrue($dos instanceof b8\Store);
- $this->assertTrue($tres instanceof b8\Store);
-
- $this->assertTrue($uno instanceof Generation\Store\Base\UnoStoreBase);
- $this->assertTrue($dos instanceof Generation\Store\Base\DosStoreBase);
- $this->assertTrue($tres instanceof Generation\Store\Base\TresStoreBase);
-
- $tresModel = new Generation\Model\Tres();
- $tresModel->setFieldVarchar('Hi');
-
- $caught = false;
-
- try {
- $tres->save($tresModel);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $caught = false;
-
- try {
- $uno->save($tresModel);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $unoModel = new Generation\Model\Uno();
- $unoModel->setFieldVarchar('Hi');
-
- $unoModel = $uno->save($unoModel);
- $id = $unoModel->getId();
- $this->assertTrue(!empty($id));
- $this->assertTrue($unoModel->getFieldVarchar() == 'Hi');
-
- $unoModel->setFieldVarchar('Ha');
- $unoModel = $uno->save($unoModel);
- $this->assertTrue($id == $unoModel->getId());
- $this->assertTrue($unoModel->getFieldVarchar() == 'Ha');
-
- $unoModel = $uno->save($unoModel);
- $this->assertTrue($id == $unoModel->getId());
- $this->assertTrue($unoModel->getFieldVarchar() == 'Ha');
-
- $unoModel2 = $uno->getByPrimaryKey($id);
- $this->assertTrue($unoModel2->getId() == $unoModel->getId());
-
- $res = $uno->getWhere(['field_varchar' => 'Ha']);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => ['operator' => 'between', 'value' => [0, 100]]]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => ['operator' => 'IN', 'value' => [1, 2, 3, 4]]]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => ['operator' => '!=', 'value' => ['null', 100]]]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => ['operator' => '==', 'value' => ['null']]]);
- $this->assertTrue($res['count'] == 0);
-
- $res = $uno->getWhere(['id' => ['operator' => '==', 'value' => 'null']]);
- $this->assertTrue($res['count'] == 0);
-
- $res = $uno->getWhere(['id' => ['operator' => '!=', 'value' => 'null']]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['field_varchar' => ['operator' => 'like', 'value' => 'Ha']]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['field_varchar' => ['operator' => '!=', 'value' => 'Hi']]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['field_varchar' => ['Ha', 'Hi']]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => 1], 1, 0, ['dos' => ['alias' => 'd', 'on' => 'd.id = uno.id']], ['id' => 'ASC']);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => 1], 1, 0, ['dos' => ['alias' => 'd', 'on' => 'd.id = uno.id']], 'rand');
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => 1], 1, 10);
- $this->assertTrue(count($res['items']) == 0 && $res['count'] == 1);
-
-
- $caught = false;
-
- try {
- $uno->getWhere(['invalid_column' => 1]);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $res = $uno->getWhere(['id' => 1], 1, 0, [], 'rand', ['LEFT JOIN dos d ON d.id = uno.id']);
- $this->assertTrue($res['count'] != 0);
-
-
- $res = $uno->getWhere(['id' => 1], 1, 0, [], 'rand', [], 'field_varchar');
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere([], 1, 0, [], 'rand', [], null, [['type' => 'AND', 'query' => 'id = 1', 'params' => []]]);
- $this->assertTrue($res['count'] != 0);
-
- $res = $uno->getWhere(['id' => 2], 1, 0, [], 'rand', [], null,
- [['type' => 'AND', 'query' => 'id = ?', 'params' => ['id']]]);
- $this->assertTrue($res['count'] == 0);
-
- $caught = false;
-
- try {
- $uno->getWhere(['' => 1]);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- // ----
- // Tests for Model::toArray() with relationships:
- // ----
- $tresModel->setField($unoModel);
- $array = $tresModel->toArray();
-
- $this->assertTrue(array_key_exists('Field', $array));
- $this->assertTrue(array_key_exists('id', $array['Field']));
- $this->assertTrue($array['Field']['id'] == $unoModel->getId());
-
- // ----
- // Tests for Store::delete()
- // ----
-
- $caught = false;
- try {
- $tres->delete($tresModel);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $caught = false;
- try {
- $uno->delete($tresModel);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $this->assertTrue($uno->delete($unoModel));
- $this->assertTrue(is_null($uno->getByPrimaryKey(1)));
- }
-
- /**
- * @depends testGeneratedStores
- */
- public function testGeneratedControllers()
- {
- require_once(self::$_base . 'Generation/Controller/Base/UnoControllerBase.php');
- require_once(self::$_base . 'Generation/Controller/Base/DosControllerBase.php');
- require_once(self::$_base . 'Generation/Controller/Base/TresControllerBase.php');
- require_once(self::$_base . 'Generation/Controller/UnoController.php');
- require_once(self::$_base . 'Generation/Controller/DosController.php');
- require_once(self::$_base . 'Generation/Controller/TresController.php');
- require_once(self::$_base . 'TestUser.php');
-
- $uno = new Generation\Controller\UnoController();
- $dos = new Generation\Controller\DosController();
- $tres = new Generation\Controller\TresController();
-
- $uno->init();
- $dos->init();
- $tres->init();
-
- $this->assertTrue($uno instanceof b8\Controller);
- $this->assertTrue($dos instanceof b8\Controller);
- $this->assertTrue($tres instanceof b8\Controller);
-
- $this->assertTrue($uno instanceof Generation\Controller\Base\UnoControllerBase);
- $this->assertTrue($dos instanceof Generation\Controller\Base\DosControllerBase);
- $this->assertTrue($tres instanceof Generation\Controller\Base\TresControllerBase);
-
- $config = new Config();
- Config::getInstance()->set('hello', 'world');
-
- $this->assertTrue($uno->getParam('hello', 'dave') == 'world');
-
- $uno->setParam('hello', 'dave');
- $this->assertTrue($uno->getParam('hello', 'world') == 'dave');
- $this->assertTrue(array_key_exists('hello', $uno->getParams()));
-
- $uno->unsetParam('hello');
- $this->assertFalse(array_key_exists('hello', $uno->getParams()));
-
- $testUser = new \TestUser();
- $uno->setActiveUser($testUser);
- $dos->setActiveUser($uno->getActiveUser());
- $tres->setActiveUser($uno->getActiveUser());
-
- $unoModel = new Generation\Model\Uno();
- $unoStore = \b8\Store\Factory::getStore('Uno');
- $unoModel->setFieldVarchar('Hi');
-
- $unoStore->save($unoModel);
- $list = $uno->index();
-
- $this->assertTrue(is_array($list));
- $this->assertTrue(is_array($list['items']));
- $this->assertTrue(count($list['items']) > 0);
-
- $caught = false;
- try {
- $dos->index();
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $first = array_shift($list['items']);
-
- $uno1 = $uno->get($first['id']);
- $this->assertTrue(is_array($uno1));
- $this->assertTrue(isset($uno1['uno']));
- $this->assertTrue($uno1['uno']['id'] == $first['id']);
-
- $caught = false;
- try {
- $dos->get(1);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
-
- $uno->setParam('field_varchar', 'Un');
- $uno1 = $uno->put($first['id']);
- $this->assertTrue($uno1['uno']['id'] == $first['id']);
-
- $caught = false;
- try {
- $dos->put(1);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
- $this->assertTrue(is_null($uno->put(10000)));
-
-
- $uno->setParam('field_text', 'Hello');
- $res = $uno->post();
- $this->assertTrue($res['uno']['field_varchar'] == 'Un');
- $this->assertTrue(!empty($res['uno']['id']));
-
- $caught = false;
- try {
- $dos->post();
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- $del = $uno->delete($res['uno']['id']);
- $this->assertTrue($del['deleted']);
-
- $del = $uno->delete($res['uno']['id']);
- $this->assertFalse($del['deleted']);
-
- $del = $tres->delete(100);
- $this->assertFalse($del['deleted']);
-
- $caught = false;
- try {
- $dos->delete(1000);
- } catch (Exception $ex) {
- $caught = true;
- }
-
- $this->assertTrue($caught);
-
- //----
- // Tests for _parseWhere()
- //----
- $uno->setParam('where', ['id' => [1000]]);
- $uno->setParam('neq', 'id');
- $list = $uno->index();
-
- $this->assertTrue(is_array($list));
- $this->assertTrue(count($list['items']) != 0);
-
- $uno->setParam('where', ['id' => 1000]);
- $uno->setParam('fuzzy', 'id');
- $list = $uno->index();
-
- $this->assertTrue(is_array($list));
- $this->assertTrue(count($list['items']) == 0);
- }
-}
diff --git a/tests/B8Framework/DatabaseGenerationTest.php b/tests/B8Framework/DatabaseGenerationTest.php
index 2042dfe3..fd51864e 100644
--- a/tests/B8Framework/DatabaseGenerationTest.php
+++ b/tests/B8Framework/DatabaseGenerationTest.php
@@ -26,7 +26,7 @@ class DatabaseGenerationTest extends \PHPUnit_Framework_TestCase
public function testCreateDatabase()
{
- $gen = new Generator($this->_db, 'Test', dirname(__FILE__) . '/data/generation/models/');
+ $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/');
$gen->generate();
$map = new Map($this->_db);
@@ -49,10 +49,10 @@ class DatabaseGenerationTest extends \PHPUnit_Framework_TestCase
public function testUpdateDatabase()
{
- $gen = new Generator($this->_db, 'Test', dirname(__FILE__) . '/data/generation/models/');
+ $gen = new Generator($this->_db, 'Test', __DIR__ . '/data/generation/models/');
$gen->generate();
- $gen = new Generator($this->_db, 'Update', dirname(__FILE__) . '/data/generation/update_models/');
+ $gen = new Generator($this->_db, 'Update', __DIR__ . '/data/generation/update_models/');
$gen->generate();
$map = new Map($this->_db);
diff --git a/tests/B8Framework/FormTest.php b/tests/B8Framework/FormTest.php
index 6678d42f..b0e6b4cd 100755
--- a/tests/B8Framework/FormTest.php
+++ b/tests/B8Framework/FormTest.php
@@ -16,7 +16,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($f->getMethod() == 'POST');
$config = new Config();
- Config::getInstance()->set('ViewPath', dirname(__FILE__) . '/data/view/');
+ Config::getInstance()->set('ViewPath', __DIR__ . '/data/view/');
$this->assertTrue($f->render('form') == '/POST');
diff --git a/tests/B8Framework/ViewTest.php b/tests/B8Framework/ViewTest.php
index d8dd3900..0b925477 100755
--- a/tests/B8Framework/ViewTest.php
+++ b/tests/B8Framework/ViewTest.php
@@ -8,7 +8,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
{
public function testSimpleView()
{
- $view = new View('simple', dirname(__FILE__) . '/data/view/');
+ $view = new View('simple', __DIR__ . '/data/view/');
$this->assertTrue($view->render() == 'Hello');
}
@@ -17,12 +17,12 @@ class ViewTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidView()
{
- new View('dogs', dirname(__FILE__) . '/data/view/');
+ new View('dogs', __DIR__ . '/data/view/');
}
public function testViewVars()
{
- $view = new View('vars', dirname(__FILE__) . '/data/view/');
+ $view = new View('vars', __DIR__ . '/data/view/');
$view->who = 'World';
$this->assertTrue(isset($view->who));
@@ -32,7 +32,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
public function testFormatViewHelper()
{
- $view = new View('format', dirname(__FILE__) . '/data/view/');
+ $view = new View('format', __DIR__ . '/data/view/');
$view->number = 1000000.25;
$view->symbol = true;
diff --git a/tests/B8Framework/data/generation/ArrayPropertyModel.php b/tests/B8Framework/data/generation/ArrayPropertyModel.php
deleted file mode 100755
index d6237ad3..00000000
--- a/tests/B8Framework/data/generation/ArrayPropertyModel.php
+++ /dev/null
@@ -1,18 +0,0 @@
-_getters['array_property'] = 'getArrayProperty';
- self::$sleepable[] = 'array_property';
- }
-
- public function getArrayProperty()
- {
- return ['one' => 'two', 'three' => ['four' => 'five']];
- }
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/TestUser.php b/tests/B8Framework/data/generation/TestUser.php
deleted file mode 100755
index 324f8459..00000000
--- a/tests/B8Framework/data/generation/TestUser.php
+++ /dev/null
@@ -1,13 +0,0 @@
- ['type' => 'catfish'],
- ];
-
- public $indexes = [];
- public $foreignKeys = [];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/models/Dos.php b/tests/B8Framework/data/generation/models/Dos.php
deleted file mode 100755
index 20e31f96..00000000
--- a/tests/B8Framework/data/generation/models/Dos.php
+++ /dev/null
@@ -1,24 +0,0 @@
- ['type' => 'int', 'primary_key' => true, 'auto_increment' => false],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250', 'default' => 'Hello World'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- ];
-
- public $indexes = [
- 'PRIMARY' => ['unique' => true, 'columns' => 'id'],
- 'idx_test_1' => ['unique' => true, 'columns' => 'field_int'],
- 'idx_test_2' => ['columns' => 'field_datetime'],
- ];
- public $foreignKeys = [];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/models/Tres.php b/tests/B8Framework/data/generation/models/Tres.php
deleted file mode 100755
index 45bf5faf..00000000
--- a/tests/B8Framework/data/generation/models/Tres.php
+++ /dev/null
@@ -1,35 +0,0 @@
- ['type' => 'int'],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250'],
- 'field_date' => ['type' => 'date'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- 'field_int_2' => ['type' => 'int'],
- ];
-
- public $indexes = [
- 'fk_tres_uno' => ['columns' => 'field_int'],
- 'fk_tres_dos' => ['columns' => 'field_int_2'],
- ];
-
- public $foreignKeys = [
- 'fk_tres_uno' => ['local_col' => 'field_int', 'table' => 'uno', 'col' => 'id'],
- 'fk_tres_dos' => [
- 'local_col' => 'field_int_2',
- 'update' => 'NO ACTION',
- 'delete' => 'CASCADE',
- 'table' => 'dos',
- 'col' => 'id'
- ],
- ];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/models/Uno.php b/tests/B8Framework/data/generation/models/Uno.php
deleted file mode 100755
index 01cc7540..00000000
--- a/tests/B8Framework/data/generation/models/Uno.php
+++ /dev/null
@@ -1,27 +0,0 @@
- ['type' => 'int', 'primary_key' => true, 'auto_increment' => true],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250'],
- 'field_text' => ['type' => 'text'],
- 'field_ltext' => ['type' => 'longtext'],
- 'field_mtext' => ['type' => 'mediumtext'],
- 'field_date' => ['type' => 'date'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- 'field_tinyint' => ['type' => 'tinyint', 'length' => '1'],
- 'field_float' => ['type' => 'float'],
- 'field_double' => ['type' => 'double', 'length' => '15,2'],
- ];
-
- public $indexes = [];
- public $foreignKeys = [];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/models/ignore.file b/tests/B8Framework/data/generation/models/ignore.file
deleted file mode 100755
index e69de29b..00000000
diff --git a/tests/B8Framework/data/generation/update_models/Dos.php b/tests/B8Framework/data/generation/update_models/Dos.php
deleted file mode 100755
index de58edd1..00000000
--- a/tests/B8Framework/data/generation/update_models/Dos.php
+++ /dev/null
@@ -1,24 +0,0 @@
- ['type' => 'int', 'primary_key' => true, 'auto_increment' => true],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250', 'default' => 'Hello World'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- ];
-
- public $indexes = [
- 'PRIMARY' => ['unique' => true, 'columns' => 'id'],
- 'idx_test_1' => ['unique' => false, 'columns' => 'field_int'],
- 'idx_test_2' => ['columns' => 'field_datetime'],
- ];
- public $foreignKeys = [];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/update_models/Tres.php b/tests/B8Framework/data/generation/update_models/Tres.php
deleted file mode 100755
index fd1b4d11..00000000
--- a/tests/B8Framework/data/generation/update_models/Tres.php
+++ /dev/null
@@ -1,46 +0,0 @@
- ['type' => 'int', 'primary_key' => true, 'auto_increment' => true],
- 'id' => ['type' => 'int'],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250', 'default' => 'Hello World'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- 'field_int_2' => ['type' => 'int'],
- 'field_dt' => ['type' => 'date', 'rename' => 'field_date'],
- 'field_float_1' => ['type' => 'float', 'default' => '1'],
- 'field_varchar_2' => ['type' => 'varchar', 'length' => '10', 'default' => 'Hello'],
- 'dosid' => ['type' => 'int'],
- ];
-
- public $indexes = [
- 'PRIMARY' => ['unique' => true, 'columns' => 'key_col'],
- 'fk_tres_dos' => ['columns' => 'field_int_2'],
- 'fk_tres_dos_2' => ['columns' => 'dosid'],
- ];
-
- public $foreignKeys = [
- 'fk_tres_dos' => [
- 'local_col' => 'field_int_2',
- 'update' => 'CASCADE',
- 'delete' => 'CASCADE',
- 'table' => 'dos',
- 'col' => 'id'
- ],
- 'fk_tres_dos_2' => [
- 'local_col' => 'dosid',
- 'update' => 'CASCADE',
- 'delete' => 'CASCADE',
- 'table' => 'dos',
- 'col' => 'id'
- ],
- ];
-}
\ No newline at end of file
diff --git a/tests/B8Framework/data/generation/update_models/Uno.php b/tests/B8Framework/data/generation/update_models/Uno.php
deleted file mode 100755
index 689e9a45..00000000
--- a/tests/B8Framework/data/generation/update_models/Uno.php
+++ /dev/null
@@ -1,26 +0,0 @@
- ['type' => 'int', 'primary_key' => true],
- 'field_varchar' => ['type' => 'varchar', 'length' => '250'],
- 'field_text' => ['type' => 'text'],
- 'field_ltext' => ['type' => 'longtext'],
- 'field_mtext' => ['type' => 'mediumtext'],
- 'field_datetime' => ['type' => 'datetime'],
- 'field_int' => ['type' => 'int'],
- 'field_tinyint' => ['type' => 'tinyint', 'length' => '1'],
- 'field_float' => ['type' => 'float'],
- 'field_double' => ['type' => 'double', 'length' => '15,2'],
- ];
-
- public $indexes = [];
- public $foreignKeys = [];
-}
\ No newline at end of file
diff --git a/tests/PHPCI/Plugin/PharTest.php b/tests/PHPCI/Plugin/PharTest.php
index 10d907fe..7ac9669d 100644
--- a/tests/PHPCI/Plugin/PharTest.php
+++ b/tests/PHPCI/Plugin/PharTest.php
@@ -39,7 +39,7 @@ class PharTest extends \PHPUnit_Framework_TestCase
protected function buildTemp()
{
- $directory = tempnam(APPLICATION_PATH . '/Tests/temp', 'source');
+ $directory = tempnam(ROOT_DIR . 'tests' . DIRECTORY_SEPARATOR . 'PHPCI' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR, 'source');
unlink($directory);
return $directory;
}
diff --git a/vars.php b/vars.php
deleted file mode 100644
index 41811582..00000000
--- a/vars.php
+++ /dev/null
@@ -1,42 +0,0 @@
-get('phpci.url', '') . '/');
-}
-
-// Define PHPCI_BIN_DIR
-if (!defined('PHPCI_BIN_DIR')) {
- define('PHPCI_BIN_DIR', PHPCI_DIR . 'vendor/bin/');
-}
-
-// Define PHPCI_BUILD_ROOT_DIR
-if (!defined('PHPCI_BUILD_ROOT_DIR')) {
- define('PHPCI_BUILD_ROOT_DIR', PHPCI_DIR . 'runtime/builds/');
-}
-
-// Should PHPCI run the Shell plugin?
-if (!defined('ENABLE_SHELL_PLUGIN')) {
- define('ENABLE_SHELL_PLUGIN', false);
-}
-
-// If this is not already defined, we're not running in the console:
-if (!defined('PHPCI_IS_CONSOLE')) {
- define('PHPCI_IS_CONSOLE', false);
-}
-
-if (!defined('IS_WIN')) {
- define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false));
-}
-
-// If an environment variable is set defining our config location, use that
-// otherwise fall back to PHPCI/config.yml.
-if (!defined('PHPCI_CONFIG_FILE')) {
- define('PHPCI_CONFIG_FILE', $configFile);
-}