Require @covers annotation for tests, increase workspace mem limit to 512M, improved coverage for db factories
This commit is contained in:
parent
724894316a
commit
b41a675a35
|
@ -147,7 +147,7 @@ test:
|
|||
- ./bin/migrate
|
||||
script:
|
||||
- >-
|
||||
php -d pcov.enabled=1 vendor/bin/phpunit -vvv --colors=never
|
||||
php -d pcov.enabled=1 -d pcov.directory=. vendor/bin/phpunit -vvv --colors=never
|
||||
--coverage-text --coverage-html "${HOMEDIR}/coverage/"
|
||||
--log-junit "${HOMEDIR}/unittests.xml"
|
||||
after_script:
|
||||
|
|
|
@ -55,7 +55,7 @@ vendor/bin/phpunit
|
|||
To run code coverage reports its highly recommended to use [`pcov`](https://github.com/krakjoe/pcov) or
|
||||
at least `phpdbg -qrr`(which has problems with switch case statements) as using Xdebug slows down execution.
|
||||
```bash
|
||||
php -d pcov.enabled=1 vendor/bin/phpunit --testsuite Unit --coverage-text
|
||||
php -d pcov.enabled=1 -d pcov.directory=. vendor/bin/phpunit --testsuite Unit --coverage-text
|
||||
```
|
||||
|
||||
### Var Dump server
|
||||
|
|
|
@ -24,6 +24,7 @@ ENV TRUSTED_PROXIES 10.0.0.0/8,::ffff:10.0.0.0/8,\
|
|||
# Engelsystem development workspace
|
||||
# Contains all tools required to build / manage the system
|
||||
FROM es_base AS es_workspace
|
||||
RUN echo 'memory_limit = 512M' > /usr/local/etc/php/conf.d/docker-php.ini
|
||||
RUN apk add --no-cache gettext nodejs npm yarn
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
ENTRYPOINT php -r 'sleep(PHP_INT_MAX);'
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
|
||||
bootstrap="./includes/autoload.php"
|
||||
forceCoversAnnotation="true"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory>./tests/Feature</directory>
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory>./tests/Unit</directory>
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<include>
|
||||
<directory>./src/</directory>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</phpunit>
|
||||
|
|
|
@ -10,6 +10,7 @@ use Engelsystem\Models\Question;
|
|||
use Engelsystem\Models\Room;
|
||||
use Engelsystem\Models\Shifts\Schedule;
|
||||
use Engelsystem\Models\User\Contact;
|
||||
use Engelsystem\Models\User\License;
|
||||
use Engelsystem\Models\User\PasswordReset;
|
||||
use Engelsystem\Models\User\PersonalData;
|
||||
use Engelsystem\Models\User\Settings;
|
||||
|
@ -24,24 +25,41 @@ class FactoriesTest extends TestCase
|
|||
|
||||
/** @var string[] */
|
||||
protected $models = [
|
||||
User::class,
|
||||
Contact::class,
|
||||
PersonalData::class,
|
||||
Settings::class,
|
||||
State::class,
|
||||
PasswordReset::class,
|
||||
Worklog::class,
|
||||
Faq::class,
|
||||
License::class,
|
||||
Message::class,
|
||||
News::class,
|
||||
NewsComment::class,
|
||||
Message::class,
|
||||
Faq::class,
|
||||
PasswordReset::class,
|
||||
PersonalData::class,
|
||||
Question::class,
|
||||
Room::class,
|
||||
Schedule::class,
|
||||
Settings::class,
|
||||
State::class,
|
||||
User::class,
|
||||
Worklog::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Test all existing model factories
|
||||
*
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\ContactFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\FaqFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\LicenseFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\MessageFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\NewsFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\NewsCommentFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\PasswordResetFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\PersonalDataFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\QuestionFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\RoomFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\Shifts\ScheduleFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\SettingsFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\UserFactory
|
||||
* @covers \Database\Factories\Engelsystem\Models\WorklogFactory
|
||||
*/
|
||||
public function testFactories()
|
||||
{
|
||||
|
@ -52,4 +70,17 @@ class FactoriesTest extends TestCase
|
|||
$this->assertInstanceOf(Model::class, $instance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Database\Factories\Engelsystem\Models\User\StateFactory
|
||||
*/
|
||||
public function testStateFactoryArrived()
|
||||
{
|
||||
$this->initDatabase();
|
||||
|
||||
/** @var State $instance */
|
||||
$instance = (new State())->factory()->arrived()->create();
|
||||
$this->assertInstanceOf(Model::class, $instance);
|
||||
$this->assertTrue($instance->arrived);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue