Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit 2122250

Browse files
committed
Merge pull request #30 from icewind1991/travis-matrix
split running of smbclient and libsmbclient backend tests
2 parents 53fe7f2 + 25c0dff commit 2122250

File tree

8 files changed

+39
-9
lines changed

8 files changed

+39
-9
lines changed

.travis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ php:
66
- 5.6
77
- 7.0
88

9+
env:
10+
11+
912
matrix:
1013
allow_failures:
1114
- php: 7.0
1215

1316
env:
1417
global:
1518
- CURRENT_DIR=`pwd`
19+
matrix:
20+
- BACKEND=smbclient
21+
- BACKEND=libsmbclient
1622

1723
before_install:
1824
- pass=$(perl -e 'print crypt("test", "password")')
1925
- sudo useradd -m -p $pass test
2026
- sudo apt-get update -qq
21-
- sudo apt-get install samba smbclient libsmbclient-dev libsmbclient
22-
- wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip
23-
- unzip /tmp/libsmbclient-php.zip -d /tmp
24-
- cd /tmp/libsmbclient-php-master
25-
- phpize && ./configure && make && sudo make install
26-
- echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
27+
- sudo apt-get install samba smbclient
28+
- if [ "$BACKEND" == 'libsmbclient' ]; then ./install_libsmbclient.sh; fi
2729
- cd $CURRENT_DIR
2830
- chmod go+w $HOME
2931
- printf "%s\n%s\n" test test|sudo smbpasswd -s test

install_libsmbclient.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get install libsmbclient-dev libsmbclient
4+
wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip
5+
unzip /tmp/libsmbclient-php.zip -d /tmp
6+
cd /tmp/libsmbclient-php-master
7+
phpize && ./configure && make && sudo make install
8+
echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

tests/AbstractShare.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Icewind\SMB\FileInfo;
1111

12-
abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
12+
abstract class AbstractShare extends TestCase {
1313
/**
1414
* @var \Icewind\SMB\Server $server
1515
*/

tests/NativeShare.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class NativeShare extends AbstractShare {
1313
public function setUp() {
14+
$this->requireBackendEnv('libsmbclient');
1415
if (!function_exists('smbclient_state_new')) {
1516
$this->markTestSkipped('libsmbclient php extension not installed');
1617
}

tests/NativeStream.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Icewind\SMB\NativeServer;
1111

12-
class NativeStream extends \PHPUnit_Framework_TestCase {
12+
class NativeStream extends TestCase {
1313
/**
1414
* @var \Icewind\SMB\Server $server
1515
*/
@@ -28,6 +28,7 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
2828
protected $config;
2929

3030
public function setUp() {
31+
$this->requireBackendEnv('libsmbclient');
3132
if (!function_exists('smbclient_state_new')) {
3233
$this->markTestSkipped('libsmbclient php extension not installed');
3334
}

tests/Server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Icewind\SMB\Test;
99

10-
class Server extends \PHPUnit_Framework_TestCase {
10+
class Server extends TestCase {
1111
/**
1212
* @var \Icewind\SMB\Server $server
1313
*/
@@ -16,6 +16,7 @@ class Server extends \PHPUnit_Framework_TestCase {
1616
private $config;
1717

1818
public function setUp() {
19+
$this->requireBackendEnv('smbclient');
1920
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
2021
$this->server = new \Icewind\SMB\Server($this->config->host, $this->config->user, $this->config->password);
2122
}

tests/Share.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class Share extends AbstractShare {
1313
public function setUp() {
14+
$this->requireBackendEnv('smbclient');
1415
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
1516
$this->server = new NormalServer($this->config->host, $this->config->user, $this->config->password);
1617
$this->share = $this->server->getShare($this->config->share);

tests/TestCase.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2015 Robin Appelman <[email protected]>
4+
* This file is licensed under the Licensed under the MIT license:
5+
* http://opensource.org/licenses/MIT
6+
*/
7+
8+
namespace Icewind\SMB\Test;
9+
10+
abstract class TestCase extends \PHPUnit_Framework_TestCase {
11+
protected function requireBackendEnv($backend) {
12+
if (getenv('BACKEND') and getenv('BACKEND') !== $backend) {
13+
$this->markTestSkipped('Skipping tests for ' . $backend . ' backend');
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)