Merge pull request #2388 from MPOS/development
UPDATE : Development to Master
This commit is contained in:
commit
f996118d17
4
.gitignore
vendored
4
.gitignore
vendored
@ -34,3 +34,7 @@
|
||||
/public/sitemap.gz
|
||||
/public/sitemap.tar.gz
|
||||
/public/.htaccess
|
||||
|
||||
/vendor/
|
||||
|
||||
tests/_output/*
|
||||
9
.scrutinizer.yml
Normal file
9
.scrutinizer.yml
Normal file
@ -0,0 +1,9 @@
|
||||
tools:
|
||||
external_code_coverage: true
|
||||
checks:
|
||||
php:
|
||||
code_rating: true
|
||||
duplication: true
|
||||
filter:
|
||||
paths:
|
||||
- include/classes/*
|
||||
41
.travis.yml
Normal file
41
.travis.yml
Normal file
@ -0,0 +1,41 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
|
||||
|
||||
install:
|
||||
- wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
|
||||
- composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
|
||||
- composer install
|
||||
|
||||
|
||||
before_script:
|
||||
- sudo chmod 777 /etc/hosts
|
||||
- echo 127.0.0.1 mining > /etc/hosts
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- sleep 5
|
||||
- java -jar selenium-server-standalone-2.42.2.jar -port 4444 &
|
||||
- "mysql -e 'create database mpos;'"
|
||||
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('mining') WHERE user='travis';\nFLUSH PRIVILEGES;\n" | mysql -u root
|
||||
- nohup php -S bone:8000 public/index.php &
|
||||
|
||||
script:
|
||||
- php vendor/bin/codecept run unit --coverage --coverage-html --coverage-xml --env travis
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
|
||||
@ -1,6 +1,4 @@
|
||||
0.0.1 (Mar 7th 2013)
|
||||
1.0.0 (Jan 18th 2015)
|
||||
--------------------
|
||||
|
||||
* WiP Upload of all files currently available
|
||||
* Added upstream script collections
|
||||
* Added SQL structure
|
||||
* First (non-beta) public release of MPOS
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
[](https://travis-ci.org/MPOS/php-mpos) [](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) [](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=master) master<br />
|
||||
[](https://travis-ci.org/MPOS/php-mpos) [](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=development) [](https://scrutinizer-ci.com/g/MPOS/php-mpos/?branch=development) development
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
|
||||
21
codeception.yml
Normal file
21
codeception.yml
Normal file
@ -0,0 +1,21 @@
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
data: tests/_data
|
||||
helpers: tests/_support
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
coverage:
|
||||
whitelist:
|
||||
include:
|
||||
- include/classes/*
|
||||
14
composer.json
Normal file
14
composer.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "delboy1978uk/mpos",
|
||||
"description": "MPOS stands for Mining Portal Open Source. A unified mining interface for various Scrypt and SHA256d Crypto-currencies!",
|
||||
"require-dev": {
|
||||
"codeception/codeception": "~2.0"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Derek Stephen McLean",
|
||||
"email": "delboy1978uk@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {}
|
||||
}
|
||||
1358
composer.lock
generated
Normal file
1358
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
* Also the URL to check for the most recent upstream versions available
|
||||
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-version
|
||||
**/
|
||||
$config['version'] = '0.0.8';
|
||||
$config['version'] = '1.0.0';
|
||||
$config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/master/include/version.inc.php';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
define('MPOS_VERSION', '0.0.4');
|
||||
define('DB_VERSION', '0.0.15');
|
||||
define('CONFIG_VERSION', '0.0.8');
|
||||
define('MPOS_VERSION', '1.0.0');
|
||||
define('DB_VERSION', '1.0.0');
|
||||
define('CONFIG_VERSION', '1.0.0');
|
||||
define('HASH_VERSION', 1);
|
||||
|
||||
// Fetch installed database version
|
||||
|
||||
@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `blocks` (
|
||||
`accounted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`account_id` int(255) unsigned DEFAULT NULL,
|
||||
`worker_name` varchar(50) DEFAULT 'unknown',
|
||||
`shares` int(255) unsigned DEFAULT NULL,
|
||||
`shares` bigint(30) unsigned DEFAULT NULL,
|
||||
`share_id` bigint(30) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `height` (`height`,`blockhash`),
|
||||
@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `settings` (
|
||||
UNIQUE KEY `setting` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.15');
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '1.0.0');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `shares` (
|
||||
`id` bigint(30) NOT NULL AUTO_INCREMENT,
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE `statistics_shares` ADD `pplns_valid` int(11) NOT NULL AFTER `invalid` ;
|
||||
ALTER TABLE `statistics_shares` ADD `pplns_invalid` int(11) NOT NULL DEFAULT 0 AFTER `pplns_valid` ;
|
||||
@ -1 +0,0 @@
|
||||
ALTER TABLE `settings` CHANGE `value` `value` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;
|
||||
@ -1 +0,0 @@
|
||||
ALTER TABLE `monitoring` CHANGE `value` `value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
|
||||
@ -1 +0,0 @@
|
||||
ALTER TABLE `blocks` ADD `worker_name` varchar(50) DEFAULT 'unknown' AFTER `account_id`;
|
||||
@ -1,7 +0,0 @@
|
||||
CREATE TABLE `templates` (
|
||||
`template` varchar(255) NOT NULL,
|
||||
`active` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`content` mediumtext,
|
||||
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`template`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@ -1 +0,0 @@
|
||||
ALTER TABLE `transactions` ADD `txid` VARCHAR( 256 ) NULL DEFAULT NULL AFTER `timestamp` ;
|
||||
@ -1 +0,0 @@
|
||||
ALTER TABLE `accounts` ADD `failed_pins` INT NOT NULL AFTER `failed_logins` ;
|
||||
@ -1,4 +0,0 @@
|
||||
ALTER TABLE `shares_archive` ADD INDEX ( `username` ) ;
|
||||
ALTER TABLE `shares_archive` ADD INDEX ( `share_id` ) ;
|
||||
ALTER TABLE `shares_archive` ADD INDEX ( `our_result` ) ;
|
||||
ALTER TABLE `shares_archive` ADD INDEX ( `time` ) ;
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE `token_types` ADD `expiration` INT NULL DEFAULT '0';
|
||||
UPDATE `token_types` SET `expiration` = 3600 WHERE `id` = 1;
|
||||
@ -1 +0,0 @@
|
||||
INSERT INTO `token_types` (`name`, `expiration`) VALUES ('account_unlock', 0);
|
||||
@ -1,2 +0,0 @@
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.1') ON DUPLICATE KEY UPDATE `value` = '0.0.1';
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('db_upgrade_required', 0) ON DUPLICATE KEY UPDATE `value` = 0;
|
||||
24
tests/_bootstrap.php
Normal file
24
tests/_bootstrap.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
||||
|
||||
// Set a decently long SECURITY key with special chars etc
|
||||
define('SECURITY', '*)WT#&YHfd');
|
||||
// Whether or not to check SECHASH for validity, still checks if SECURITY defined as before if disabled
|
||||
define('SECHASH_CHECK', false);
|
||||
|
||||
// change SECHASH every second, we allow up to 3 sec back for slow servers
|
||||
if (SECHASH_CHECK) {
|
||||
function fip($tr=0) { return md5(SECURITY.(time()-$tr).SECURITY); }
|
||||
define('SECHASH', fip());
|
||||
function cfip() { return (fip()==SECHASH||fip(1)==SECHASH||fip(2)==SECHASH) ? 1 : 0; }
|
||||
} else {
|
||||
function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
|
||||
}
|
||||
|
||||
|
||||
define("BASEPATH", dirname(__FILE__) . "/");
|
||||
|
||||
define('INCLUDE_DIR', BASEPATH . '../include');
|
||||
define('CLASS_DIR', INCLUDE_DIR . '/classes');
|
||||
define('PAGES_DIR', INCLUDE_DIR . '/pages');
|
||||
define('TEMPLATE_DIR', BASEPATH . '../templates');
|
||||
1
tests/_data/dump.sql
Normal file
1
tests/_data/dump.sql
Normal file
@ -0,0 +1 @@
|
||||
/* Replace this file with actual dump of your database */
|
||||
10
tests/_support/AcceptanceHelper.php
Normal file
10
tests/_support/AcceptanceHelper.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class AcceptanceHelper extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
||||
10
tests/_support/FunctionalHelper.php
Normal file
10
tests/_support/FunctionalHelper.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class FunctionalHelper extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
||||
10
tests/_support/UnitHelper.php
Normal file
10
tests/_support/UnitHelper.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Codeception\Module;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class UnitHelper extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
||||
14
tests/acceptance.suite.yml
Normal file
14
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,14 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for acceptance tests.
|
||||
# perform tests in browser using the WebDriver or PhpBrowser.
|
||||
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
|
||||
|
||||
class_name: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser
|
||||
- AcceptanceHelper
|
||||
config:
|
||||
PhpBrowser:
|
||||
url: 'http://mining.del/'
|
||||
1556
tests/acceptance/AcceptanceTester.php
Normal file
1556
tests/acceptance/AcceptanceTester.php
Normal file
File diff suppressed because it is too large
Load Diff
2
tests/acceptance/_bootstrap.php
Normal file
2
tests/acceptance/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
9
tests/functional.suite.yml
Normal file
9
tests/functional.suite.yml
Normal file
@ -0,0 +1,9 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for functional (integration) tests.
|
||||
# emulate web requests and make application process them.
|
||||
# Include one of framework modules (Symfony2, Yii2, Laravel4) to use it.
|
||||
|
||||
class_name: FunctionalTester
|
||||
modules:
|
||||
enabled: [Filesystem, FunctionalHelper]
|
||||
358
tests/functional/FunctionalTester.php
Normal file
358
tests/functional/FunctionalTester.php
Normal file
@ -0,0 +1,358 @@
|
||||
<?php //[STAMP] 47dce5eee849a0c25cc1be002f0699ff
|
||||
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
|
||||
use Codeception\Module\Filesystem;
|
||||
use Codeception\Module\FunctionalHelper;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method void haveFriend($name)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Enters a directory In local filesystem.
|
||||
* Project root directory is used by default
|
||||
*
|
||||
* @param $path
|
||||
* @see \Codeception\Module\Filesystem::amInPath()
|
||||
*/
|
||||
public function amInPath($path) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Condition('amInPath', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Opens a file and stores it's content.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->seeInThisFile('codeception/codeception');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $filename
|
||||
* @see \Codeception\Module\Filesystem::openFile()
|
||||
*/
|
||||
public function openFile($filename) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('openFile', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Deletes a file
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->deleteFile('composer.lock');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $filename
|
||||
* @see \Codeception\Module\Filesystem::deleteFile()
|
||||
*/
|
||||
public function deleteFile($filename) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('deleteFile', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Deletes directory with all subdirectories
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->deleteDir('vendor');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $dirname
|
||||
* @see \Codeception\Module\Filesystem::deleteDir()
|
||||
*/
|
||||
public function deleteDir($dirname) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('deleteDir', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Copies directory with all contents
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->copyDir('vendor','old_vendor');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $src
|
||||
* @param $dst
|
||||
* @see \Codeception\Module\Filesystem::copyDir()
|
||||
*/
|
||||
public function copyDir($src, $dst) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('copyDir', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file has `text` in it.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->seeInThisFile('codeception/codeception');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::seeInThisFile()
|
||||
*/
|
||||
public function canSeeInThisFile($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file has `text` in it.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->seeInThisFile('codeception/codeception');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* @see \Codeception\Module\Filesystem::seeInThisFile()
|
||||
*/
|
||||
public function seeInThisFile($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks the strict matching of file contents.
|
||||
* Unlike `seeInThisFile` will fail if file has something more then expected lines.
|
||||
* Better to use with HEREDOC strings.
|
||||
* Matching is done after removing "\r" chars from file content.
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('process.pid');
|
||||
* $I->seeFileContentsEqual('3192');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::seeFileContentsEqual()
|
||||
*/
|
||||
public function canSeeFileContentsEqual($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks the strict matching of file contents.
|
||||
* Unlike `seeInThisFile` will fail if file has something more then expected lines.
|
||||
* Better to use with HEREDOC strings.
|
||||
* Matching is done after removing "\r" chars from file content.
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('process.pid');
|
||||
* $I->seeFileContentsEqual('3192');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* @see \Codeception\Module\Filesystem::seeFileContentsEqual()
|
||||
*/
|
||||
public function seeFileContentsEqual($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file doesn't contain `text` in it
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->dontSeeInThisFile('codeception/codeception');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::dontSeeInThisFile()
|
||||
*/
|
||||
public function cantSeeInThisFile($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file doesn't contain `text` in it
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->dontSeeInThisFile('codeception/codeception');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $text
|
||||
* @see \Codeception\Module\Filesystem::dontSeeInThisFile()
|
||||
*/
|
||||
public function dontSeeInThisFile($text) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInThisFile', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Deletes a file
|
||||
* @see \Codeception\Module\Filesystem::deleteThisFile()
|
||||
*/
|
||||
public function deleteThisFile() {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('deleteThisFile', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file exists in path.
|
||||
* Opens a file when it's exists
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->seeFileFound('UserModel.php','app/models');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $filename
|
||||
* @param string $path
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::seeFileFound()
|
||||
*/
|
||||
public function canSeeFileFound($filename, $path = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file exists in path.
|
||||
* Opens a file when it's exists
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->seeFileFound('UserModel.php','app/models');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $filename
|
||||
* @param string $path
|
||||
* @see \Codeception\Module\Filesystem::seeFileFound()
|
||||
*/
|
||||
public function seeFileFound($filename, $path = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file does not exists in path
|
||||
*
|
||||
* @param $filename
|
||||
* @param string $path
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::dontSeeFileFound()
|
||||
*/
|
||||
public function cantSeeFileFound($filename, $path = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFileFound', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file does not exists in path
|
||||
*
|
||||
* @param $filename
|
||||
* @param string $path
|
||||
* @see \Codeception\Module\Filesystem::dontSeeFileFound()
|
||||
*/
|
||||
public function dontSeeFileFound($filename, $path = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeFileFound', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Erases directory contents
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->cleanDir('logs');
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param $dirname
|
||||
* @see \Codeception\Module\Filesystem::cleanDir()
|
||||
*/
|
||||
public function cleanDir($dirname) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('cleanDir', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Saves contents to file
|
||||
*
|
||||
* @param $filename
|
||||
* @param $contents
|
||||
* @see \Codeception\Module\Filesystem::writeToFile()
|
||||
*/
|
||||
public function writeToFile($filename, $contents) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('writeToFile', func_get_args()));
|
||||
}
|
||||
}
|
||||
2
tests/functional/_bootstrap.php
Normal file
2
tests/functional/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
6
tests/unit.suite.yml
Normal file
6
tests/unit.suite.yml
Normal file
@ -0,0 +1,6 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for unit (internal) tests.
|
||||
class_name: UnitTester
|
||||
modules:
|
||||
enabled: [Asserts, UnitHelper]
|
||||
23
tests/unit/BitcoinTest.php
Normal file
23
tests/unit/BitcoinTest.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once(CLASS_DIR . '/bitcoin.class.php');
|
||||
|
||||
class BitcoinTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
|
||||
public function _before()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function _after()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testAddressToHash160()
|
||||
{
|
||||
$bitcoin = new Bitcoin();
|
||||
$this->assertEquals('82839EADFB204C8D22ED122A0868C6F52B5BDFC9',$bitcoin->addressToHash160('1Cu6X3c716CCKU3Bi2jfHv8kZ2QCor8uXm'));
|
||||
}
|
||||
}
|
||||
58
tests/unit/SecurityCSRFTokenTest.php
Normal file
58
tests/unit/SecurityCSRFTokenTest.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Stub;
|
||||
|
||||
class SecurityCSRFTokenTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
public function _before()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function _after()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests if a CSRF token succeeds for a matching user and type
|
||||
*/
|
||||
public function testCSRFToken_success() {
|
||||
// global $config;
|
||||
// global $user;
|
||||
// global $csrftoken;
|
||||
//
|
||||
// // no delay
|
||||
// // TODO: simulate delay without a sleep ? test length
|
||||
// $created_token = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
|
||||
// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
|
||||
// $this->assertTrue($test_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a CSRF token correctly fails
|
||||
*/
|
||||
public function testCSRFToken_fail() {
|
||||
// global $config;
|
||||
// global $user;
|
||||
// global $csrftoken;
|
||||
//
|
||||
// // differing user
|
||||
// $created_token = $csrftoken->getBasic('not the same', 'test-token');
|
||||
// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
|
||||
// $this->assertFalse($test_token);
|
||||
//
|
||||
// // differing type
|
||||
// $created_token2 = $csrftoken->getBasic($user->getCurrentIP(), 'not the same');
|
||||
// $test_token2 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token2);
|
||||
// $this->assertFalse($test_token2);
|
||||
//
|
||||
// // token slightly shortened
|
||||
// $created_token3 = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
|
||||
// $created_token3 = substr($created_token3, 0, (strlen($created_token3)-1));
|
||||
// $test_token3 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token3);
|
||||
// $this->assertFalse($test_token3);
|
||||
}
|
||||
}
|
||||
|
||||
32
tests/unit/SecuritySessionsTest.php
Normal file
32
tests/unit/SecuritySessionsTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Security_Sessions extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* Tests if our current session checking will throw errors or take a malformed id
|
||||
*/
|
||||
public function testSessions_destruction_malformed_id()
|
||||
{
|
||||
// global $config;
|
||||
//
|
||||
// $malformed_ids = array(
|
||||
// "",
|
||||
// "'",
|
||||
// "9881o1ke7ia4k5*p1k28e6utg0"
|
||||
// );
|
||||
//
|
||||
// foreach ($malformed_ids as $mid) {
|
||||
// session_set_cookie_params(time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
|
||||
// $session_start = @session_start();
|
||||
// if (!$session_start) {
|
||||
// session_destroy();
|
||||
// session_regenerate_id(true);
|
||||
// session_start();
|
||||
// }
|
||||
// @setcookie(session_name(), session_id(), time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
|
||||
// $this->assertNotEquals($mid, session_id());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
26
tests/unit/SecurityTokensTest.php
Normal file
26
tests/unit/SecurityTokensTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class Security_Tokens extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* Tests tokens CRUD
|
||||
*/
|
||||
public function testTokens_CRUD()
|
||||
{
|
||||
// global $config;
|
||||
// global $mysqli;
|
||||
// $mysqli = new DBConnection($config);
|
||||
// global $tokentype;
|
||||
// global $oToken;
|
||||
// // grab token types first so we can test them all
|
||||
// $token_types = $tokentype->getAll();
|
||||
//
|
||||
// foreach ($token_types as $tt)
|
||||
// {
|
||||
// // create
|
||||
// $create_token = $oToken->createToken($tt['name'], 1);
|
||||
// $this->assertStringMatchesFormat('%x', $create_token);
|
||||
// $this->assertGreaterThan(16, strlen($create_token));
|
||||
// }
|
||||
}
|
||||
}
|
||||
214
tests/unit/UnitTester.php
Normal file
214
tests/unit/UnitTester.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php //[STAMP] b219486ab7e4b78d3283a629a658cc66
|
||||
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
|
||||
use Codeception\Module\Asserts;
|
||||
use Codeception\Module\UnitHelper;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method void haveFriend($name)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @return mixed
|
||||
* @see \Codeception\Module\Asserts::assertEquals()
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that two variables are not equal
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotEquals()
|
||||
*/
|
||||
public function assertNotEquals($expected, $actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that expected is greater then actual
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThen()
|
||||
*/
|
||||
public function assertGreaterThen($expected, $actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that expected is greater or equal then actual
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
|
||||
*/
|
||||
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that haystack contains needle
|
||||
*
|
||||
* @param $needle
|
||||
* @param $haystack
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertContains()
|
||||
*/
|
||||
public function assertContains($needle, $haystack, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertContains', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that haystack doesn't contain needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param $haystack
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotContains()
|
||||
*/
|
||||
public function assertNotContains($needle, $haystack, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is empty.
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertEmpty()
|
||||
*/
|
||||
public function assertEmpty($actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is not empty.
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotEmpty()
|
||||
*/
|
||||
public function assertNotEmpty($actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is NULL
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNull()
|
||||
*/
|
||||
public function assertNull($actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNull', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that variable is not NULL
|
||||
*
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertNotNull()
|
||||
*/
|
||||
public function assertNotNull($actual, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that condition is positive.
|
||||
*
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertTrue()
|
||||
*/
|
||||
public function assertTrue($condition, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertTrue', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that condition is negative.
|
||||
*
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFalse()
|
||||
*/
|
||||
public function assertFalse($condition, $message = null) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertFalse', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Fails the test with message.
|
||||
*
|
||||
* @param $message
|
||||
* @see \Codeception\Module\Asserts::fail()
|
||||
*/
|
||||
public function fail($message) {
|
||||
return $this->scenario->runStep(new \Codeception\Step\Action('fail', func_get_args()));
|
||||
}
|
||||
}
|
||||
2
tests/unit/_bootstrap.php
Normal file
2
tests/unit/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
// these are ONLY here because we're checking config options
|
||||
// these should NOT be in a normal unit test
|
||||
|
||||
class TestDistConfig extends PHPUnit_Framework_Testcase {
|
||||
/**
|
||||
* Test to make sure SALT is sane
|
||||
*/
|
||||
function testSaltLength() {
|
||||
$this->assertNotEmpty($config['SALT']);
|
||||
$this->assertGreaterThan(1, strlen($config['SALTY']));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Security_CSRFToken extends PHPUnit_Framework_Testcase {
|
||||
/**
|
||||
* Tests if a CSRF token succeeds for a matching user and type
|
||||
*/
|
||||
function testCSRFToken_success() {
|
||||
global $config;
|
||||
global $user;
|
||||
global $csrftoken;
|
||||
|
||||
// no delay
|
||||
// TODO: simulate delay without a sleep ? test length
|
||||
$created_token = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
|
||||
$test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
|
||||
$this->assertTrue($test_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a CSRF token correctly fails
|
||||
*/
|
||||
function testCSRFToken_fail() {
|
||||
global $config;
|
||||
global $user;
|
||||
global $csrftoken;
|
||||
|
||||
// differing user
|
||||
$created_token = $csrftoken->getBasic('not the same', 'test-token');
|
||||
$test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
|
||||
$this->assertFalse($test_token);
|
||||
|
||||
// differing type
|
||||
$created_token2 = $csrftoken->getBasic($user->getCurrentIP(), 'not the same');
|
||||
$test_token2 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token2);
|
||||
$this->assertFalse($test_token2);
|
||||
|
||||
// token slightly shortened
|
||||
$created_token3 = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
|
||||
$created_token3 = substr($created_token3, 0, (strlen($created_token3)-1));
|
||||
$test_token3 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token3);
|
||||
$this->assertFalse($test_token3);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Security_Sessions extends PHPUnit_Framework_Testcase {
|
||||
/**
|
||||
* Tests if our current session checking will throw errors or take a malformed id
|
||||
*/
|
||||
function testSessions_destruction_malformed_id() {
|
||||
global $config;
|
||||
|
||||
$malformed_ids = array(
|
||||
"",
|
||||
"'",
|
||||
"9881o1ke7ia4k5*p1k28e6utg0"
|
||||
);
|
||||
|
||||
foreach ($malformed_ids as $mid) {
|
||||
session_set_cookie_params(time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
|
||||
$session_start = @session_start();
|
||||
if (!$session_start) {
|
||||
session_destroy();
|
||||
session_regenerate_id(true);
|
||||
session_start();
|
||||
}
|
||||
@setcookie(session_name(), session_id(), time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
|
||||
$this->assertNotEquals($mid, session_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Security_Tokens extends PHPUnit_Framework_Testcase {
|
||||
/**
|
||||
* Tests tokens CRUD
|
||||
*/
|
||||
function testTokens_CRUD() {
|
||||
global $config;
|
||||
global $mysqli;
|
||||
$mysqli = new DBConnection($config);
|
||||
global $tokentype;
|
||||
global $oToken;
|
||||
// grab token types first so we can test them all
|
||||
$token_types = $tokentype->getAll();
|
||||
|
||||
foreach ($token_types as $tt) {
|
||||
// create
|
||||
$create_token = $oToken->createToken($tt['name'], 1);
|
||||
$this->assertStringMatchesFormat('%x', $create_token);
|
||||
$this->assertGreaterThan(16, strlen($create_token));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
30
upgrade/definitions/0.0.15_to_1.0.0.inc.php
Executable file
30
upgrade/definitions/0.0.15_to_1.0.0.inc.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
function run_100() {
|
||||
// Ugly but haven't found a better way
|
||||
global $setting, $config, $statistics, $block, $mysqli;
|
||||
|
||||
// Version information
|
||||
$db_version_old = '0.0.15'; // What version do we expect
|
||||
$db_version_new = '1.0.0'; // What is the new version we wish to upgrade to
|
||||
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed
|
||||
|
||||
// Upgrade specific variables
|
||||
$aSql[] = "ALTER TABLE `blocks` CHANGE `shares` `shares` BIGINT(30) unsigned DEFAULT NULL";
|
||||
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '1.0.0' WHERE name = 'DB_VERSION'";
|
||||
|
||||
if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
|
||||
// Run the upgrade
|
||||
echo '- Starting database migration to version ' . $db_version_new . PHP_EOL;
|
||||
foreach ($aSql as $sql) {
|
||||
echo '- Preparing: ' . $sql . PHP_EOL;
|
||||
$stmt = $mysqli->prepare($sql);
|
||||
if ($stmt && $stmt->execute()) {
|
||||
echo '- success' . PHP_EOL;
|
||||
} else {
|
||||
echo '! failed: ' . $mysqli->error . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user