Skip to content

Commit 12f0426

Browse files
committed
Migrate to plaisio/kernel 2.0.
1 parent cb1b2a9 commit 12f0426

File tree

10 files changed

+130
-48
lines changed

10 files changed

+130
-48
lines changed

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/.idea/
22
/.phpunit.result.cache
33
/bin/
4-
/doc/
5-
/vendor/
64
/composer.lock
5+
/doc/
6+
/test/C.php
7+
/test/TestDataLayer.php
8+
/test/coverage.xml
79
/test/etc/columns.txt
810
/test/etc/routines.json
9-
/test/DataLayer.php
1011
/test/report/
11-
/test/C.php
12-
/test/coverage.xml
12+
/vendor/

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
"PhpPlaisio",
66
"BLOB-Store"
77
],
8-
"type": "library",
98
"license": "MIT",
109
"require": {
1110
"php": ">=7.3",
1211
"plaisio/blob-store": "^1.1",
13-
"plaisio/kernel": "^1.1",
12+
"plaisio/kernel": "^2.0",
1413
"setbased/helper-program-execution": "^1.1"
1514
},
1615
"require-dev": {
1716
"phing/phing": "^2.0",
1817
"phpunit/phpunit": "^9.0",
1918
"plaisio/company-resolver-uni": "^1.1",
20-
"setbased/php-stratum": "^5.4",
21-
"setbased/php-stratum-mysql": "^4.4"
19+
"setbased/php-stratum": "^6.0",
20+
"setbased/php-stratum-mysql": "^5.0"
2221
},
2322
"autoload": {
2423
"psr-4": {

src/BlobBlobStore.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BlobBlobStore implements BlobStore
3232
*/
3333
public function delBlob(int $blbId): void
3434
{
35-
Nub::$DL->abcBlobDelBlob(Nub::$companyResolver->getCmpId(), $blbId);
35+
Nub::$nub->DL->abcBlobDelBlob(Nub::$nub->companyResolver->getCmpId(), $blbId);
3636
}
3737

3838
//--------------------------------------------------------------------------------------------------------------------
@@ -41,7 +41,7 @@ public function delBlob(int $blbId): void
4141
*/
4242
public function getBlob(int $blbId): array
4343
{
44-
return Nub::$DL->abcBlobGetBlob(Nub::$companyResolver->getCmpId(), $blbId);
44+
return Nub::$nub->DL->abcBlobGetBlob(Nub::$nub->companyResolver->getCmpId(), $blbId);
4545
}
4646

4747
//--------------------------------------------------------------------------------------------------------------------
@@ -50,7 +50,7 @@ public function getBlob(int $blbId): array
5050
*/
5151
public function getMetadata(int $blbId): array
5252
{
53-
return Nub::$DL->abcBlobGetMetadata(Nub::$companyResolver->getCmpId(), $blbId);
53+
return Nub::$nub->DL->abcBlobGetMetadata(Nub::$nub->companyResolver->getCmpId(), $blbId);
5454
}
5555

5656
//--------------------------------------------------------------------------------------------------------------------
@@ -59,11 +59,9 @@ public function getMetadata(int $blbId): array
5959
*/
6060
public function mimeTypePath(string $path): string
6161
{
62-
list($output) = ProgramExecution::exec1([self::$filePath, '-ib', $path], [0], true);
62+
[$output] = ProgramExecution::exec1([self::$filePath, '-ib', $path], [0], true);
6363

64-
$mimeType = $output[0];
65-
66-
return $mimeType;
64+
return $output[0];
6765
}
6866

6967
//--------------------------------------------------------------------------------------------------------------------
@@ -102,9 +100,9 @@ public function putFile(string $path, string $filename, ?string $mimeType = null
102100

103101
$data = file_get_contents($path);
104102

105-
Nub::$DL->abcBlobInsertBlob(Nub::$companyResolver->getCmpId(), $filename, $mimeType, $timestamp, $data);
103+
Nub::$nub->DL->abcBlobInsertBlob(Nub::$nub->companyResolver->getCmpId(), $filename, $mimeType, $timestamp, $data);
106104

107-
return Nub::$DL->abcBlobWorkaround();
105+
return Nub::$nub->DL->abcBlobWorkaround();
108106
}
109107

110108
//--------------------------------------------------------------------------------------------------------------------
@@ -118,9 +116,9 @@ public function putString(string $data, string $filename, ?string $mimeType = nu
118116
$mimeType = $this->mimeTypeString($data);
119117
}
120118

121-
Nub::$DL->abcBlobInsertBlob(Nub::$companyResolver->getCmpId(), $filename, $mimeType, $timestamp, $data);
119+
Nub::$nub->DL->abcBlobInsertBlob(Nub::$nub->companyResolver->getCmpId(), $filename, $mimeType, $timestamp, $data);
122120

123-
return Nub::$DL->abcBlobWorkaround();
121+
return Nub::$nub->DL->abcBlobWorkaround();
124122
}
125123

126124
//--------------------------------------------------------------------------------------------------------------------
@@ -129,7 +127,7 @@ public function putString(string $data, string $filename, ?string $mimeType = nu
129127
*/
130128
public function searchByMd5(string $md5): array
131129
{
132-
return Nub::$DL->abcBlobGetMetadataByMd5(Nub::$companyResolver->getCmpId(), $md5);
130+
return Nub::$nub->DL->abcBlobGetMetadataByMd5(Nub::$nub->companyResolver->getCmpId(), $md5);
133131
}
134132
}
135133

test/BlobBlobStoreTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
namespace Plaisio\BlobStore\Test;
55

66
use Plaisio\BlobStore\BlobBlobStore;
7-
use Plaisio\C;
8-
use Plaisio\CompanyResolver\UniCompanyResolver;
9-
use Plaisio\Kernel\Nub;
107

118
/**
129
* Test cases for BlobBlobStore
@@ -98,7 +95,9 @@ public function testCompanySeparation(): void
9895
$store = new BlobBlobStore();
9996

10097
$store->putFile(__FILE__, basename(__FILE__));
101-
Nub::$companyResolver = new UniCompanyResolver(C::CMP_ID_ABC);
98+
99+
$this->kernel = new TestKernelPlaisio();
100+
102101
$store->putFile(__FILE__, basename(__FILE__));
103102

104103
$this->assertEquals($this->getBlobCount(), 2, 'ABC_BLOB');

test/BlobBlobStoreTestCase.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@
44
namespace Plaisio\BlobStore\Test;
55

66
use PHPUnit\Framework\TestCase;
7-
use Plaisio\C;
8-
use Plaisio\CompanyResolver\UniCompanyResolver;
97
use Plaisio\Kernel\Nub;
108

119
/**
1210
* Parent class for test cases for BlobBlobStore.
1311
*/
1412
class BlobBlobStoreTestCase extends TestCase
1513
{
14+
//--------------------------------------------------------------------------------------------------------------------
15+
/**
16+
* The kernel.
17+
*
18+
* @var Nub
19+
*/
20+
protected $kernel;
21+
1622
//--------------------------------------------------------------------------------------------------------------------
1723
/**
1824
* Returns the number of rows in table ABC_BLOB.
1925
*/
2026
protected function getBlobCount(): int
2127
{
22-
return Nub::$DL->executeSingleton1('select count(*) from `ABC_BLOB`');
28+
return Nub::$nub->DL->executeSingleton1('select count(*) from `ABC_BLOB`');
2329
}
2430

2531
//--------------------------------------------------------------------------------------------------------------------
@@ -28,7 +34,7 @@ protected function getBlobCount(): int
2834
*/
2935
protected function getBlobDataCount(): int
3036
{
31-
return Nub::$DL->executeSingleton1('select count(*) from `ABC_BLOB_DATA`');
37+
return Nub::$nub->DL->executeSingleton1('select count(*) from `ABC_BLOB_DATA`');
3238
}
3339

3440
//--------------------------------------------------------------------------------------------------------------------
@@ -37,15 +43,12 @@ protected function getBlobDataCount(): int
3743
*/
3844
protected function setUp(): void
3945
{
40-
Nub::$DL = new DataLayer();
41-
Nub::$companyResolver = new UniCompanyResolver(C::CMP_ID_SYS);
42-
43-
Nub::$DL->connect('localhost', 'test', 'test', 'test');
46+
$this->kernel = new TestKernelSys();
4447

45-
Nub::$DL->executeNone('set foreign_key_checks = 0');
46-
Nub::$DL->executeNone('truncate table `ABC_BLOB`');
47-
Nub::$DL->executeNone('truncate table `ABC_BLOB_DATA`');
48-
Nub::$DL->executeNone('set foreign_key_checks = 1');
48+
Nub::$nub->DL->executeNone('set foreign_key_checks = 0');
49+
Nub::$nub->DL->executeNone('truncate table `ABC_BLOB`');
50+
Nub::$nub->DL->executeNone('truncate table `ABC_BLOB_DATA`');
51+
Nub::$nub->DL->executeNone('set foreign_key_checks = 1');
4952
}
5053

5154
//--------------------------------------------------------------------------------------------------------------------
@@ -54,7 +57,7 @@ protected function setUp(): void
5457
*/
5558
protected function tearDown(): void
5659
{
57-
Nub::$DL->disconnect();
60+
Nub::$nub->DL->disconnect();
5861
}
5962

6063
//--------------------------------------------------------------------------------------------------------------------

test/C.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class C
1414
*
1515
* Below this doc block constants will be inserted by PhpStratum.
1616
*/
17-
const CMP_ID_ABC = 2;
18-
const CMP_ID_SYS = 1;
17+
const CMP_ID_PLAISIO = 2;
18+
const CMP_ID_SYS = 1;
1919

2020
//--------------------------------------------------------------------------------------------------------------------
2121
}

test/TestKernelPlaisio.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Plaisio\BlobStore\Test;
5+
6+
use Plaisio\C;
7+
use Plaisio\CompanyResolver\CompanyResolver;
8+
use Plaisio\CompanyResolver\UniCompanyResolver;
9+
10+
/**
11+
* Kernel for testing purposes.
12+
*/
13+
class TestKernelPlaisio extends TestKernelSys
14+
{
15+
//--------------------------------------------------------------------------------------------------------------------
16+
/**
17+
* Returns the helper object for deriving the company.
18+
*
19+
* @return CompanyResolver
20+
*/
21+
public function getCompanyResolver(): CompanyResolver
22+
{
23+
return new UniCompanyResolver(C::CMP_ID_PLAISIO);
24+
}
25+
26+
//--------------------------------------------------------------------------------------------------------------------
27+
}
28+
29+
//----------------------------------------------------------------------------------------------------------------------

test/TestKernelSys.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Plaisio\BlobStore\Test;
5+
6+
use Plaisio\C;
7+
use Plaisio\CompanyResolver\CompanyResolver;
8+
use Plaisio\CompanyResolver\UniCompanyResolver;
9+
use Plaisio\Kernel\Nub;
10+
use SetBased\Stratum\MySql\MySqlDefaultConnector;
11+
12+
/**
13+
* Kernel for testing purposes.
14+
*/
15+
class TestKernelSys extends Nub
16+
{
17+
//--------------------------------------------------------------------------------------------------------------------
18+
/**
19+
* Object constructor.
20+
*/
21+
public function __construct()
22+
{
23+
parent::__construct();
24+
}
25+
26+
//--------------------------------------------------------------------------------------------------------------------
27+
/**
28+
* Returns the helper object for deriving the company.
29+
*
30+
* @return CompanyResolver
31+
*/
32+
public function getCompanyResolver(): CompanyResolver
33+
{
34+
return new UniCompanyResolver(C::CMP_ID_SYS);
35+
}
36+
37+
//--------------------------------------------------------------------------------------------------------------------
38+
/**
39+
* Returns the data layer generated by PhpStratum.
40+
*
41+
* @return Object
42+
*/
43+
protected function getDL(): Object
44+
{
45+
$connector = new MySqlDefaultConnector('localhost', 'test', 'test', 'test');
46+
$dl = new TestDataLayer($connector);
47+
$dl->connect();
48+
49+
return $dl;
50+
}
51+
52+
//--------------------------------------------------------------------------------------------------------------------
53+
}
54+
55+
//----------------------------------------------------------------------------------------------------------------------

test/ddl/0300_abc_auth_company.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ CREATE TABLE `ABC_AUTH_COMPANY` (
66
);
77

88
insert into `ABC_AUTH_COMPANY`( `cmp_id`
9-
, `cmp_abbr`
10-
, `cmp_label` )
9+
, `cmp_abbr`
10+
, `cmp_label` )
1111
values( 1
1212
, 'SYS'
1313
, 'CMP_ID_SYS')
1414
, ( 2
1515
, 'ABC'
16-
, 'CMP_ID_ABC')
16+
, 'CMP_ID_PLAISIO')
1717
;
1818

19-
commit;
19+
commit;

test/etc/stratum.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ character_set = utf8
1919
collate = utf8_general_ci
2020

2121
[wrapper]
22-
parent_class = \SetBased\Stratum\MySql\DataLayer
22+
parent_class = \SetBased\Stratum\MySql\MySqlDataLayer
2323
mangler_class = \SetBased\Stratum\Middle\NameMangler\PsrNameMangler
24-
wrapper_class = \Plaisio\BlobStore\Test\DataLayer
25-
wrapper_file = test/DataLayer.php
26-
wrapper_type = non static
24+
wrapper_class = \Plaisio\BlobStore\Test\TestDataLayer
25+
wrapper_file = test/TestDataLayer.php

0 commit comments

Comments
 (0)