-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jacob Dreesen <[email protected]>
- Loading branch information
Showing
8 changed files
with
115 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
$xmlContent = file_get_contents('.coverage/cobertura.xml'); | ||
$matches = []; | ||
preg_match("#coverage line-rate=\"(.*)\"#U", $xmlContent, $matches); | ||
|
||
$coverage = (int) ((float) $matches[1] * 100); | ||
|
||
echo "Coverage: " . $coverage . "%\n"; | ||
|
||
if ($coverage < 80) { | ||
echo "Test coverage is below 80%\n"; | ||
exit(1); // Gibt einen Fehlercode zurück, der den Build fehlschlagen lässt | ||
} | ||
|
||
echo "Test coverage is sufficient.\n"; | ||
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Tests\Target; | ||
|
||
use Neusta\ConverterBundle\Target\GenericTargetFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class GenericTargetFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function create_regular_case(): void | ||
{ | ||
$factory = new GenericTargetFactory(TestTarget::class); | ||
|
||
self::assertInstanceOf(TestTarget::class, $factory->create()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function create_with_non_instantiable_case(): void | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage(\sprintf( | ||
'Target class "%s" is not instantiable', | ||
TestNonInstantiableTarget::class, | ||
)); | ||
|
||
new GenericTargetFactory(TestNonInstantiableTarget::class); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function create_with_constructor_params_case(): void | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage(\sprintf( | ||
'Target class "%s" has required constructor parameters', | ||
TestWithConstructorParamsTarget::class, | ||
)); | ||
|
||
new GenericTargetFactory(TestWithConstructorParamsTarget::class); | ||
} | ||
} | ||
|
||
class TestTarget | ||
{ | ||
} | ||
|
||
abstract class TestNonInstantiableTarget | ||
{ | ||
} | ||
|
||
class TestWithConstructorParamsTarget | ||
{ | ||
public function __construct($value) | ||
{ | ||
} | ||
} |