Skip to content

Commit 32a4707

Browse files
committed
Test auto-discovery in List Command
1 parent f17be07 commit 32a4707

6 files changed

Lines changed: 83 additions & 2 deletions

File tree

tests/Command/WorkspaceListCommandTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public function testExecute()
6262
$configContent = file_get_contents('adr.yml');
6363
$configContent = str_replace('docs/arch', $vfs->url(), $configContent);
6464
$configContent = str_replace('vendor/bellangelo/phpadr/', '', $configContent);
65-
$configFile = vfsStream::newFile('adr.yml')->at($vfs)->setContent($configContent)->url();
65+
$configFile = vfsStream::newFile('adr-test.yml')->at($vfs)->setContent($configContent);
6666

6767
$input = [
6868
'command' => $this->command->getName(),
69-
'--config' => $configFile,
69+
'--config' => $configFile->url(),
7070
];
7171

7272
(new Application())->add($this->command);
@@ -84,4 +84,27 @@ public function testExecute()
8484
$this->assertStringContainsString('0001-foo.md', $tester->getDisplay());
8585
$this->assertStringContainsString('0002-bar.md', $tester->getDisplay());
8686
}
87+
88+
public function testExecuteWithAutoDiscovery()
89+
{
90+
$originalValue = $GLOBALS['_composer_autoload_path'] ?? '';
91+
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/../data/vendor/autoload.php';
92+
93+
try {
94+
$input = [
95+
'command' => $this->command->getName(),
96+
];
97+
98+
(new Application())->add($this->command);
99+
100+
$tester = new CommandTester($this->command);
101+
$tester->execute($input);
102+
103+
$this->assertStringContainsString('0001-test1.md', $tester->getDisplay());
104+
$this->assertStringContainsString('0002-test2.md', $tester->getDisplay());
105+
106+
} finally {
107+
$GLOBALS['_composer_autoload_path'] = $originalValue;
108+
}
109+
}
87110
}

tests/data/adr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
directory: tests/data/docs/arch
2+
template:
3+
decision-record: ./skeleton.md

tests/data/docs/arch/0001-test1.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 1. Documenting architecture decisions
2+
3+
Date: 2018-02-11
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
Record certain design decisions for the benefit of future team members as well as for external oversight.
12+
13+
## Decision
14+
15+
Use Architecture Decision Records (ADR), that is a technique for capturing important architectural decisions, along with their context and consequences as described by [Michael Nygard](https://twitter.com/mtnygard) in his article: [Documenting Architecture Decisions](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions).
16+
17+
## Consequences
18+
19+
See Michael Nygard's article, linked above.

tests/data/docs/arch/0002-test2.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 2. Develop tool to manage ADRs
2+
3+
Date: 2018-02-12
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
Encourage and facilitate the use of documentation in agile projects in world of evolutionary architecture using the technique Architecture Decision Records (ADR).
12+
13+
## Decision
14+
15+
Develop a command-line tool to manage the Architecture Decision Records (ADR) that will be stored in version control along with the project source code.
16+
17+
## Consequences
18+
19+
It is very easy for the development team to use.
20+
21+
Project managers, client stakeholders, and others who don't work in version control like the development team, they will can to have difficulty using the tool or not using.
22+
23+
But these people can help to manage Architecture Decision Records (ADR), because the records can be created or edited by a web-based version control repository hosting service, for example: Github, Bitbucket or others.

tests/data/skeleton.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# <sequence>. <title>
2+
3+
Date: <date>
4+
5+
## Status
6+
7+
<status>
8+
9+
## Context
10+
11+
## Decision
12+
13+
## Consequences

tests/data/vendor/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)