Skip to content
Merged
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
12 changes: 6 additions & 6 deletions inc/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace WPTS;

\define('WPTS_VERSION', '1.0.0');
const VERSION = '1.0.0';

\define('WPTS_CMD_INTRO', [
'<options=bold>Touchstone v' . \WPTS_VERSION,
const CMD_INTRO = [
'<options=bold>Touchstone v' . VERSION,
'',
]);
];

\define('WPTS_CMD_ICONS', [
const CMD_ICONS = [
'check' => '<fg=green>✓</>',
'cross' => '<fg=red>𐄂</>',
'loading' => '<fg=magenta>==></>',
]);
];
20 changes: 10 additions & 10 deletions src/Console/Commands/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(\WPTS_CMD_INTRO);
$output->writeln(\WPTS\CMD_INTRO);

$this->db_creds = [
'host' => $input->getOption('db-host') ?: '',
Expand Down Expand Up @@ -110,14 +110,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln([
'',
\WPTS_CMD_ICONS['check'] . " Setup complete",
\WPTS\CMD_ICONS['check'] . " Setup complete",
]);

return Command::SUCCESS;
} catch (\Throwable $e) {
$output->writeln([
'',
\WPTS_CMD_ICONS['cross'] . " {$e->getMessage()}",
\WPTS\CMD_ICONS['cross'] . " {$e->getMessage()}",
]);

return Command::FAILURE;
Expand Down Expand Up @@ -155,7 +155,7 @@ protected function validateDatabaseCredentials(): void
*/
protected function connectToHost(InputInterface $input, OutputInterface &$output): void
{
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Testing connection...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Testing connection...');

$db_string = "mysql:host={$this->db_creds['host']};charset=UTF8";

Expand Down Expand Up @@ -197,7 +197,7 @@ protected function createDatabase(InputInterface $input, OutputInterface &$outpu
return;
}

$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Creating database...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Creating database...');

try {
$this->db_connection->query("CREATE DATABASE IF NOT EXISTS {$this->db_creds['name']}");
Expand Down Expand Up @@ -233,7 +233,7 @@ protected function getLatestWordPressDownloadUrl()
protected function downloadWordPressFiles(InputInterface $input, OutputInterface &$output): void
{
//---- Download zip file
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Downloading WordPress files...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Downloading WordPress files...');

// Remove old files
try {
Expand All @@ -252,7 +252,7 @@ protected function downloadWordPressFiles(InputInterface $input, OutputInterface
\file_put_contents($this->tmp_dir . '/' . $this->wpZipFilename, $files_request->getBody()->getContents());

//---- Unzip files
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Installing WordPress files...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Installing WordPress files...');

if (!$this->filesystem->fileExists($this->wpZipFilename)) {
throw new \InvalidArgumentException('No WordPress files found.');
Expand Down Expand Up @@ -284,7 +284,7 @@ protected function downloadWordPressFiles(InputInterface $input, OutputInterface
protected function downloadWordPressTestFiles(InputInterface $input, OutputInterface &$output): void
{
//---- Download zip file
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Downloading WordPress test files...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Downloading WordPress test files...');

// Remove old files
try {
Expand All @@ -305,7 +305,7 @@ protected function downloadWordPressTestFiles(InputInterface $input, OutputInter
\file_put_contents($this->tmp_dir . '/' . $this->wpTestsZipFilename, $files_request->getBody()->getContents());

//---- Unzip files
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Installing WordPress test files...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Installing WordPress test files...');

if (!$this->filesystem->fileExists($this->wpTestsZipFilename)) {
throw new \InvalidArgumentException('No WordPress test files found.');
Expand Down Expand Up @@ -358,7 +358,7 @@ protected function downloadWordPressTestFiles(InputInterface $input, OutputInter
*/
protected function configureWordPressTestFiles(InputInterface $input, OutputInterface &$output): void
{
$output->writeln(\WPTS_CMD_ICONS['loading'] . ' Configuring WordPress test files...');
$output->writeln(\WPTS\CMD_ICONS['loading'] . ' Configuring WordPress test files...');

$transformer = new WPConfigTransformer(
$this->tmp_dir . '/' . $this->wpTestsDirectoryName . '/' . 'wp-tests-config.php'
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Commands/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(\WPTS_CMD_INTRO);
$output->writeln(\WPTS\CMD_INTRO);

if ($this->env == 'prod') {
$this->phpunitExecutablePath = __DIR__ . '/../../../../../../vendor/bin/phpunit';
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$output->writeln([
\WPTS_CMD_ICONS['loading'] . " Running {$input->getOption('type')} tests...",
\WPTS\CMD_ICONS['loading'] . " Running {$input->getOption('type')} tests...",
'',
]);

Expand All @@ -103,14 +103,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln([
'',
\WPTS_CMD_ICONS['check'] . " Tests run successfully",
\WPTS\CMD_ICONS['check'] . " Tests run successfully",
]);

return Command::SUCCESS;
} catch (\Throwable $e) {
$output->writeln([
'',
\WPTS_CMD_ICONS['cross'] . " {$e->getMessage()}",
\WPTS\CMD_ICONS['cross'] . " {$e->getMessage()}",
]);

return Command::FAILURE;
Expand Down