This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
427 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace DkanTools\Command; | ||
|
||
use DkanTools\Util\Util; | ||
use DkanTools\Util\TestUserTrait; | ||
|
||
/** | ||
* This project's console commands configuration for Robo task runner. | ||
* | ||
* @see http://robo.li/ | ||
*/ | ||
class ProjectCommands extends \Robo\Tasks | ||
{ | ||
use TestUserTrait; | ||
|
||
/** | ||
* Run project cypress tests. | ||
*/ | ||
public function projectTestCypress(array $args) | ||
{ | ||
$this->apiUser(); | ||
$this->editorUser(); | ||
|
||
$result = $this->taskExec("npm link ../../../../usr/local/bin/node_modules/cypress") | ||
->dir("src/tests") | ||
->run(); | ||
if ($result->getExitCode() != 0) { | ||
$this->io()->error('Could not symlink package folder'); | ||
return $result; | ||
} | ||
|
||
$task = $this | ||
->taskExec('npm install --force') | ||
->dir("src/tests"); | ||
$result = $task->run(); | ||
if ($result->getExitCode() != 0) { | ||
$this->io()->error('Could not insall test dependencies.'); | ||
return $result; | ||
} | ||
$this->io()->success('Installation of test dependencies successful.'); | ||
|
||
$cypress = $this->taskExec('CYPRESS_baseUrl="http://$DKTL_PROXY_DOMAIN" npx cypress run') | ||
->dir("src/tests"); | ||
|
||
foreach ($args as $arg) { | ||
$cypress->arg($arg); | ||
} | ||
|
||
return $cypress->run(); | ||
} | ||
|
||
/** | ||
* Run Site PhpUnit Tests. Additional phpunit CLI options can be passed. | ||
* | ||
* @see https://phpunit.de/manual/6.5/en/textui.html#textui.clioptions | ||
* @param array $args Arguments to append to phpunit command. | ||
*/ | ||
public function projectTestPhpunit(array $args) | ||
{ | ||
$proj_dir = Util::getProjectDirectory(); | ||
$phpunit_executable = $this->getPhpUnitExecutable(); | ||
|
||
$phpunitExec = $this->taskExec($phpunit_executable) | ||
->option('testsuite', 'Custom Test Suite') | ||
->dir("{$proj_dir}/docroot/modules/custom"); | ||
|
||
foreach ($args as $arg) { | ||
$phpunitExec->arg($arg); | ||
} | ||
|
||
return $phpunitExec->run(); | ||
} | ||
|
||
private function getPhpUnitExecutable() | ||
{ | ||
$proj_dir = Util::getProjectDirectory(); | ||
|
||
$phpunit_executable = $phpunit_executable = "{$proj_dir}/vendor/bin/phpunit"; | ||
|
||
if (!file_exists($phpunit_executable)) { | ||
$this->taskExec("dktl installphpunit")->run(); | ||
$phpunit_executable = "phpunit"; | ||
} | ||
|
||
return $phpunit_executable; | ||
} | ||
|
||
private function inGitDetachedState($dkanDirPath) | ||
{ | ||
$output = []; | ||
exec("cd {$dkanDirPath} && git rev-parse --abbrev-ref HEAD", $output); | ||
return (isset($output[0]) && $output[0] == 'HEAD'); | ||
} | ||
} |
Oops, something went wrong.