Skip to content

Commit

Permalink
Merge branch 'release/0.21.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
garex committed Jul 11, 2018
2 parents 57397fd + dc34ebf commit 89a188b
Show file tree
Hide file tree
Showing 29 changed files with 382 additions and 137 deletions.
48 changes: 34 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: php

php:
- 5.6
- 5.2

env:
global:
Expand All @@ -29,29 +28,44 @@ env:

matrix:
include:
- php: 7.0
env: WP_VERSION= DB_CHARSET=utf8mb4
- php: 5.2
dist: precise
env: WP_VERSION=
- php: 5.2
dist: precise
env: WP_VERSION=4.8.4
- php: 5.2
dist: precise
env: WP_VERSION=4.0.1
- php: 5.2
dist: precise
env: WP_VERSION=3.9
- php: 5.2
dist: precise
env: WP_VERSION=3.5
- php: 5.2
dist: precise
env: WP_VERSION=3.3
- php: 5.2
dist: precise
env: WP_VERSION=3.2
- php: 5.3
dist: precise
env: WP_VERSION=
- php: 5.4
env: WP_VERSION=
- php: 5.5
env: WP_VERSION=
- php: 5.3
env: DB_ENGINE=MyISAM DB_CHARSET=latin1 WP_UPGRADE=1
- php: 5.4
env: DB_ENGINE=MyISAM DB_CHARSET=latin1 WP_UPGRADE=1
- php: 7.0
env: WP_VERSION= DB_CHARSET=utf8mb4
- php: 7.0
env: PLUGINS=akismet.3.1.11:jetpack.4.2.2:wordpress-seo.3.3.4:wordfence.6.1.14:contact-form-7.4.5:google-sitemap-generator.4.0.8
allow_failures:
- php: 5.2
env: WP_VERSION=3.5
- php: 5.2
env: WP_VERSION=3.6
- php: 5.2
env: WP_VERSION=3.7

sudo: false

dist: precise
dist: trusty

addons:
hosts:
Expand All @@ -68,13 +82,19 @@ before_script:
- cd $TRAVIS_BUILD_DIR
- tests/integration-environment/create.sh
- cd $TRAVIS_BUILD_DIR/tests/mocha
- nvm install 0.10.36
- nvm use 0.10.36
- npm install
- cd $TRAVIS_BUILD_DIR
- export PATH=$PATH:$TRAVIS_BUILD_DIR/tests/mocha/node_modules/.bin/:$TRAVIS_BUILD_DIR/tests/integration-environment/
- if [ $(cat /proc/sys/net/ipv6/conf/all/disable_ipv6) -eq 1 ]; then
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
fi
- test $(cat /proc/sys/net/ipv6/conf/all/disable_ipv6) -eq 0

script:
- vendor/bin/phpunit-php52
- cd $TRAVIS_BUILD_DIR/tests/mocha && mocha-casperjs --timeout=360000
- cd $TRAVIS_BUILD_DIR/tests/mocha && PHANTOMJS_EXECUTABLE=node_modules/.bin/phantomjs mocha-casperjs --timeout=360000

after_script:
- cd $TRAVIS_BUILD_DIR
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
## Changelog ##


### 0.21.11 ###

Allow to use socket and IPv6 in database connection

Make DB-connection compatible with wordpress: allow to use sockets and IPv6.
It's mostly for new users, who uses non-standard database connection settings.
If you are existing user, you dont' need this update.

* Improve database-related testing aspects
* Stabilize auto-tests
* Upgrade testing environment
* Parse wordpress's DB_HOST constant in same way as it was introduced in WP 4.9
with respect to socket and IPv6.


### 0.21.10 ###

Improve database charset operations
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

**Tested up to:** 4.9

**Stable tag:** 0.21.10
**Stable tag:** 0.21.11

**License:** GPLv3

Expand Down
2 changes: 2 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ machine:

hosts:
wpti.dev: 127.0.0.1
before.wpti.dev: 127.0.0.1
after.wpti.dev: 127.0.0.1

