Skip to content

Commit ee71d46

Browse files
committed
Upgrade to PHP 8.1 and higher.
1 parent 7840f04 commit ee71d46

File tree

6 files changed

+93
-51
lines changed

6 files changed

+93
-51
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
12
/.idea/
23
/.phpunit.result.cache
34
/bin/
45
/composer.lock
6+
/custom.task.properties
7+
/custom.type.properties
58
/doc/
69
/test/TestDataLayer.php
710
/test/coverage.xml

build.xml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
<project name="PhpPlaisio" default="build" basedir=".">
2-
<!-- Run composer update and executes various other updates -->
2+
<!-- Update dependencies -->
33
<target name="update">
4-
<exec command="composer update" checkreturn="true" passthru="true"/>
4+
<exec executable="composer" checkreturn="true" passthru="true">
5+
<arg value="--ansi"/>
6+
<arg value="update"/>
7+
</exec>
8+
59
<phing phingfile="build.xml" target="kernel" haltonfailure="true"/>
10+
<phing phingfile="build.xml" target="outdated" haltonfailure="true"/>
11+
</target>
12+
13+
<!-- Install dependencies -->
14+
<target name="install">
15+
<exec executable="composer" checkreturn="true" passthru="true">
16+
<arg value="--ansi"/>
17+
<arg value="install"/>
18+
</exec>
19+
20+
<phing phingfile="build.xml" target="kernel" haltonfailure="true"/>
21+
<phing phingfile="build.xml" target="outdated" haltonfailure="true"/>
22+
</target>
23+
24+
<!-- Show outdated dependencies -->
25+
<target name="outdated">
26+
<exec executable="composer" checkreturn="true" passthru="true">
27+
<arg value="--ansi"/>
28+
<arg value="outdated"/>
29+
<arg value="--direct"/>
30+
</exec>
631
</target>
732

833
<target name="kernel">
@@ -18,12 +43,12 @@
1843

1944
<!-- Runs all unit tests -->
2045
<target name="unit">
21-
<exec command="cat test/ddl/0010_create_database.sql | mysql -v -u root" passthru="true" checkreturn="true"/>
22-
<exec command="cat test/ddl/0020_create_user.sql | mysql -v -u root" passthru="true" checkreturn="true"/>
23-
<exec command="cat test/ddl/0300_abc_auth_company.sql | mysql -v -u root test" passthru="true" checkreturn="true"/>
24-
<exec command="cat lib/ddl/0100_create_tables.sql | mysql -v -u root test" passthru="true" checkreturn="true"/>
25-
<exec command="bin/stratum stratum test/etc/stratum.ini" passthru="true" checkreturn="true"/>
26-
<exec command="bin/phpunit" passthru="true" checkreturn="true"/>
46+
<exec executable="bash" passthru="true" checkreturn="true">
47+
<arg value="-e"/>
48+
<arg value="-x"/>
49+
<arg value="test/unit-test.sh"/>
50+
</exec>
2751
</target>
52+
2853
<target name="build"/>
2954
</project>

composer.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
],
88
"license": "MIT",
99
"require": {
10-
"php": ">=7.4",
11-
"plaisio/blob-store": "^1.2.0",
12-
"plaisio/company-resolver": "^2.0.0",
13-
"plaisio/kernel": "^3.1.1",
14-
"setbased/helper-program-execution": "^1.1.0"
10+
"php": ">=8.1",
11+
"plaisio/blob-store": "^1.3.0",
12+
"plaisio/company-resolver": "^2.1.0",
13+
"plaisio/kernel": "^3.2.1",
14+
"setbased/helper-program-execution": "^1.2.0"
1515
},
16+
"minimum-stability": "dev",
17+
"prefer-stable": true,
1618
"require-dev": {
17-
"phing/phing": "^2.16.4",
18-
"phpunit/phpunit": "^9.5.3",
19-
"plaisio/company-resolver-uni": "^2.0.0",
20-
"plaisio/console": "^2.4.8",
21-
"setbased/php-stratum": "^6.1.0",
22-
"setbased/php-stratum-backend": "^5.3.0",
23-
"setbased/php-stratum-mysql": "^6.4.0"
19+
"phing/phing": "^3.0.0-RC4",
20+
"phpunit/phpunit": "^9.6.3",
21+
"plaisio/company-resolver-uni": "^2.1.0",
22+
"plaisio/console-kernel": "^1.0.0",
23+
"setbased/php-stratum": "^6.3.1",
24+
"setbased/php-stratum-backend": "^6.0.0",
25+
"setbased/php-stratum-mysql": "^6.6.0"
2426
},
2527
"autoload": {
2628
"psr-4": {
@@ -37,6 +39,9 @@
3739
},
3840
"config": {
3941
"bin-dir": "bin/",
40-
"sort-packages": true
42+
"sort-packages": true,
43+
"allow-plugins": {
44+
"phing/phing-composer-configurator": true
45+
}
4146
}
4247
}

