Skip to content

Commit b848eae

Browse files
committed
Issue #13: Codecov percentage optimizations
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent ad51354 commit b848eae

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

test/ComponentTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,15 @@ public function testWillRenderInputServiceInterface(): void
269269
$this->assertSame('BOOK_STORE_SERVICE_INTERFACE', $component->toUpperCase(false));
270270
$this->assertSame('BOOK_STORE_SERVICE', $component->toUpperCase());
271271
}
272+
273+
public function testWillPluralize(): void
274+
{
275+
$this->assertSame('buses', Component::pluralize('bus'));
276+
$this->assertSame('boxes', Component::pluralize('box'));
277+
$this->assertSame('jazzes', Component::pluralize('jazz'));
278+
$this->assertSame('fishes', Component::pluralize('fish'));
279+
$this->assertSame('watches', Component::pluralize('watch'));
280+
$this->assertSame('candies', Component::pluralize('candy'));
281+
$this->assertSame('books', Component::pluralize('book'));
282+
}
272283
}

test/MakerTest.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ public function testWillInstantiate(): void
5151
{
5252
$maker = new Maker('');
5353
$this->assertContainsOnlyInstancesOf(Maker::class, [$maker]);
54+
$this->assertTrue($maker->isCli());
5455
}
5556

56-
public function testInvokeWillOutputErrorWhenNotInCliMode(): void
57+
public function testCallingInvokeWillOutputErrorWhenNotInCliMode(): void
5758
{
5859
$maker = $this->getMockBuilder(Maker::class)
5960
->onlyMethods(['isCli'])
@@ -69,7 +70,7 @@ public function testInvokeWillOutputErrorWhenNotInCliMode(): void
6970
);
7071
}
7172

72-
public function testInvokeWillOutputErrorWhenInvalidComponent(): void
73+
public function testCallingInvokeWillOutputErrorWhenInvalidComponent(): void
7374
{
7475
$root = vfsStream::setup('root', 0644, [
7576
'composer.json' => '{
@@ -98,7 +99,7 @@ public function testInvokeWillOutputErrorWhenInvalidComponent(): void
9899
$this->assertEmpty(stream_get_contents($this->outputStream));
99100
}
100101

101-
public function testInvokeWithoutArgsWillOutputHelpText(): void
102+
public function testCallingInvokeWithoutArgsWillOutputHelpText(): void
102103
{
103104
$root = vfsStream::setup('root', 0644, [
104105
'composer.json' => '{
@@ -161,4 +162,35 @@ public function testCallingInvokeWithArgsModuleWillOutputDebugInfo(): void
161162
);
162163
$this->assertEmpty(stream_get_contents($this->errorStream));
163164
}
165+
166+
public function testCallingInvokeWithValidComponentIdentifierWillSucceed(): void
167+
{
168+
$root = vfsStream::setup('root', 0644, [
169+
'composer.json' => '{
170+
"autoload": {
171+
"psr-4": {
172+
"Api\\\\App\\\\": "src/App/src/"
173+
}
174+
}
175+
}',
176+
'src' => [
177+
'App' => [],
178+
],
179+
]);
180+
181+
fwrite($this->inputStream, 'App' . PHP_EOL);
182+
fwrite($this->inputStream, 'Test' . PHP_EOL);
183+
fwrite($this->inputStream, PHP_EOL);
184+
rewind($this->inputStream);
185+
186+
$maker = $this->getMockBuilder(Maker::class)
187+
->onlyMethods(['isCli'])
188+
->setConstructorArgs([$root->url()])
189+
->getMock();
190+
$maker->method('isCli')->willReturn(true);
191+
$maker(['', 'command']);
192+
193+
rewind($this->errorStream);
194+
$this->assertEmpty(stream_get_contents($this->errorStream));
195+
}
164196
}

test/Type/ModuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ public function testWillCallAccessors(): void
8787
$module->setModule($module);
8888
$this->assertContainsOnlyInstancesOf(Module::class, [$module->getModule()]);
8989
$this->assertTrue($module->hasModule());
90+
91+
$module->setConfig(new Config($root->url()));
92+
$module->setContext(new Context($root->url()));
93+
$module->setFileSystem((new FileSystem($context))->setModuleName($this->moduleName));
94+
$this->assertContainsOnlyInstancesOf(Config::class, [$module->getConfig()]);
95+
$this->assertContainsOnlyInstancesOf(Context::class, [$module->getContext()]);
96+
$this->assertContainsOnlyInstancesOf(FileSystem::class, [$module->getFileSystem()]);
9097
}
9198

9299
public function testCallToInvokeWillEarlyReturnOnEmptyInput(): void

0 commit comments

Comments
 (0)