environment:
WP_T_MULTI_SERVER: http://wpti.dev
Expand Down
2 changes: 1 addition & 1 deletion db/ruckusing.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
$local = dirname(__FILE__) . '/ruckusing.conf.local.php';
if (file_exists($local)) {
return require_once $local;
return require $local;
}
$wp0Prefix = 'wp_';
$wpPrefix = 'wp_';
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
backupStaticAttributes="false"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
20 changes: 20 additions & 0 deletions src/Component/Database/FlourishDatabase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class WpTesting_Component_Database_FlourishDatabase extends fDatabase
{
public function __construct(WpTesting_WordPressFacade $wp)
{
$host = new WpTesting_WordPress_Value_DbHost($wp->getDbHost());

parent::__construct(
'mysql',
$wp->getDbName(),
$wp->getDbUser(),
$wp->getDbPassword(),
$host->socket() ? 'sock:' . $host->socket() : $host->host(),
$host->port(),
null,
$wp->getDbCharset()
);
}
}
55 changes: 55 additions & 0 deletions src/Component/Database/RuckusingRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* @method Ruckusing_Adapter_MySQL_Base get_adapter
*/
class WpTesting_Component_Database_RuckusingRunner extends Ruckusing_FrameworkRunner
{
public function __construct(WpTesting_WordPressFacade $wp, WpTesting_Facade_IORM $ormAware, array $argv)
{
$wp0Prefix = $wp->getGlobalTablePrefix();
$wpPrefix = $wp->getTablePrefix();
$wptPrefix = $ormAware->getTablePrefix();

$runnerReflection = new ReflectionClass('Ruckusing_FrameworkRunner');
defined('RUCKUSING_WORKING_BASE') || define('RUCKUSING_WORKING_BASE', dirname(dirname(dirname(dirname(__FILE__)))));
defined('RUCKUSING_BASE') || define('RUCKUSING_BASE', dirname(dirname(dirname($runnerReflection->getFileName()))));

$databaseDirectory = RUCKUSING_WORKING_BASE . '/db';
$host = new WpTesting_WordPress_Value_DbHost($wp->getDbHost());
$config = array(
'db' => array(
'development' => array(
'type' => 'mysql',
'host' => $host->socket() ? null : $host->host(),
'port' => $host->socket() ? null : $host->port(),
'socket' => $host->socket() ? $host->socket() : null,
'database' => $wp->getDbName(),
'directory'=> 'wp_testing',
'user' => $wp->getDbUser(),
'password' => $wp->getDbPassword(),
'charset' => $wp->getDbCharset(),
'globalPrefix' => $wp0Prefix,
'blogPrefix' => $wpPrefix,
'pluginPrefix' => $wptPrefix,
'schema_version_table_name' => $wptPrefix . 'schema_migrations',
),
'fixed-charset' => array(
'charset' => 'utf8',
),
),
'db_dir' => $databaseDirectory,
'migrations_dir' => array('default' => $databaseDirectory . '/migrations'),
'log_dir' => $wp->getTempDir() . 'wp_testing_' . md5(__FILE__),
);
$config['db']['fixed-charset'] = array_merge($config['db']['development'], $config['db']['fixed-charset']);

parent::__construct($config, $argv);

restore_error_handler();
restore_exception_handler();

// Unset logger to avoid closing it in execute and to not create outside as it was before
unset($this->logger);
}
}
51 changes: 3 additions & 48 deletions src/Doer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ private function uninstallOnBlog($isDropTables = true)
if ($isDropTables) {
$adapter = $this->migrateDatabase(array(__FILE__,'db:migrate','VERSION=0'));
$adapter->drop_table($adapter->get_schema_version_table_name());
if ($adapter instanceof Ruckusing_Adapter_Base) {
$adapter->logger->close();
}
$adapter->logger->close();
}
$this->flushRewrite();
}
Expand Down Expand Up @@ -158,53 +156,10 @@ private function runOnBlogs($method)
*/
private function migrateDatabase($argv)
{
$wp0Prefix = $this->wp->getGlobalTablePrefix();
$wpPrefix = $this->wp->getTablePrefix();
$wptPrefix = $this->ormAware->getTablePrefix();

$runnerReflection = new ReflectionClass('Ruckusing_FrameworkRunner');
defined('RUCKUSING_WORKING_BASE') || define('RUCKUSING_WORKING_BASE', dirname(dirname(dirname(__FILE__))));
defined('RUCKUSING_BASE') || define('RUCKUSING_BASE', dirname(dirname(dirname($runnerReflection->getFileName()))));

$databaseDirectory = RUCKUSING_WORKING_BASE . '/db';
$dbHostWithPort = explode(':', $this->wp->getDbHost() . ':3306');
$config = array(
'db' => array(
'development' => array(
'type' => 'mysql',
'host' => reset($dbHostWithPort),
'port' => next($dbHostWithPort),
'database' => $this->wp->getDbName(),
'directory'=> 'wp_testing',
'user' => $this->wp->getDbUser(),
'password' => $this->wp->getDbPassword(),
'charset' => $this->wp->getDbCharset(),
'globalPrefix' => $wp0Prefix,
'blogPrefix' => $wpPrefix,
'pluginPrefix' => $wptPrefix,
'schema_version_table_name' => $wptPrefix . 'schema_migrations',
),
'fixed-charset' => array(
'charset' => 'utf8',
),
),
'db_dir' => $databaseDirectory,
'migrations_dir' => array('default' => $databaseDirectory . '/migrations'),
'log_dir' => $this->wp->getTempDir() . 'wp_testing_' . md5(__FILE__),
);
$config['db']['fixed-charset'] = array_merge($config['db']['development'], $config['db']['fixed-charset']);

$runner = new Ruckusing_FrameworkRunner($config, $argv);
restore_error_handler();
restore_exception_handler();
$runner = new WpTesting_Component_Database_RuckusingRunner($this->wp, $this->ormAware, $argv);
$runner->execute();

/* @var $adapter Ruckusing_Adapter_Base */
$adapter = $runner->get_adapter();
if ($adapter instanceof Ruckusing_Adapter_Base) {
$adapter->logger = new Ruckusing_Util_Logger($config['log_dir'] . '/development.log');
}
return $adapter;
return $runner->get_adapter();
}

