Ensure that the directory doesn't already exist

This commit is contained in:
Oliver Davies 2020-02-09 12:11:20 +00:00
parent d17c1defcf
commit 0ece90c6cf
7 changed files with 217 additions and 4 deletions

View file

@ -0,0 +1,27 @@
<?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
{
/** @test */
public function it_throws_an_exception_if_the_directory_already_exists() {
mkdir('my-existing-drupal-module');
try {
$commandTester = new CommandTester(new GenerateDrupal7Command());
$commandTester->execute([
'module-name' => 'my-existing-drupal-module',
]);
} catch (CannotCreateModuleException $e) {
$this->addToAssertionCount(1);
}
rmdir('my-existing-drupal-module');
}
}