2020-02-09 12:11:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Opdavies\Tests\DrupalModuleGenerator\Command;
|
|
|
|
|
|
|
|
use Opdavies\DrupalModuleGenerator\Command\GenerateDrupal7Command;
|
|
|
|
use Opdavies\DrupalModuleGenerator\Exception\CannotCreateModuleException;
|
|
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class GenerateDrupal7ModuleCommandTest extends TestCase
|
|
|
|
{
|
2020-02-09 12:30:28 +00:00
|
|
|
protected function tearDown(): void
|
|
|
|
{
|
|
|
|
rmdir('test_module');
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:11:20 +00:00
|
|
|
/** @test */
|
|
|
|
public function it_throws_an_exception_if_the_directory_already_exists() {
|
2020-02-09 12:30:28 +00:00
|
|
|
mkdir('test_module');
|
|
|
|
|
|
|
|
$this->expectExceptionObject(CannotCreateModuleException::directoryAlreadyExists());
|
|
|
|
|
|
|
|
$commandTester = new CommandTester(new GenerateDrupal7Command());
|
|
|
|
$commandTester->execute([
|
|
|
|
'module-name' => 'test_module'
|
|
|
|
]);
|
2020-02-09 12:11:20 +00:00
|
|
|
}
|
2020-02-09 12:24:28 +00:00
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function it_creates_a_new_module_directory()
|
|
|
|
{
|
|
|
|
$commandTester = new CommandTester(new GenerateDrupal7Command());
|
|
|
|
$commandTester->execute([
|
2020-02-09 12:30:28 +00:00
|
|
|
'module-name' => 'test_module',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertTrue(is_dir('test_module'));
|
|
|
|
}
|
2020-02-09 12:24:28 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertTrue(is_dir('my-new-drupal-module'));
|
|
|
|
|
|
|
|
rmdir('my-new-drupal-module');
|
|
|
|
}
|
2020-02-09 12:11:20 +00:00
|
|
|
}
|