Skip to content

Commit

Permalink
Add test + fix loadin ConfigurationHelper using service
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 16, 2019
1 parent 919abd3 commit a7c4528
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions chash.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Command-line tool to do things more swiftly in Chamilo.
* To add support for a new command see the Console Component read:.
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Common/CommonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public function setMigrationConfigurationFile($file)
*/
public function getConfigurationHelper()
{
return $this->getHelper('configuration');
return $this->configurationHelper;
}

/**
Expand Down
13 changes: 12 additions & 1 deletion src/Command/Common/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Chash\Command\Common;

use Chash\Helpers\ConfigurationHelper;
use Exception;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -14,10 +15,20 @@
*/
class DatabaseCommand extends CommonCommand
{
public $configurationHelper;

public function __construct(ConfigurationHelper $configurationHelper)
{
$this->configurationHelper = $configurationHelper;

// you *must* call the parent constructor
parent::__construct();
}

/**
* {@inheritdoc}
*/
public function getConnection(InputInterface $input)
public function getConnection()
{
try {
return $this->getHelper('db')->getConnection();
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Command/Database/StatusCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function testExecute()

// the output of the command in the console
$output = $commandTester->getDisplay();
//$this->assertContains('Username: Wouter', $output);
$this->assertStringContainsString('No connection to the database', $output);
}
}

0 comments on commit a7c4528

Please sign in to comment.