-
-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Description
Q | A |
---|---|
php-code-coverage version | 7.0.7 |
PHP version | 7.3.6 |
Driver | Xdebug |
Xdebug version (if used) | 2.7.2 |
Installation Method | Composer |
Usage Method | PHPUnit |
PHPUnit version (if used) | 8.3.4 |
Target Class
<?php
declare(strict_types=1);
namespace App\Service;
class SoapClientService
{
/**
* @const string
*/
const URL = 'http://example.com/service.jws?wsdl';
/**
* @var \SoapClient
*/
protected $soapClient = null;
/**
* @param string $url
* @return \SoapClient
* @throws \InvalidArgumentException
*/
public function getSoapClient(string $url = null)
{
if (!isset($this->soapClient)) {
try {
$this->soapClient = new \SoapClient(
$url ?? self::URL
);
} catch (\Throwable $error) {
throw new \InvalidArgumentException('Failed to initialize Soap Client');
}
}
return $this->soapClient;
}
}
Target TestCase
<?php
declare(strict_types=1);
namespace App\Tests\Service;
use App\Service\SoapClientService;
use PHPUnit\Framework\TestCase;
/**
* Unit test for SoapClientService
*/
class SoapClientServiceTest extends TestCase
{
public function testGetSoapClient(): void
{
$client = new SoapClientService();
$this->expectException(\InvalidArgumentException::class);
$client->getSoapClient('no-wsdl');
}
}
Command for generate Code Coverage XML Report
vendor/bin/phpunit -v --coverage-xml build/coverage-xml
After executing comand, folder build/coverage-xml
contains empty files.
Other reports (HTML, Clover, PHP) works as expected.
Also reproduced on the previous version of sebastianbergmann/php-code-coverage
.
Metadata
Metadata
Assignees
Labels
No labels