Skip to content

Commit

Permalink
[#135] Update PHPUnit Tests to specify covers attribute and convert p…
Browse files Browse the repository at this point in the history
…hpunit xml dist to be phpunit9 supported
  • Loading branch information
jensschuppe committed Jul 3, 2024
1 parent 1ece54b commit 36cce3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
34 changes: 13 additions & 21 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
colors="true"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="true"
bootstrap="tests/phpunit/bootstrap.php">

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" failOnRisky="true" failOnWarning="true" forceCoversAnnotation="true" bootstrap="tests/phpunit/bootstrap.php">
<coverage>
<include>
<directory suffix=".php">api</directory>
<directory suffix=".php">CRM</directory>
<directory suffix=".php">Civi</directory>
</include>
<exclude>
<directory>CRM/*/DAO</directory>
<directory suffix="Base.php">CRM/*/Upgrader</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0&amp;baselineFile=./tests/ignored-deprecations.json"/>
</php>

<testsuites>
<testsuite name="Extension Test Suite">
<directory>./tests/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">api</directory>
<directory suffix=".php">CRM</directory>
<directory suffix=".php">Civi</directory>
<exclude>
<directory>CRM/*/DAO</directory>
<directory suffix="Base.php">CRM/*/Upgrader</directory>
</exclude>
</whitelist>
</filter>
<listeners>
<listener class="Civi\Test\CiviTestListener">
<arguments/>
Expand Down
12 changes: 12 additions & 0 deletions tests/phpunit/api/v4/EckEntity/EckEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function setUpHeadless(): CiviEnvBuilder {
->apply();
}

/**
* @covers \Civi\Api4\EckEntityType::create
*/
public function testCreateEntityType():void {
$entityType = EckEntityType::create(FALSE)
->addValue('label', 'Test One Type')
Expand Down Expand Up @@ -77,6 +80,9 @@ public function testCreateEntityType():void {
self::assertArrayNotHasKey('Eck_Test_One_Type', $extends['options']);
}

/**
* @covers \Civi\Api4\EckEntityType::update
*/
public function testRenameEntityType():void {
$entityType = EckEntityType::create(FALSE)
->addValue('label', 'Test Two Type')
Expand Down Expand Up @@ -110,6 +116,9 @@ public function testRenameEntityType():void {
self::assertStringContainsString('not allowed', $e->getMessage());
}

/**
* @covers \Civi\Api4\EckEntityType::get
*/
public function testTwoEntityTypes(): void {
$firstEntity = $this->createEntity(['one' => 'One', 'two' => 'Two']);
$secondEntity = $this->createEntity(['one' => 'One', 'three' => 'Three']);
Expand Down Expand Up @@ -191,6 +200,9 @@ public function testTwoEntityTypes(): void {
self::assertEquals('three', $secondRecords[1]['subtype:name']);
}

/**
* @covers \Civi\Api4\EckEntityType::get
*/
public function testEntityCustomFields(): void {
$entityName = $this->createEntity(['one' => 'One', 'two' => 'Two']);

Expand Down

0 comments on commit 36cce3c

Please sign in to comment.