test/BlobBlobStoreTest.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@ public function baseStoreAndRetrieve(string $method): void
2626
}
2727

2828
// Search by MD5 hash must give 1 row.
29-
$this->assertCount(1, $this->kernel->blob->searchByMd5(md5_file(__FILE__)));
29+
self::assertCount(1, $this->kernel->blob->searchByMd5(md5_file(__FILE__)));
3030

3131
// Test all fields of getBlob.
3232
$blob = $this->kernel->blob->getBlob($blbId);
33-
$this->assertEquals(1, $blob['blb_id']);
34-
$this->assertEquals(md5_file(__FILE__), strtolower($blob['blb_md5']));
35-
$this->assertEquals(filesize(__FILE__), $blob['blb_size']);
36-
$this->assertEquals(basename(__FILE__), $blob['blb_filename']);
37-
$this->assertNotEmpty($blob['blb_mime_type']);
38-
$this->assertNotEmpty($blob['blb_timestamp']);
39-
$this->assertSame(file_get_contents(__FILE__), $blob['blb_data']);
33+
self::assertEquals(1, $blob['blb_id']);
34+
self::assertEquals(md5_file(__FILE__), strtolower($blob['blb_md5']));
35+
self::assertEquals(filesize(__FILE__), $blob['blb_size']);
36+
self::assertEquals(basename(__FILE__), $blob['blb_filename']);
37+
self::assertNotEmpty($blob['blb_mime_type']);
38+
self::assertNotEmpty($blob['blb_timestamp']);
39+
self::assertSame(file_get_contents(__FILE__), $blob['blb_data']);
4040

4141
// Test all fields of getMetaData.
4242
$meta_data = $this->kernel->blob->getMetadata($blbId);
43-
$this->assertEquals(1, $meta_data['blb_id']);
44-
$this->assertEquals(md5_file(__FILE__), strtolower($meta_data['blb_md5']));
45-
$this->assertEquals(filesize(__FILE__), $meta_data['blb_size']);
46-
$this->assertEquals(basename(__FILE__), $meta_data['blb_filename']);
47-
$this->assertNotEmpty($meta_data['blb_mime_type']);
48-
$this->assertNotEmpty($meta_data['blb_timestamp']);
43+
self::assertEquals(1, $meta_data['blb_id']);
44+
self::assertEquals(md5_file(__FILE__), strtolower($meta_data['blb_md5']));
45+
self::assertEquals(filesize(__FILE__), $meta_data['blb_size']);
46+
self::assertEquals(basename(__FILE__), $meta_data['blb_filename']);
47+
self::assertNotEmpty($meta_data['blb_mime_type']);
48+
self::assertNotEmpty($meta_data['blb_timestamp']);
4949
}
5050

5151
//--------------------------------------------------------------------------------------------------------------------
@@ -62,22 +62,22 @@ public function testCollision(): void
6262
$blbId2 = $this->kernel->blob->putFile($file2, basename($file2));
6363

6464
// We expect 2 rows in ABC_BLOB and ABC_BLOB_DATA.
65-
$this->assertEquals($this->getBlobCount(), 2, 'ABC_BLOB');
66-
$this->assertEquals($this->getBlobDataCount(), 2, 'ABC_BLOB_DATA');
65+
self::assertEquals(2, $this->getBlobCount(), 'ABC_BLOB');
66+
self::assertEquals(2, $this->getBlobDataCount(), 'ABC_BLOB_DATA');
6767

6868
$blob1 = $this->kernel->blob->getBlob($blbId1);
6969
$blob2 = $this->kernel->blob->getBlob($blbId2);
7070

7171
// Hashes must be equal but data not.
72-
$this->assertSame($blob1['blb_md5'], $blob2['blb_md5']);
73-
$this->assertNotSame($blob1['blb_data'], $blob2['blb_data']);
72+
self::assertSame($blob1['blb_md5'], $blob2['blb_md5']);
73+
self::assertNotSame($blob1['blb_data'], $blob2['blb_data']);
7474

