Skip to content

Commit

Permalink
Add cmd test
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed May 31, 2024
1 parent 565006e commit c30de39
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/command/__files/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
use midgard\portable\driver;
use midgard\portable\storage\connection;

$schema_dirs = [dirname(__DIR__, 2) . '/__files/membership/'];

$driver = new driver($schema_dirs, dirname(__DIR__, 2) . '/__output/commandTest/var', 'schemaCommandTest');

// CHANGE PARAMETERS AS REQUIRED:
$db_config = [
'memory' => true,
'driver' => 'pdo_sqlite',
];

connection::initialize($driver, $db_config, true);
30 changes: 30 additions & 0 deletions test/command/schemaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
* @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/

namespace midgard\portable\test;

use midgard\portable\command\schema;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Command\Command;

class schemaTest extends testcase
{
public function test_run()
{
$command = new schema;
$input = new ArrayInput(['config' => __DIR__ . '/__files/config.php']);
$output = new BufferedOutput;
$this->assertSame(Command::SUCCESS, $command->run($input, $output));

$this->assertStringStartsWith('Creating 5 new tables', $output->fetch());
$vardir = dirname(__DIR__) . '/__output/commandTest/var/';
$this->assertDirectoryExists($vardir . 'blobs/0/0');
$this->assertFileExists($vardir . 'mgdschema_classes.php');
$this->assertTrue(class_exists(\schemaCommandTest\midgard_group::class));
}
}

0 comments on commit c30de39

Please sign in to comment.