Merge branch 'master' into dc/new-ui

This commit is contained in:
Dan Cryer 2014-12-03 13:05:10 +00:00
commit 1b1a90c1d7
16 changed files with 615 additions and 96 deletions

View file

@ -23,7 +23,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\DialogHelper;
use PHPCI\Service\UserService;
/**
* Install console command - Installs PHPCI.
* @author Dan Cryer <dan@block8.co.uk>
@ -32,10 +31,23 @@ use PHPCI\Service\UserService;
*/
class InstallCommand extends Command
{
protected $configFilePath;
protected function configure()
{
$defaultPath = PHPCI_DIR . 'PHPCI/config.yml';
$this
->setName('phpci:install')
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHPCI Installation URL')
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database hostname')
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name')
->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database username')
->addOption('db-pass', null, InputOption::VALUE_OPTIONAL, 'Database password')
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin username')
->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, 'Admin password')
->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, 'Admin e-mail')
->addOption('config-path', null, InputOption::VALUE_OPTIONAL, 'Config file path', $defaultPath)
->setDescription('Install PHPCI.');
}
@ -44,6 +56,8 @@ class InstallCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->configFilePath = $input->getOption('config-path');
$this->verifyNotInstalled($output);
$output->writeln('');
@ -58,60 +72,39 @@ class InstallCommand extends Command
$output->writeln('-------------------------------------');
$output->writeln('');
/**
* @var \Symfony\Component\Console\Helper\DialogHelper
*/
$dialog = $this->getHelperSet()->get('dialog');
// ----
// Get MySQL connection information and verify that it works:
// ----
$connectionVerified = false;
while (!$connectionVerified) {
$db = array();
$db['servers']['read'] = $dialog->ask($output, 'Please enter your MySQL host [localhost]: ', 'localhost');
$db['servers']['write'] = $db['servers']['read'];
$db['name'] = $dialog->ask($output, 'Please enter your database name [phpci]: ', 'phpci');
$db['username'] = $dialog->ask($output, 'Please enter your database username [phpci]: ', 'phpci');
$db['password'] = $dialog->askHiddenResponse($output, 'Please enter your database password: ');
$db = $this->getDatabaseInformation($input, $output);
$connectionVerified = $this->verifyDatabaseDetails($db, $output);
}
$output->writeln('');
$conf = array();
$conf['b8']['database'] = $db;
// ----
// Get basic installation details (URL, etc)
// ----
$conf = array();
$conf['b8']['database'] = $db;
$conf['phpci']['url'] = $dialog->askAndValidate(
$output,
'Your PHPCI URL ("http://phpci.local" for example): ',
function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_URL)) {
throw new Exception('Must be a valid URL');
}
return rtrim($answer, '/');
},
false
);
$conf['phpci'] = $this->getPhpciConfigInformation($input, $output);
$this->writeConfigFile($conf);
$this->setupDatabase($output);
$this->createAdminUser($output, $dialog);
$admin = $this->getAdminInforamtion($input, $output);
$this->createAdminUser($admin, $output);
}
/**
* Check PHP version, required modules and for disabled functions.
*
* @param OutputInterface $output
* @throws \Exception
*/
protected function checkRequirements(OutputInterface $output)
{
$output->write('Checking requirements...');
@ -160,6 +153,127 @@ class InstallCommand extends Command
$output->writeln('');
}
/**
* Load information for admin user form CLI options or ask info to user.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return array
*/
protected function getAdminInforamtion(InputInterface $input, OutputInterface $output)
{
$admin = array();
/**
* @var \Symfony\Component\Console\Helper\DialogHelper
*/
$dialog = $this->getHelperSet()->get('dialog');
// Function to validate mail address.
$mailValidator =function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
throw new Exception('Must be a valid email address.');
}
return $answer;
};
if ($adminEmail = $input->getOption('admin-mail')) {
$adminEmail = $mailValidator($adminEmail);
} else {
$adminEmail = $dialog->askAndValidate($output, 'Your email address: ', $mailValidator, false);
}
if (!$adminName = $input->getOption('admin-name')) {
$adminName = $dialog->ask($output, 'Enter your name: ');
}
if (!$adminPass = $input->getOption('admin-pass')) {
$adminPass = $dialog->askHiddenResponse($output, 'Enter your desired admin password: ');
}
$admin['mail'] = $adminEmail;
$admin['name'] = $adminName;
$admin['pass'] = $adminPass;
return $admin;
}
/**
* Load configuration for PHPCI form CLI options or ask info to user.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return array
*/
protected function getPhpciConfigInformation(InputInterface $input, OutputInterface $output)
{
$phpci = array();
/**
* @var \Symfony\Component\Console\Helper\DialogHelper
*/
$dialog = $this->getHelperSet()->get('dialog');
// FUnction do validate URL.
$urlValidator = function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_URL)) {
throw new Exception('Must be a valid URL');
}
return rtrim($answer, '/');
};
if ($url = $input->getOption('url')) {
$url = $urlValidator($url);
} else {
$url = $dialog->askAndValidate($output, 'Your PHPCI URL ("http://phpci.local" for example): ', $urlValidator, false);
}
$phpci['url'] = $url;
return $phpci;
}
/**
* Load configuration for DB form CLI options or ask info to user.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return array
*/
protected function getDatabaseInformation(InputInterface $input, OutputInterface $output)
{
$db = array();
/**
* @var \Symfony\Component\Console\Helper\DialogHelper
*/
$dialog = $this->getHelperSet()->get('dialog');
if (!$dbHost = $input->getOption('db-host')) {
$dbHost = $dialog->ask($output, 'Please enter your MySQL host [localhost]: ', 'localhost');
}
if (!$dbName = $input->getOption('db-name')) {
$dbName = $dialog->ask($output, 'Please enter your database name [phpci]: ', 'phpci');
}
if (!$dbUser = $input->getOption('db-user')) {
$dbUser = $dialog->ask($output, 'Please enter your database username [phpci]: ', 'phpci');
}
if (!$dbPass = $input->getOption('db-pass')) {
$dbPass = $dialog->askHiddenResponse($output, 'Please enter your database password: ');
}
$db['servers']['read'] = $dbHost;
$db['servers']['write'] = $dbHost;
$db['name'] = $dbName;
$db['username'] = $dbUser;
$db['password'] = $dbPass;
return $db;
}
/**
* Try and connect to MySQL using the details provided.
* @param array $db
@ -198,9 +312,9 @@ class InstallCommand extends Command
protected function writeConfigFile(array $config)
{
$dumper = new \Symfony\Component\Yaml\Dumper();
$yaml = $dumper->dump($config, 2);
$yaml = $dumper->dump($config, 4);
file_put_contents(PHPCI_DIR . 'PHPCI/config.yml', $yaml);
file_put_contents($this->configFilePath, $yaml);
}
protected function setupDatabase(OutputInterface $output)
@ -213,34 +327,19 @@ class InstallCommand extends Command
}
/**
* Create admin user using information loaded before.
*
* @param array $admin
* @param OutputInterface $output
* @param DialogHelper $dialog
*/
protected function createAdminUser(OutputInterface $output, DialogHelper $dialog)
protected function createAdminUser($admin, $output)
{
// Try to create a user account:
$adminEmail = $dialog->askAndValidate(
$output,
'Your email address: ',
function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
throw new Exception('Must be a valid email address.');
}
return $answer;
},
false
);
$adminPass = $dialog->askHiddenResponse($output, 'Enter your desired admin password: ');
$adminName = $dialog->ask($output, 'Enter your name: ');
try {
$this->reloadConfig();
$userStore = Factory::getStore('User');
$userService = new UserService($userStore);
$userService->createUser($adminName, $adminEmail, $adminPass, 1);
$userService->createUser($admin['name'], $admin['mail'], $admin['pass'], 1);
$output->writeln('<info>User account created!</info>');
} catch (\Exception $ex) {
@ -252,11 +351,10 @@ class InstallCommand extends Command
protected function reloadConfig()
{
$configFile = PHPCI_DIR . 'PHPCI/config.yml';
$config = Config::getInstance();
$config = Config::getInstance();
if (file_exists($configFile)) {
$config->loadYaml($configFile);
if (file_exists($this->configFilePath)) {
$config->loadYaml($this->configFilePath);
}
}
@ -265,11 +363,11 @@ class InstallCommand extends Command
*/
protected function verifyNotInstalled(OutputInterface $output)
{
if (file_exists(PHPCI_DIR . 'PHPCI/config.yml')) {
$content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml');
if (file_exists($this->configFilePath)) {
$content = file_get_contents($this->configFilePath);
if (!empty($content)) {
$output->writeln('<error>PHPCI/config.yml exists and is not empty.</error>');
$output->writeln('<error>The PHPCI config file exists and is not empty.</error>');
$output->writeln('<error>If you were trying to update PHPCI, please use phpci:update instead.</error>');
die;
}

View file

@ -68,23 +68,15 @@ class BuildStatusController extends \PHPCI\Controller
}
/**
* Returns the appropriate build status image for a given project.
* Returns the appropriate build status image in SVG format for a given project.
*/
public function image($projectId)
{
$status = $this->getStatus($projectId);
header('Content-Type: image/png');
die(file_get_contents(APPLICATION_PATH . 'public/assets/img/build-' . $status . '.png'));
}
/**
* Returns the appropriate build status image in SVG format for a given project.
*/
public function svg($projectId)
{
$status = $this->getStatus($projectId);
$color = ($status == 'passing') ? 'green' : 'red';
header('Content-Type: image/svg+xml');
die(file_get_contents(APPLICATION_PATH . 'public/assets/img/build-' . $status . '.svg'));
die(file_get_contents('http://img.shields.io/badge/build-' . $status . '-' . $color . '.svg'));
}
public function view($projectId)

View file

@ -108,9 +108,19 @@ class PluginController extends \PHPCI\Controller
return json_decode($json, true);
}
/**
* Convert array to json and save composer.json
*
* @param $array
*/
protected function setComposerJson($array)
{
$json = json_encode($array);
if (defined('JSON_PRETTY_PRINT')) {
$json = json_encode($array, JSON_PRETTY_PRINT);
} else {
$json = json_encode($array);
}
file_put_contents(APPLICATION_PATH . 'composer.json', $json);
}

View file

@ -147,11 +147,16 @@ class SettingsController extends Controller
die;
}
/**
* Convert config to yaml and store to file.
* @return mixed
*/
protected function storeSettings()
{
$dumper = new Dumper();
$yaml = $dumper->dump($this->settings);
$yaml = $dumper->dump($this->settings, 4);
file_put_contents(APPLICATION_PATH . 'PHPCI/config.yml', $yaml);
if (error_get_last()) {
$error_get_last = error_get_last();
return $error_get_last['message'];

View file

@ -58,10 +58,91 @@ class PhpSpec implements PHPCI\Plugin
return false;
}
$success = $this->phpci->executeCommand($phpspec . ' --format=pretty --no-code-generation run');
$success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run');
$output = $this->phpci->getLastOutput();
chdir($curdir);
/*
* process xml output
*
* <testsuites time=FLOAT tests=INT failures=INT errors=INT>
* <testsuite name=STRING time=FLOAT tests=INT failures=INT errors=INT skipped=INT>
* <testcase name=STRING time=FLOAT classname=STRING status=STRING/>
* </testsuite>
* </testsuites
*/
$xml = new \SimpleXMLElement($output);
$attr = $xml->attributes();
$data = array(
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
// now all the tests
'suites' => array()
);
/**
* @var \SimpleXMLElement $group
*/
foreach ($xml->xpath('testsuite') as $group) {
$attr = $group->attributes();
$suite = array(
'name' => (String)$attr['name'],
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
'skipped' => (int)$attr['skipped'],
// now the cases
'cases' => array()
);
/**
* @var \SimpleXMLElement $child
*/
foreach ($group->xpath('testcase') as $child) {
$attr = $child->attributes();
$case = array(
'name' => (String)$attr['name'],
'classname' => (String)$attr['classname'],
'time' => (float)$attr['time'],
'status' => (String)$attr['status'],
);
if ($case['status']=='failed') {
$error = array();
/*
* ok, sad, we had an error
*
* there should be one - foreach makes this easier
*/
foreach ($child->xpath('failure') as $failure) {
$attr = $failure->attributes();
$error['type'] = (String)$attr['type'];
$error['message'] = (String)$attr['message'];
}
foreach ($child->xpath('system-err') as $system_err) {
$error['raw'] = (String)$system_err;
}
$case['error'] = $error;
}
$suite['cases'][] = $case;
}
$data['suites'][] = $suite;
}
$this->build->storeMeta('phpspec', $data);
return $success;
}
}

View file

@ -67,7 +67,7 @@ class FilesPluginInformation implements InstalledPluginInformation
$this->pluginInfo = array();
foreach ($this->files as $fileInfo) {
if ($fileInfo instanceof \SplFileInfo) {
if ($fileInfo->isFile()) {
if ($fileInfo->isFile() && $fileInfo->getExtension()=='php') {
$this->addPluginFromFile($fileInfo);
}
}
@ -76,13 +76,17 @@ class FilesPluginInformation implements InstalledPluginInformation
protected function addPluginFromFile(\SplFileInfo $fileInfo)
{
$newPlugin = new \stdClass();
$newPlugin->class = $this->getFullClassFromFile($fileInfo);
$newPlugin->source = "core";
$parts = explode('\\', $newPlugin->class);
$newPlugin->name = end($parts);
$class = $this->getFullClassFromFile($fileInfo);
$this->pluginInfo[] = $newPlugin;
if (!is_null($class)) {
$newPlugin = new \stdClass();
$newPlugin->class = $class;
$newPlugin->source = "core";
$parts = explode('\\', $newPlugin->class);
$newPlugin->name = end($parts);
$this->pluginInfo[] = $newPlugin;
}
}
protected function getFullClassFromFile(\SplFileInfo $fileInfo)
@ -90,15 +94,20 @@ class FilesPluginInformation implements InstalledPluginInformation
//TODO: Something less horrible than a regular expression
// on the contents of a file
$contents = file_get_contents($fileInfo->getRealPath());
$matches = array();
preg_match('#class +([A-Za-z]+) +implements#i', $contents, $matches);
$className = $matches[1];
$matches = array();
preg_match('#namespace +([A-Za-z\\\\]+);#i', $contents, $matches);
$namespace = $matches[1];
return $namespace . '\\' . $className;
if (isset($matches[1])) {
$className = $matches[1];
$matches = array();
preg_match('#namespace +([A-Za-z\\\\]+);#i', $contents, $matches);
$namespace = $matches[1];
return $namespace . '\\' . $className;
} else {
return null;
}
}
}

View file

@ -44,7 +44,7 @@ class TapParser
throw new \Exception('TapParser only supports TAP version 13');
}
if (preg_match(self::TEST_COVERAGE_PATTERN, $lines[count($lines) - 1])) {
if (isset($lines[count($lines) - 1]) && preg_match(self::TEST_COVERAGE_PATTERN, $lines[count($lines) - 1])) {
array_pop($lines);
if ($lines[count($lines) - 1] == "") {
array_pop($lines);
@ -58,7 +58,8 @@ class TapParser
$totalTests = (int) $matches[2];
}
if (preg_match(self::TEST_COUNTS_PATTERN, $lines[count($lines) - 1], $matches)) {
if (isset($lines[count($lines) - 1]) &&
preg_match(self::TEST_COUNTS_PATTERN, $lines[count($lines) - 1], $matches)) {
array_pop($lines);
$totalTests = (int) $matches[2];
}

View file

@ -0,0 +1,237 @@
<?php
namespace PHPCI\Plugin\Tests\Command;
use Symfony\Component\Console\Application;
use PHPCI\Command\InstallCommand;
use Prophecy\PhpUnit\ProphecyTestCase;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Helper\HelperSet;
class InstallCommandTest extends ProphecyTestCase
{
protected $config;
protected $admin;
protected $command;
protected $dialog;
protected $application;
public function setup()
{
parent::setup();
// Current command, we need to mock all method that interact with
// Database & File system.
$this->command = $this->getMockBuilder('PHPCI\\Command\\InstallCommand')
->setMethods(array(
'reloadConfig',
'verifyNotInstalled',
'verifyDatabaseDetails',
'setupDatabase',
'createAdminUser',
'writeConfigFile',
))
->getMock();
$this->command->expects($this->once())->method('verifyDatabaseDetails')->willReturn(true);
$this->command->expects($this->once())->method('setupDatabase')->willReturn(true);
$this->command->expects($this->once())->method('createAdminUser')->will(
$this->returnCallback(function ($adm) {// use (&$admin) {
$this->admin = $adm;
})
);
$this->command->expects($this->once())->method('writeConfigFile')->will(
$this->returnCallback(function ($cfg) { //use (&$config) {
$this->config = $cfg;
})
);
// We check that there's no interaction with user.
$this->dialog = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\DialogHelper')
->setMethods(array(
'ask',
'askConfirmation',
'askAndValidate',
'askHiddenResponse',
'askHiddenResponseAndValidate',
))
->getMock();
$this->application = new Application();
$this->application->setHelperSet(new HelperSet());
}
protected function getCommandTester()
{
$this->application->getHelperSet()->set($this->dialog, 'dialog');
$this->application->add($this->command);
$command = $this->application->find('phpci:install');
$commandTester = new CommandTester($command);
return $commandTester;
}
protected function getConfig($exclude = null)
{
$config = array(
'--db-host' => 'localhost',
'--db-name' => 'phpci1',
'--db-user' => 'phpci2',
'--db-pass' => 'phpci3',
'--admin-mail' => 'phpci@phpci.test',
'--admin-name' => 'phpci4',
'--admin-pass' => 'phpci5',
'--url' => 'http://test.phpci.org',
);
if (!is_null($exclude)) {
unset($config[$exclude]);
}
return $config;
}
protected function executeWithoutParam($param = null)
{
// Clean result variables.
$this->admin = array();
$this->config = array();
// Get tester and execute with extracted parameters.
$commandTester = $this->getCommandTester();
$parameters = $this->getConfig($param);
$commandTester->execute($parameters);
}
public function testAutomticInstallation()
{
$this->dialog->expects($this->never())->method('ask');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam();
}
public function testDatabaseHostnameConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->once())->method('ask')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--db-host');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['read']);
$this->assertEquals('testedvalue', $this->config['b8']['database']['servers']['write']);
}
public function testDatabaseNameConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->once())->method('ask')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--db-name');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['name']);
}
public function testDatabaseUserameConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->once())->method('ask')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--db-user');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['username']);
}
public function testDatabasePasswordConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->never())->method('ask');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->once())->method('askHiddenResponse')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--db-pass');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->config['b8']['database']['password']);
}
public function testPhpciUrlConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->never())->method('ask');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->once())->method('askAndValidate')->willReturn('http://testedvalue.com');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--url');
// Check that specified arguments are correctly loaded.
$this->assertEquals('http://testedvalue.com', $this->config['phpci']['url']);
}
public function testAdminEmailConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->never())->method('ask');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->once())->method('askAndValidate')->willReturn('test@phpci.com');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--admin-mail');
// Check that specified arguments are correctly loaded.
$this->assertEquals('test@phpci.com', $this->admin['mail']);
}
public function testAdminUserameConfig()
{
// Define expectation for dialog.
$this->dialog->expects($this->once())->method('ask')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->never())->method('askHiddenResponse');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--admin-name');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->admin['name']);
}
public function testAdminPasswordConfig()
{
// We specified an input value for hostname.
$this->dialog->expects($this->never())->method('ask');
$this->dialog->expects($this->never())->method('askConfirmation');
$this->dialog->expects($this->never())->method('askAndValidate');
$this->dialog->expects($this->once())->method('askHiddenResponse')->willReturn('testedvalue');
$this->dialog->expects($this->never())->method('askHiddenResponseAndValidate');
$this->executeWithoutParam('--admin-pass');
// Check that specified arguments are correctly loaded.
$this->assertEquals('testedvalue', $this->admin['pass']);
}
}