7575
// Test data is retrieved correctly.
76-
$this->assertSame(file_get_contents($file1), $blob1['blb_data']);
77-
$this->assertSame(file_get_contents($file2), $blob2['blb_data']);
76+
self::assertSame(file_get_contents($file1), $blob1['blb_data']);
77+
self::assertSame(file_get_contents($file2), $blob2['blb_data']);
7878

7979
// Search by MD5 hash must give 2 rows.
80-
$this->assertCount(2, $this->kernel->blob->searchByMd5($blob1['blb_md5']));
80+
self::assertCount(2, $this->kernel->blob->searchByMd5($blob1['blb_md5']));
8181
}
8282

8383
//--------------------------------------------------------------------------------------------------------------------
@@ -92,8 +92,8 @@ public function testCompanySeparation(): void
9292

9393
$this->kernel->blob->putFile(__FILE__, basename(__FILE__));
9494

95-
$this->assertEquals($this->getBlobCount(), 2, 'ABC_BLOB');
96-
$this->assertEquals($this->getBlobDataCount(), 2, 'ABC_BLOB_DATA');
95+
self::assertEquals(2, $this->getBlobCount(), 'ABC_BLOB');
96+
self::assertEquals(2, $this->getBlobDataCount(), 'ABC_BLOB_DATA');
9797
}
9898

9999
//--------------------------------------------------------------------------------------------------------------------
@@ -103,10 +103,10 @@ public function testCompanySeparation(): void
103103
public function testDelBlob(): void
104104
{
105105
$blbId = $this->kernel->blob->putFile(__FILE__, basename(__FILE__));
106-
$this->assertEquals($this->getBlobCount(), 1, 'ABC_BLOB');
106+
self::assertEquals(1, $this->getBlobCount(), 'ABC_BLOB');
107107

108108
$this->kernel->blob->delBlob($blbId);
109-
$this->assertEquals($this->getBlobCount(), 0, 'ABC_BLOB');
109+
self::assertEquals(0, $this->getBlobCount(), 'ABC_BLOB');
110110
}
111111

112112
//--------------------------------------------------------------------------------------------------------------------
@@ -119,7 +119,7 @@ public function testMimeTypeTranslationPutString(): void
119119

120120
$blob = $this->kernel->blob->getMetadata($blbId);
121121

122-
$this->assertStringStartsWith('application/pdf', $blob['blb_mime_type']);
122+
self::assertStringStartsWith('application/pdf', $blob['blb_mime_type']);
123123
}
124124

125125
//--------------------------------------------------------------------------------------------------------------------
@@ -131,8 +131,8 @@ public function testReUsage(): void
131131
$this->kernel->blob->putFile(__FILE__, basename(__FILE__));
132132
$this->kernel->blob->putFile(__FILE__, basename(__FILE__));
133133

134-
$this->assertEquals($this->getBlobCount(), 2, 'ABC_BLOB');
135-
$this->assertEquals($this->getBlobDataCount(), 1, 'ABC_BLOB_DATA');
134+
self::assertEquals(2, $this->getBlobCount(), 'ABC_BLOB');
135+
self::assertEquals(1, $this->getBlobDataCount(), 'ABC_BLOB_DATA');
136136
}
137137

138138
//--------------------------------------------------------------------------------------------------------------------

test/TestKernelSys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function getCompany(): CompanyResolver
4343
*
4444
* @return Object
4545
*/
46-
protected function getDL(): Object
46+
protected function getDL(): object
4747
{
48-
$connector = new MySqlDefaultConnector('localhost', 'test', 'test', 'test');
48+
$connector = new MySqlDefaultConnector('127.0.0.1', 'test', 'test', 'test');
4949
$dl = new TestDataLayer($connector);
5050
$dl->connect();
5151

test/unit-test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -e -x
2+
3+
mysql -v -uroot -h127.0.0.1 < test/ddl/0010_create_database.sql
4+
mysql -v -uroot -h127.0.0.1 < test/ddl/0020_create_user.sql
5+
mysql -v -uroot -h127.0.0.1 test < test/ddl/0300_abc_auth_company.sql
6+
mysql -v -uroot -h127.0.0.1 test < lib/ddl/0100_create_tables.sql
7+
8+
./bin/stratum stratum test/etc/stratum.ini
9+
./bin/phpunit

0 commit comments

Comments
 (0)