Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 42 additions & 80 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,102 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">

<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
beStrictAboutOutputDuringTests="true"
colors="true"
columns="max"
failOnRisky="true"
failOnWarning="true"
cacheDirectory="build/.phpunit.cache">
<coverage
includeUncoveredFiles="true"
pathCoverage="false"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage/html" highLowerBound="80"/>
<text outputFile="build/coverage/coverage.txt"/>
</report>
</coverage>
<extensions>
<bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension">
<parameter name="time-limit" value="0.50" />
<parameter name="report-count" value="30" />
</bootstrap>
</extensions>
<source>
<include>
<directory suffix=".php">./src/</directory>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./src/Config</directory>
<directory suffix=".php">./src/Views</directory>
<directory suffix=".php">./src/Language</directory>
<directory suffix=".php">./src/Collectors</directory>
</exclude>
<report>
<clover outputFile="build/phpunit/clover.xml"/>
<html outputDirectory="build/phpunit/html"/>
<php outputFile="build/phpunit/coverage.serialized"/>
<text outputFile="php://stdout" showUncoveredFiles="false"/>
<xml outputDirectory="build/phpunit/xml-coverage"/>
</report>
</coverage>

</source>
<testsuites>
<testsuite name="main">
<directory>./tests</directory>
<exclude>./tests/Language</exclude>
</testsuite>
</testsuites>

<extensions>
<extension class="Nexus\PHPUnit\Extension\Tachycardia">
<arguments>
<array>
<element key="timeLimit">
<double>0.50</double>
</element>
<element key="reportable">
<integer>30</integer>
</element>
<element key="precision">
<integer>2</integer>
</element>
<element key="collectBare">
<boolean>true</boolean>
</element>
<element key="tabulate">
<boolean>true</boolean>
</element>
</array>
</arguments>
</extension>
</extensions>

<logging>
<testdoxHtml outputFile="build/phpunit/testdox.html"/>
<testdoxText outputFile="build/phpunit/testdox.txt"/>
<junit outputFile="build/phpunit/junit.xml"/>
<testdoxHtml outputFile="build/logs/testdox.html"/>
<testdoxText outputFile="build/logs/testdox.txt"/>
<junit outputFile="build/logs/logfile.xml"/>
<!--<log type="coverage-clover" target="build/logs/clover.xml"/>-->
</logging>

<php>
<env name="XDEBUG_MODE" value="coverage"/>
<server name="app.baseURL" value="https://example.com/"/>

<server name="app.baseURL" value="http://example.com/"/>
<server name="CODEIGNITER_SCREAM_DEPRECATIONS" value="1"/>
<env name="app.appTimezone" value="UTC" force="true"/>
<!-- Directory containing phpunit.xml -->
<const name="HOMEPATH" value="./"/>

<!-- Directory containing the Paths config file -->
<const name="CONFIGPATH" value="./vendor/codeigniter4/framework/app/Config/"/>

<!-- Directory containing the front controller (index.php) -->
<const name="PUBLICPATH" value="./vendor/codeigniter4/framework/public/"/>

<!-- https://getcomposer.org/xdebug -->
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>

<!-- Database configuration -->
<env name="database.tests.strictOn" value="true"/>
<!-- Uncomment to use alternate testing database configuration
<env name="database.tests.hostname" value="localhost"/>
<env name="database.tests.database" value="tests"/>
<env name="database.tests.username" value="tests_user"/>
<env name="database.tests.password" value=""/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
-->
<const name="WRITEPATH" value="./vendor/codeigniter4/framework/writable/"/>
</php>
</phpunit>
2 changes: 2 additions & 0 deletions src/Structures/Mergeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Countable;
use IteratorAggregate;
use Traversable;
use AllowDynamicProperties;

#[AllowDynamicProperties]
class Mergeable implements Countable, IteratorAggregate
{
/**
Expand Down
2 changes: 2 additions & 0 deletions tests/draft/BaseDrafterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
final class BaseDrafterTest extends SchemasTestCase
{
protected ?BaseDrafter $handler = null;

protected function setUp(): void
{
parent::setUp();
Expand Down
6 changes: 3 additions & 3 deletions tests/draft/DatabaseDrafterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testHasAllTables()

public function testHasSpecificTable()
{
$this->assertObjectHasAttribute('factories', $this->schema->tables);
$this->assertTrue(property_exists($this->schema->tables, 'factories'));
}

public function testDetectsPivotTablesWithFK()
Expand All @@ -50,15 +50,15 @@ public function testDetectsPivotTablesWithoutFK()

public function testIgnoredTables()
{
$this->assertObjectNotHasAttribute('migrations', $this->schema->tables);
$this->assertFalse(property_exists($this->schema->tables, 'migrations'));

$config = new Schemas();
$config->ignoredTables = [];

$handler = new DatabaseHandler($config, 'tests');
$schema = $handler->draft();

$this->assertObjectHasAttribute('migrations', $schema->tables);
$this->assertTrue(property_exists($schema->tables, 'migrations'));
}

// -------------------- RELATIONSHIPS --------------------
Expand Down
2 changes: 2 additions & 0 deletions tests/draft/ModelDrafterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
final class ModelDrafterTest extends SchemasTestCase
{
private ?ModelHandler $handler = null;

protected function setUp(): void
{
parent::setUp();
Expand Down
2 changes: 2 additions & 0 deletions tests/misc/BaseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
final class BaseHandlerTest extends SchemasTestCase
{
protected ?BaseHandler $handler = null;

protected function setUp(): void
{
parent::setUp();
Expand Down
6 changes: 3 additions & 3 deletions tests/misc/LiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testDatabaseToCache()
$schemaFromCache = $cache->get('schema-testing');
$this->assertCount(is_countable($schemaFromCache->tables) ? count($schemaFromCache->tables) : 0, $schemaFromService->tables);

$this->assertObjectHasAttribute('factories', $schemaFromCache->tables);
$this->assertTrue(property_exists($schemaFromService->tables, 'factories'));
}

public function testDatabaseMergeFile()
Expand All @@ -50,7 +50,7 @@ public function testDatabaseMergeFile()

$schema = $this->schemas->draft([$databaseHandler, $fileHandler])->get();

$this->assertObjectHasAttribute('products', $schema->tables);
$this->assertTrue(property_exists($schema->tables, 'products'));
$this->assertCount(3, $schema->tables->workers->relations);
}

Expand All @@ -66,7 +66,7 @@ public function testMergeAllDrafters()

$schema = $this->schemas->draft([$databaseHandler, $modelHandler, $fileHandler])->get();

$this->assertObjectHasAttribute('products', $schema->tables);
$this->assertTrue(property_exists($schema->tables, 'products'));
$this->assertSame('Tests\Support\Models\FactoryModel', $schema->tables->factories->model);
$this->assertCount(3, $schema->tables->workers->relations);
}
Expand Down