View file

@ -30,12 +30,18 @@ if (!file_exists($configFile)) {
// If we don't have a config file at all, fail at this point and tell the user to install:
if (!file_exists($configFile) && (!defined('PHPCI_IS_CONSOLE') || !PHPCI_IS_CONSOLE)) {
die('PHPCI has not yet been installed - Please use the command ./console phpci:install to install it.');
$message = 'PHPCI has not yet been installed - Please use the command "./console phpci:install" ';
$message .= '(or "php ./console phpci:install" for Windows) to install it.';
die($message);
}
// If composer has not been run, fail at this point and tell the user to install:
if (!file_exists(dirname(__FILE__) . '/vendor/autoload.php') && defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
file_put_contents('php://stderr', 'Please install PHPCI with "composer install" before using console');
$message = 'Please install PHPCI with "composer install" (or "php composer.phar install"';
$message .= ' for Windows) before using console';
file_put_contents('php://stderr', $message);
exit(1);
}

View file

@ -11,6 +11,9 @@
bootstrap="./Tests/bootstrap.php"
>
<testsuites>
<testsuite name="PHPCI Command Test Suite">
<directory suffix="Test.php">./Tests/PHPCI/Command</directory>
</testsuite>
<testsuite name="PHPCI Helper Test Suite">
<directory suffix="Test.php">./Tests/PHPCI/Helper</directory>
</testsuite>

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="76" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="76" height="18" fill="#555"/><rect rx="4" x="37" width="39" height="18" fill="#fe7d37"/><path fill="#fe7d37" d="M37 0h4v18h-4z"/><rect rx="4" width="76" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="55.5" y="13" fill="#010101" fill-opacity=".3">error</text><text x="55.5" y="12">error</text></g></svg>

Before

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="78" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="78" height="18" fill="#555"/><rect rx="4" x="37" width="41" height="18" fill="#e05d44"/><path fill="#e05d44" d="M37 0h4v18h-4z"/><rect rx="4" width="78" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="56.5" y="13" fill="#010101" fill-opacity=".3">failed</text><text x="56.5" y="12">failed</text></g></svg>

Before

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="90" height="18" fill="#555"/><rect rx="4" x="37" width="53" height="18" fill="#97CA00"/><path fill="#97CA00" d="M37 0h4v18h-4z"/><rect rx="4" width="90" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="13" fill="#010101" fill-opacity=".3">build</text><text x="19.5" y="12">build</text><text x="62.5" y="13" fill="#010101" fill-opacity=".3">passing</text><text x="62.5" y="12">passing</text></g></svg>

Before

Width:  |  Height:  |  Size: 822 B

View file

@ -0,0 +1,80 @@
var phpspecPlugin = PHPCI.UiPlugin.extend({
id: 'build-phpspec-errors',
css: 'col-lg-12 col-md-12 col-sm-12 col-xs-12',
title: 'PHPSpec',
lastData: null,
displayOnUpdate: false,
box: true,
rendered: false,
register: function() {
var self = this;
var query = PHPCI.registerQuery('phpspec', -1, {key: 'phpspec'})
$(window).on('phpspec', function(data) {
self.onUpdate(data);
});
$(window).on('build-updated', function() {
if (!self.rendered) {
self.displayOnUpdate = true;
query();
}
});
},
render: function() {
return $('<table class="table table-striped" id="phpspec-data">' +
'<thead>' +
'<tr>' +
' <th>Suite</th>' +
' <th>Test</th>' +
' <th>Result</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},
onUpdate: function(e) {
if (!e.queryData) {
$('#build-phpspec-errors').hide();
return;
}
this.rendered = true;
this.lastData = e.queryData;
var tests = this.lastData[0].meta_value;
var tbody = $('#phpspec-data tbody');
tbody.empty();
for (var i in tests.suites) {
var test_suite = tests.suites[i];
for(var k in test_suite.cases){
var test_case = test_suite.cases[k];
var row = $(
'<tr>'+
'<td>'+test_suite.name+'</td>'+
'<td title="Took '+test_case['time']+'Seconds">'+test_case.name+'</td>'+
'<td>'+(test_case.message?test_case.message:'OK')+'</td>'+
'</tr>'
);
if (test_case.status!='passed') {
row.addClass('danger');
} else {
row.addClass('success');
}
tbody.append(row);
}
}
// show plugin once preparation of grid is done
$('#build-phpspec-errors').show();
}
});
PHPCI.registerPlugin(new phpspecPlugin());