Skip to content

Commit e4b0bcd

Browse files
committed
github ci
1 parent 58f6df3 commit e4b0bcd

File tree

5 files changed

+126
-3
lines changed

5 files changed

+126
-3
lines changed

.github/workflows/ci.yaml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
on: [push, pull_request]
2+
3+
name: CI
4+
5+
jobs:
6+
php-cs-fixer:
7+
name: PHP-CS-Fixer
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@master
11+
- name: Setup PHP
12+
uses: shivammathur/setup-php@v2
13+
with:
14+
php-version: '8.0'
15+
extensions: apcu
16+
- name: PHP-CS-Fixer
17+
uses: OskarStark/[email protected]
18+
with:
19+
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
20+
21+
phpstan:
22+
name: PHPStan Static Analysis
23+
runs-on: ubuntu-20.04
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: '8.0'
31+
extensions: apcu, smbclient
32+
- name: Composer
33+
run: composer install
34+
- env:
35+
BACKEND: smbclient
36+
run: php ./vendor/bin/phpstan analyse --level 1 src
37+
38+
phpunit:
39+
runs-on: ubuntu-20.04
40+
name: Unit tests
41+
42+
services:
43+
samba:
44+
image: dperson/samba
45+
env:
46+
USER: "test;test"
47+
SHARE: "test;/tmp;yes;no;yes;all;none"
48+
ports:
49+
- 139:139
50+
- 445:445
51+
52+
steps:
53+
- name: Install packages
54+
run: |
55+
sudo apt-get install smbclient
56+
- uses: actions/checkout@v2
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: '8.0'
61+
extensions: apcu, smbclient
62+
- name: Composer
63+
run: composer install
64+
- name: Config
65+
run: |
66+
cat tests/config.json
67+
echo '{"host": "localhost","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
68+
cat tests/config.json
69+
- name: PHPUnit Tests
70+
env:
71+
BACKEND: smbclient
72+
run: php ./vendor/bin/phpunit tests

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
},
1515
"require-dev": {
1616
"phpunit/phpunit": "^9.3.8",
17-
"friendsofphp/php-cs-fixer": "^2.16"
17+
"friendsofphp/php-cs-fixer": "^2.16",
18+
"phpstan/phpstan": "^0.12.57"
1819
},
1920
"autoload" : {
2021
"psr-4": {

src/ProtocolLevel.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* @copyright Copyright (c) 2021 Robin Appelman <[email protected]>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace Icewind\SMB;
25+
26+
27+
class ProtocolLevel {
28+
/** @var string */
29+
private $level;
30+
31+
private function __construct(string $level) {
32+
$this->level = $level;
33+
}
34+
35+
public function getLevel(): string {
36+
return $this->level;
37+
}
38+
39+
public static function NT1(): self {
40+
return new ProtocolLevel("NT1");
41+
}
42+
43+
public static function SMB2(): self {
44+
return new ProtocolLevel("SMB2");
45+
}
46+
47+
public static function SMB3(): self {
48+
return new ProtocolLevel("SMB3");
49+
}
50+
}

src/Wrapped/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function read(callable $callback = null) {
8282
break;
8383
}
8484
} else {
85-
$output[] .= $line;
85+
$output[] = $line;
8686
}
8787
$line = $this->readLine();
8888
}

src/Wrapped/Share.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public function write($target) {
348348

349349
// use a close callback to ensure the upload is finished before continuing
350350
// this also serves as a way to keep the connection in scope
351-
return CallbackWrapper::wrap($fh, null, null, function () use ($connection, $target) {
351+
return CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
352352
$connection->close(false); // dont terminate, give the upload some time
353353
});
354354
}

0 commit comments

Comments
 (0)