/**
Expand Down
25 changes: 4 additions & 21 deletions src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,8 @@ public function setupORM()
$wpPrefix = $this->wp->getTablePrefix();
$wptPrefix = $this->getTablePrefix();

// Extract port from host. See wpdb::db_connect
$port = null;
$host = $this->wp->getDbHost();
$m = array();
if (preg_match('/^(.+):(\d+)$/', trim($host), $m)) {
$host = $m[1];
$port = $m[2];
}
$database = new fDatabase(
'mysql',
$this->wp->getDbName(),
$this->wp->getDbUser(),
$this->wp->getDbPassword(),
$host,
$port,
null,
$this->wp->getDbCharset()
);
fORMDatabase::attach($database);
$this->database = new WpTesting_Component_Database_FlourishDatabase($this->wp);
fORMDatabase::attach($this->database);

fORM::mapClassToTable('WpTesting_Model_Test', $wpPrefix . 'posts');
fORM::mapClassToTable('WpTesting_Model_Question', $wptPrefix . 'questions');
Expand Down Expand Up @@ -363,9 +346,9 @@ public function setupORM()
$schema->setKeysOverride(array(), $wptPrefix . 'fields', 'foreign');
$schema->setKeysOverride(array(), $wptPrefix . 'field_values', 'foreign');

$this->wp->doAction('wp_testing_orm_setup', $schema, $database, $this);
$this->wp->doAction('wp_testing_orm_setup', $schema, $this->database, $this);

return $database;
return $this->database;
}

public function getTablePrefix()
Expand Down
19 changes: 19 additions & 0 deletions src/WordPress/Value/Base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* Value object.
*/
abstract class WpTesting_WordPress_Value_Base
{
private $value;

public function __construct($value)
{
$this->value = $value;
}

public function __toString()
{
return $this->value;
}
}
Loading

0 comments on commit 89a188b

Please sign in to comment.