Skip to content

Commit

Permalink
tests: add tests for placeholder exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Nov 30, 2020
1 parent d03da2b commit 37b812f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/DoctumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctum\RemoteRepository\GitHubRemoteRepository;
use Doctum\Store\JsonStore;
use Doctum\Version\Version;
use LogicException;

/**
* @author William Desportes <[email protected]>
Expand Down Expand Up @@ -106,6 +107,64 @@ public function testBasicNoGitCustomNameIntegration(): void
], $project->getVersions());
}

public function testBasicGitIntegrationMissingCacheDir(): void
{
$iterator = Finder::create()
->files()
->name('*.php')
->exclude('stubs')
->exclude('database')
->exclude('bootstrap')
->exclude('storage')
->in($dir = __DIR__);

$versions = GitVersionCollection::create($dir)
->add('master', 'Main Branch')
->add('blob', 'Fish Branch');

$doctum = new Doctum($iterator, [
'title' => 'API',
'versions' => $versions,
'build_dir' => __DIR__ . '/build/%version%',
'default_opened_level' => 2,
'remote_repository' => new GitHubRemoteRepository('RepoName', dirname($dir)),
]);
$this->expectExceptionMessage(
'The "cache_dir" setting must have the "%version%" placeholder as the project has more than one version.'
);
$this->expectException(LogicException::class);
$doctum->getProject();
}

public function testBasicGitIntegrationMissingBuildDir(): void
{
$iterator = Finder::create()
->files()
->name('*.php')
->exclude('stubs')
->exclude('database')
->exclude('bootstrap')
->exclude('storage')
->in($dir = __DIR__);

$versions = GitVersionCollection::create($dir)
->add('master', 'Main Branch')
->add('blob', 'Fish Branch');

$doctum = new Doctum($iterator, [
'title' => 'API',
'versions' => $versions,
'cache_dir' => __DIR__ . '/cache/%version%',
'default_opened_level' => 2,
'remote_repository' => new GitHubRemoteRepository('RepoName', dirname($dir)),
]);
$this->expectExceptionMessage(
'The "build_dir" setting must have the "%version%" placeholder as the project has more than one version.'
);
$this->expectException(LogicException::class);
$doctum->getProject();
}

public function testCliOnlyVersion(): void
{
$iterator = Finder::create()
Expand Down

0 comments on commit 37b812f

Please sign in to comment.