Skip to content

Commit 7270102

Browse files
committed
Minor cleanup
Change-Id: I0e1da338376bf1f9b2ee91dae65398afc8c90dc5
1 parent 14483a9 commit 7270102

File tree

8 files changed

+28
-34
lines changed

8 files changed

+28
-34
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"php-parallel-lint/php-parallel-lint": "1.3.2",
3838
"phpunit/phpunit": "^8.5"
3939
},
40+
"suggest": {
41+
"ext-dba": "PHP extension for DBA access. Would be quicker than the PHP based fallback"
42+
},
4043
"scripts": {
4144
"test": [
4245
"parallel-lint . --exclude vendor",

src/Cli.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Cdb;
2020

21+
use Throwable;
22+
2123
/**
2224
* @internal For use by bin/cdb only.
2325
*/
@@ -70,7 +72,7 @@ public function run() {
7072
$this->help();
7173
break;
7274
}
73-
} catch ( \Throwable $e ) {
75+
} catch ( Throwable $e ) {
7476
$this->exitCode = 1;
7577
$this->output( (string)$e );
7678
}

src/Reader.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ public static function haveExtension(): bool {
4848
return false;
4949
}
5050
$handlers = dba_handlers();
51-
if ( !in_array( 'cdb', $handlers ) || !in_array( 'cdb_make', $handlers ) ) {
52-
return false;
53-
}
5451

55-
return true;
52+
return in_array( 'cdb', $handlers ) && in_array( 'cdb_make', $handlers );
5653
}
5754

5855
/**

tests/CdbTest.php

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33

44
use Cdb\Reader;
55
use Cdb\Writer;
6-
7-
class CdbTest extends \PHPUnit\Framework\TestCase {
6+
use PHPUnit\Framework\TestCase;
7+
8+
/**
9+
* @covers \Cdb\Util
10+
* @covers \Cdb\Writer
11+
* @covers \Cdb\Writer\PHP
12+
* @covers \Cdb\Writer\DBA
13+
* @covers \Cdb\Reader\PHP
14+
* @covers \Cdb\Reader\DBA
15+
*/
16+
class CdbTest extends TestCase {
817
private $phpCdbFile;
918
private $dbaCdbFile;
1019

@@ -49,34 +58,20 @@ private function cdbAssert( $msg, $key, $expected, $actual ) {
4958
);
5059
}
5160

52-
/**
53-
* @covers Cdb\Reader::open
54-
*/
5561
public function testReaderOpen() {
5662
$this->assertInstanceOf(
5763
Reader::class,
5864
Reader::open( $this->phpCdbFile )
5965
);
6066
}
6167

62-
/**
63-
* @covers Cdb\Writer::open
64-
*/
6568
public function testWriterOpen() {
6669
$this->assertInstanceOf(
6770
Writer::class,
6871
Writer::open( $this->phpCdbFile )
6972
);
7073
}
7174

72-
/**
73-
* @covers Cdb\Util
74-
* @covers Cdb\Writer
75-
* @covers Cdb\Writer\PHP
76-
* @covers Cdb\Writer\DBA
77-
* @covers Cdb\Reader\PHP
78-
* @covers Cdb\Reader\DBA
79-
*/
8075
public function testReadWrite() {
8176
$w1 = new Writer\PHP( $this->phpCdbFile );
8277
$w2 = new Writer\DBA( $this->dbaCdbFile );
@@ -155,17 +150,11 @@ public function testReadWrite() {
155150
$this->assertFalse( $r2->nextkey() );
156151
}
157152

158-
/**
159-
* @covers Cdb\Writer\PHP::finish
160-
*/
161153
public function testEmpty() {
162154
$w = new Writer\PHP( $this->phpCdbFile );
163155
$this->assertNull( $w->close() );
164156
}
165157

166-
/**
167-
* @covers Cdb\Writer::__destruct
168-
*/
169158
public function testDestruct() {
170159
$w = new Writer\PHP( $this->phpCdbFile );
171160
$this->assertInstanceOf(

tests/CliTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
namespace Cdb\Test;
33

44
use Cdb\Cli;
5+
use PHPUnit\Framework\TestCase;
56

67
/**
7-
* @covers Cdb\Cli
8+
* @covers \Cdb\Cli
89
*/
9-
class CliTest extends \PHPUnit\Framework\TestCase {
10+
class CliTest extends TestCase {
1011
private const FIXTURE = __DIR__ . '/fixture/example.cdb';
1112
private $out;
1213

tests/Reader/DBATest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
use Cdb\Exception;
55
use Cdb\Reader;
66
use Cdb\Reader\DBA;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
9-
* @covers Cdb\Reader\DBA
10+
* @covers \Cdb\Reader\DBA
1011
*/
11-
class DBATest extends \PHPUnit\Framework\TestCase {
12+
class DBATest extends TestCase {
1213

1314
protected function setUp(): void {
1415
parent::setUp();

tests/Reader/HashTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Cdb\Reader\Hash;
55

66
/**
7-
* @covers Cdb\Reader\Hash
7+
* @covers \Cdb\Reader\Hash
88
*/
99
class HashTest extends \PHPUnit\Framework\TestCase {
1010

tests/Reader/PHPTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
use Cdb\Exception;
55
use Cdb\Reader\PHP;
6+
use PHPUnit\Framework\TestCase;
67

78
/**
8-
* @covers Cdb\Reader\PHP
9+
* @covers \Cdb\Reader\PHP
910
*/
10-
class PHPTest extends \PHPUnit\Framework\TestCase {
11+
class PHPTest extends TestCase {
1112
private $cdbFile;
1213

1314
protected function setUp(): void {

0 commit comments

Comments
 (0)