Skip to content
Merged

v2.0 #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Running the setup process downloads and installs both WordPress and the official

```shell
# Options
./vendor/bin/touchstone setup --db-host=[HOST] --db-socket=[SOCKET PATH] --db-name=[DATABASE NAME] --db-user=[DATABASE USERNAME] --db-pass=[DATABASE PASSWORD] --skip-db-creation=[TRUE/FALSE]
./vendor/bin/touchstone setup --db-host=[HOST] --db-socket=[SOCKET PATH] --db-name=[DATABASE NAME] --db-user=[DATABASE USERNAME] --db-pass=[DATABASE PASSWORD] skip-db-creation
```

#### Regular Connection
Expand Down
4 changes: 2 additions & 2 deletions inc/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace WPTS;

const NAME = 'Touchstone';
const VERSION = '1.2.0';
const NAME = 'Touchstone';
const VERSION = '2.0.0';

const CMD_INTRO = [
'<options=bold>' . NAME . ' v' . VERSION,
Expand Down
12 changes: 8 additions & 4 deletions src/Console/Commands/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function configure(): void
$this->addOption(
'skip-db-creation',
null,
InputOption::VALUE_OPTIONAL,
InputOption::VALUE_NEGATABLE,
"Skip creation of the database because it already exists?",
false
);
Expand Down Expand Up @@ -176,7 +176,7 @@ protected function connectToHost(InputInterface $input, OutputInterface &$output
$db_string .= "host={$this->db_creds['host']};";
}

if ($input->getOption('skip-db-creation')) {
if ($input->getOption('skip-db-creation') == true) {
$db_string .= "dbname={$this->db_creds['name']};";
}

Expand All @@ -194,8 +194,12 @@ protected function connectToHost(InputInterface $input, OutputInterface &$output
$this->db_connection = $db_connection;
} catch (\PDOException $e) {
switch ($e->getCode()) {
case '1045':
throw new \Exception("Couldn't connect to host. Is the username or password incorrect?");
case 1044:
case 1045:
throw new \Exception("Couldn't connect to database. Is the username or password incorrect?");
break;
case 1049:
throw new \Exception("Couldn't find the database \"{$this->db_creds['name']}\".");
break;
default:
throw new \Exception("Couldn't connect to host. Please check the details.");
Expand Down
13 changes: 2 additions & 11 deletions src/Consumer/ConsumerSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ class ConsumerSettings

public function __construct(string $root_path)
{
$file = $root_path . 'config.touchstone.php';

if (!\file_exists($file)) {
return;
}

$config = include $file;

if (!\is_array($config)) {
return;
}
$file = $root_path . 'config.touchstone.php';
$config = \file_exists($file) ? include $file : [];

$this->testsDir = $root_path . ($config['directories']['all'] ?? '');
$this->unitTestsDir = $root_path . ($config['directories']['unit'] ?? '');
Expand Down
30 changes: 16 additions & 14 deletions tests-consumer/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,27 @@
}

//---- Theme
$theme_dir = $settings->consumerSettings()->theme()->directoryPath();
$theme = $settings->consumerSettings()->theme();

if (is_dir($theme_dir)) {
$current_theme = $settings->consumerSettings()->theme()->directoryName();
$theme_root = dirname($theme_dir);
if ($theme) {
if (is_dir($theme->directoryPath())) {
$current_theme = $settings->consumerSettings()->theme()->directoryName();
$theme_root = dirname($theme->directoryPath());

add_filter('theme_root', function () use ($theme_root) {
return $theme_root;
});
add_filter('theme_root', function () use ($theme_root) {
return $theme_root;
});

register_theme_directory($theme_root);
register_theme_directory($theme_root);

add_filter('pre_option_template', function () use ($current_theme) {
return $current_theme;
});
add_filter('pre_option_template', function () use ($current_theme) {
return $current_theme;
});

add_filter('pre_option_stylesheet', function () use ($current_theme) {
return $current_theme;
});
add_filter('pre_option_stylesheet', function () use ($current_theme) {
return $current_theme;
});
}
}
});

Expand Down