Merge pull request #30 from icewind1991/travis-matrix

split running of smbclient and libsmbclient backend tests
This commit is contained in:
Robin Appelman 2015-04-25 18:42:18 +02:00
commit 21222508c0
8 changed files with 39 additions and 9 deletions

View file

@ -6,6 +6,9 @@ php:
- 5.6 - 5.6
- 7.0 - 7.0
env:
matrix: matrix:
allow_failures: allow_failures:
- php: 7.0 - php: 7.0
@ -13,17 +16,16 @@ matrix:
env: env:
global: global:
- CURRENT_DIR=`pwd` - CURRENT_DIR=`pwd`
matrix:
- BACKEND=smbclient
- BACKEND=libsmbclient
before_install: before_install:
- pass=$(perl -e 'print crypt("test", "password")') - pass=$(perl -e 'print crypt("test", "password")')
- sudo useradd -m -p $pass test - sudo useradd -m -p $pass test
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install samba smbclient libsmbclient-dev libsmbclient - sudo apt-get install samba smbclient
- wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip - if [ "$BACKEND" == 'libsmbclient' ]; then ./install_libsmbclient.sh; fi
- unzip /tmp/libsmbclient-php.zip -d /tmp
- cd /tmp/libsmbclient-php-master
- phpize && ./configure && make && sudo make install
- echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- cd $CURRENT_DIR - cd $CURRENT_DIR
- chmod go+w $HOME - chmod go+w $HOME
- printf "%s\n%s\n" test test|sudo smbpasswd -s test - printf "%s\n%s\n" test test|sudo smbpasswd -s test

8
install_libsmbclient.sh Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
sudo apt-get install libsmbclient-dev libsmbclient
wget -O /tmp/libsmbclient-php.zip https://github.com/eduardok/libsmbclient-php/archive/master.zip
unzip /tmp/libsmbclient-php.zip -d /tmp
cd /tmp/libsmbclient-php-master
phpize && ./configure && make && sudo make install
echo 'extension="libsmbclient.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

View file

@ -9,7 +9,7 @@ namespace Icewind\SMB\Test;
use Icewind\SMB\FileInfo; use Icewind\SMB\FileInfo;
abstract class AbstractShare extends \PHPUnit_Framework_TestCase { abstract class AbstractShare extends TestCase {
/** /**
* @var \Icewind\SMB\Server $server * @var \Icewind\SMB\Server $server
*/ */

View file

@ -11,6 +11,7 @@ use Icewind\SMB\NativeServer;
class NativeShare extends AbstractShare { class NativeShare extends AbstractShare {
public function setUp() { public function setUp() {
$this->requireBackendEnv('libsmbclient');
if (!function_exists('smbclient_state_new')) { if (!function_exists('smbclient_state_new')) {
$this->markTestSkipped('libsmbclient php extension not installed'); $this->markTestSkipped('libsmbclient php extension not installed');
} }

View file

@ -9,7 +9,7 @@ namespace Icewind\SMB\Test;
use Icewind\SMB\NativeServer; use Icewind\SMB\NativeServer;
class NativeStream extends \PHPUnit_Framework_TestCase { class NativeStream extends TestCase {
/** /**
* @var \Icewind\SMB\Server $server * @var \Icewind\SMB\Server $server
*/ */
@ -28,6 +28,7 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
protected $config; protected $config;
public function setUp() { public function setUp() {
$this->requireBackendEnv('libsmbclient');
if (!function_exists('smbclient_state_new')) { if (!function_exists('smbclient_state_new')) {
$this->markTestSkipped('libsmbclient php extension not installed'); $this->markTestSkipped('libsmbclient php extension not installed');
} }

View file

@ -7,7 +7,7 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
class Server extends \PHPUnit_Framework_TestCase { class Server extends TestCase {
/** /**
* @var \Icewind\SMB\Server $server * @var \Icewind\SMB\Server $server
*/ */
@ -16,6 +16,7 @@ class Server extends \PHPUnit_Framework_TestCase {
private $config; private $config;
public function setUp() { public function setUp() {
$this->requireBackendEnv('smbclient');
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); $this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$this->server = new \Icewind\SMB\Server($this->config->host, $this->config->user, $this->config->password); $this->server = new \Icewind\SMB\Server($this->config->host, $this->config->user, $this->config->password);
} }

View file

@ -11,6 +11,7 @@ use Icewind\SMB\Server as NormalServer;
class Share extends AbstractShare { class Share extends AbstractShare {
public function setUp() { public function setUp() {
$this->requireBackendEnv('smbclient');
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); $this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$this->server = new NormalServer($this->config->host, $this->config->user, $this->config->password); $this->server = new NormalServer($this->config->host, $this->config->user, $this->config->password);
$this->share = $this->server->getShare($this->config->share); $this->share = $this->server->getShare($this->config->share);

16
tests/TestCase.php Normal file
View file

@ -0,0 +1,16 @@
<?php
/**
* Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Test;
abstract class TestCase extends \PHPUnit_Framework_TestCase {
protected function requireBackendEnv($backend) {
if (getenv('BACKEND') and getenv('BACKEND') !== $backend) {
$this->markTestSkipped('Skipping tests for ' . $backend . ' backend');
}
}
}