diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/src/BeSimple/SoapCommon/Cache.php b/src/BeSimple/SoapCommon/Cache.php index c4213a8..7deecc7 100644 --- a/src/BeSimple/SoapCommon/Cache.php +++ b/src/BeSimple/SoapCommon/Cache.php @@ -72,6 +72,10 @@ class Cache static public function setDirectory($directory) { + if (!is_dir($directory)) { + mkdir($directory, 0777, true); + } + self::iniSet('soap.wsdl_cache_dir', $directory); } diff --git a/tests/BeSimple/Tests/SoapCommon/CacheTest.php b/tests/BeSimple/Tests/SoapCommon/CacheTest.php index aebe217..f56f192 100644 --- a/tests/BeSimple/Tests/SoapCommon/CacheTest.php +++ b/tests/BeSimple/Tests/SoapCommon/CacheTest.php @@ -36,11 +36,19 @@ class SoapRequestTest extends \PHPUnit_Framework_TestCase public function testSetDirectory() { - Cache::setDirectory('/foo'); - $this->assertEquals('/foo', Cache::getDirectory()); + \vfsStream::setup('Fixtures'); - Cache::setDirectory('/bar'); - $this->assertEquals('/bar', Cache::getDirectory()); + $this->assertFalse(\vfsStreamWrapper::getRoot()->hasChild('foo')); + $dir = \vfsStream::url('Fixtures/foo'); + Cache::setDirectory($dir); + $this->assertEquals($dir, Cache::getDirectory()); + $this->assertTrue(\vfsStreamWrapper::getRoot()->hasChild('foo')); + + $this->assertFalse(\vfsStreamWrapper::getRoot()->hasChild('bar')); + $dir = \vfsStream::url('Fixtures/bar'); + Cache::setDirectory($dir); + $this->assertEquals($dir, Cache::getDirectory()); + $this->assertTrue(\vfsStreamWrapper::getRoot()->hasChild('bar')); } public function testSetLifetime() diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 96aebb6..f92b0dd 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,11 +11,18 @@ spl_autoload_register(function($class) { return true; } - } else if (0 === strpos($class, 'BeSimple\SoapCommon\\')) { + } elseif (0 === strpos($class, 'BeSimple\SoapCommon\\')) { $path = __DIR__.'/../src/'.($class = strtr($class, '\\', '/')).'.php'; if (file_exists($path) && is_readable($path)) { require_once $path; + return true; + } + } elseif (0 === strpos($class, 'vfsStream')) { + $path = __DIR__.'/../vendor/vfsStream/src/main/php/org/bovigo/vfs/'.$class.'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + return true; } } diff --git a/vendors.php b/vendors.php new file mode 100755 index 0000000..7f127b0 --- /dev/null +++ b/vendors.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/* + +CAUTION: This file installs the dependencies needed to run the BeSimpleSoapCommon test suite. + +https://github.com/BeSimple/BeSimpleSoapCommon + +*/ + +if (!is_dir($vendorDir = dirname(__FILE__).'/vendor')) { + mkdir($vendorDir, 0777, true); +} + +$deps = array( + array('vfsStream', 'https://github.com/mikey179/vfsStream.git', 'RELEASE-0.10.1'), +); + +foreach ($deps as $dep) { + list($name, $url, $rev) = $dep; + + echo "> Installing/Updating $name\n"; + + $installDir = $vendorDir.'/'.$name; + if (!is_dir($installDir)) { + system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir))); + } + + system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev))); +}