Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 96: Check db schema #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 0 deletions bin/moodle-plugin-ci
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use MoodlePluginCI\Command\AddConfigCommand;
use MoodlePluginCI\Command\AddPluginCommand;
use MoodlePluginCI\Command\BehatCommand;
use MoodlePluginCI\Command\CheckDBSchemaCommand;
use MoodlePluginCI\Command\CodeCheckerCommand;
use MoodlePluginCI\Command\CodeFixerCommand;
use MoodlePluginCI\Command\CompletionCommand;
Expand Down Expand Up @@ -60,6 +61,7 @@ $application = new Application('Moodle Plugin CI', '@package_version@');
$application->add(new AddConfigCommand());
$application->add(new AddPluginCommand(ENV_FILE));
$application->add(new BehatCommand());
$application->add(new CheckDBSchemaCommand());
$application->add(new CodeCheckerCommand());
$application->add(new CodeFixerCommand());
$application->add(new CompletionCommand());
Expand Down
98 changes: 97 additions & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ title: Moodle Plugin CI Commands
* [`add-config`](#add-config)
* [`add-plugin`](#add-plugin)
* [`behat`](#behat)
* [`checkdbschema`](#checkdbschema)
* [`codechecker`](#codechecker)
* [`coveralls-upload`](#coveralls-upload)
* [`grunt`](#grunt)
Expand Down Expand Up @@ -382,6 +383,101 @@ Do not ask any interactive question
* Is multiple: no
* Default: `false`

`checkdbschema`
---------------

Run check_database_schema on the Moodle database

### Usage

* `checkdbschema [-m|--moodle MOODLE] [--] <plugin>`

Run check_database_schema on the Moodle database

### Arguments

#### `plugin`

Path to the plugin

* Is required: yes
* Is array: no
* Default: `NULL`

### Options

#### `--moodle|-m`

Path to Moodle

* Accept value: yes
* Is value required: yes
* Is multiple: no
* Default: `'.'`

#### `--help|-h`

Display this help message

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--quiet|-q`

Do not output any message

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--verbose|-v|-vv|-vvv`

Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--version|-V`

Display this application version

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--ansi`

Force ANSI output

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--no-ansi`

Disable ANSI output

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

#### `--no-interaction|-n`

Do not ask any interactive question

* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`

`codechecker`
-------------

Expand Down Expand Up @@ -1993,4 +2089,4 @@ Do not ask any interactive question
* Accept value: no
* Is value required: no
* Is multiple: no
* Default: `false`
* Default: `false`
52 changes: 52 additions & 0 deletions src/Command/CheckDBSchemaCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Moodle Plugin CI package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Copyright (c) 2018 Blackboard Inc. (http://www.blackboard.com)
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace MoodlePluginCI\Command;

use MoodlePluginCI\Process\MoodleProcess;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Check Database schema.
*/
class CheckDBSchemaCommand extends AbstractMoodleCommand
{
use ExecuteTrait;

protected function configure()
{
parent::configure();

$this->setName('checkdbschema')
->setDescription('Run check_database_schema on the Moodle database');
}

protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);
$this->initializeExecute($output, $this->getHelper('process'));
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->outputHeading($output, 'Checking Moodle Database Schema');
$process = new MoodleProcess('admin/cli/check_database_schema.php', $this->moodle->directory);
$code = 0;
$this->execute->passThroughProcess($process);
if (!$process->isSuccessful()) {
$code = 1;
}

return $code;
}
}