Skip to content

Commit ee26a65

Browse files
committed
Make tests compatible with latest version
1 parent 78d6a57 commit ee26a65

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

tests/ClassTest.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
namespace Composer\XdebugHandler\Tests;
1313

14-
use Composer\XdebugHandler\Tests\Helpers\BaseTestCase;
1514
use Composer\XdebugHandler\Tests\Helpers\LoggerFactory;
1615
use Composer\XdebugHandler\XdebugHandler;
16+
use PHPUnit\Framework\TestCase;
1717

18-
class ClassTest extends BaseTestCase
18+
class ClassTest extends TestCase
1919
{
2020
/**
2121
* @return void
@@ -37,32 +37,20 @@ public function testConstructorThrowsOnInvalidEnvPrefix()
3737
}
3838

3939
/**
40-
* @dataProvider setterProvider *
41-
* @param string $setter
42-
* @param \Psr\Log\AbstractLogger|string|null $value
43-
*
4440
* @return void
4541
*/
46-
public function testSettersAreFluent($setter, $value)
42+
public function testSettersAreFluent()
4743
{
4844
$xdebug = new XdebugHandler('myapp');
4945

50-
$params = null !== $value ? array($value) : array();
51-
$result = BaseTestCase::safeCall($xdebug, $setter, $params, $this);
52-
self::assertInstanceOf(get_class($xdebug), $result);
53-
}
46+
$result = $xdebug->setLogger(LoggerFactory::createLogger());
47+
self::assertInstanceOf(get_class($xdebug), $result, 'setLogger');
5448

55-
/**
56-
* @return array<string, mixed[]>
57-
*/
58-
public function setterProvider()
59-
{
60-
// $setter, $value
61-
return array(
62-
'setLogger' => array('setLogger', LoggerFactory::createLogger()),
63-
'setMainScript' => array('setMainScript', '--'),
64-
'setPersistent' => array('setPersistent', null),
65-
);
49+
$result = $xdebug->setMainScript('--');
50+
self::assertInstanceOf(get_class($xdebug), $result, 'setMainScript');
51+
52+
$result = $xdebug->setPersistent();
53+
self::assertInstanceOf(get_class($xdebug), $result, 'setPersistent');
6654
}
6755

6856
/**

tests/bootstrap_phpstan.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
<?php
2+
/**
3+
* Provides flexibilty for using either simple-phpunit or phpunit
4+
*/
25

36
$vendorBin = __DIR__.'/../vendor/bin';
7+
8+
// See if we using simple-phpunit
49
$path = realpath($vendorBin.'/simple-phpunit');
510

6-
if (!file_exists($vendorBin.'/phpunit') && $path !== false) {
7-
passthru(escapeshellarg($path).' install');
11+
if ($path !== false) {
12+
// simple-phpunit will update the .phpunit symlink/junction
13+
$phpunit = escapeshellarg(PHP_BINARY).' '.escapeshellarg($path);
14+
passthru($phpunit.' install');
815

916
$autoloader = $vendorBin.'/.phpunit/phpunit/vendor/autoload.php';
10-
if (file_exists($autoloader)) {
11-
require $autoloader;
17+
if (!file_exists($autoloader)) {
18+
echo 'Cannot run PHPStan: simple-phpunit did not install PHPUnit as expected'.PHP_EOL;
19+
exit(1);
1220
}
21+
22+
include $autoloader;
23+
return;
24+
}
25+
26+
if (realpath($vendorBin.'/phpunit') === false) {
27+
echo 'Cannot run PHPStan: PHPUnit has not been installed'.PHP_EOL;
28+
exit(1);
1329
}

0 commit comments

Comments
 (0)