diff options
author | Arron Woods <me@arronwoods.com> | 2013-12-05 22:40:45 +0000 |
---|---|---|
committer | Arron Woods <me@arronwoods.com> | 2013-12-05 22:40:45 +0000 |
commit | ad0e2ffc901c27477bba23bf762215b7e2350d21 (patch) | |
tree | fde2e3020c30110a967142cd879c216538cb33bd /tests/library/SSRSTest/Soap | |
parent | e0fd2e51a5546d0d85cf249a6ebf45f9e06e6017 (diff) | |
download | php-ssrs-ad0e2ffc901c27477bba23bf762215b7e2350d21.zip php-ssrs-ad0e2ffc901c27477bba23bf762215b7e2350d21.tar.gz php-ssrs-ad0e2ffc901c27477bba23bf762215b7e2350d21.tar.bz2 |
Tests almost back to passing
Diffstat (limited to 'tests/library/SSRSTest/Soap')
-rwxr-xr-x | tests/library/SSRSTest/Soap/NTLMTest.php | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/library/SSRSTest/Soap/NTLMTest.php b/tests/library/SSRSTest/Soap/NTLMTest.php new file mode 100755 index 0000000..db0970b --- /dev/null +++ b/tests/library/SSRSTest/Soap/NTLMTest.php @@ -0,0 +1,109 @@ +<?php + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * Description of SSRS_Soap_NTLMTest + * + * @author Andrew Lowe + */ + +namespace SSRSTest\Soap; + +use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamWrapper; +use org\bovigo\vfs\vfsStreamDirectory; + +class NTLMTest extends \PHPUnit_Framework_TestCase { + + public function testFetchWSDLCallsCurlWithUri() { + $arguments = array( + 'http://localhost/soap/ms.wsdl.xml', + array( + 'username' => 'test', + 'password' => 'test1' + ) + ); + + $SOAP = $this->getMock('SSRS\Soap\NTLM', array('callCurl'), $arguments); + + $SOAP->expects($this->once()) + ->method('callCurl') + ->with($this->equalTo('http://localhost/soap/ms.wsdl.xml')); + + $SOAP->fetchWSDL(); + } + + public function testSetUsernameReturnsInstance() { + $SOAP = new \SSRS\Soap\NTLM('http://'); + $result = $SOAP->setUsername('test'); + + $this->assertEquals($SOAP, $result); + $this->assertInstanceOf('SSRS\Soap\NTLM', $result); + } + + public function testSetPasswordReturnsInstance() { + $SOAP = new \SSRS\Soap\NTLM('http://'); + $result = $SOAP->setPassword('test1'); + + $this->assertEquals($SOAP, $result); + $this->assertInstanceOf('SSRS\Soap\NTLM', $result); + } + + /** + * @expectedException \SSRS\Soap\Exception + */ + public function testSetCacheThrowsExceptionWithInvalidPath() { + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); + + $SOAP = new \SSRS\Soap\NTLM('http://'); + $SOAP->setCachePath(vfsStream::url('tmp/missing/file.wsdl')); + } + + public function testSetCacheIsSetWithWriteableDirectory() { + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); + + $SOAP = new \SSRS\Soap\NTLM('http://'); + $SOAP->setCachePath(vfsStream::url('tmp/file.wsdl')); + + $this->assertEquals('vfs://tmp/file.wsdl', $SOAP->getCachePath()); + } + + /** + * @depends testSetCacheIsSetWithWriteableDirectory + */ + public function testCacheWSDLIsOutputtedValid() { + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); + $content = 'Hesaklk;k;dfs'; + + $SOAP = $this->getMock('SSRS\Soap\NTLM', array('setCacheWSDLPermission'), array('http://')); + + $SOAP->expects($this->once()) + ->method('setCacheWSDLPermission'); + + $SOAP->setCachePath(vfsStream::url('tmp/file.wsdl')); + $SOAP->cacheWSDL($content); + $output = $SOAP->getCacheWSDL(); + $this->assertEquals($output, $content); + } + + public function testCacheWSDLIsWorldWritable() { + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('tmp')); + $SOAP = $this->getMock('SSRS\Soap\NTLM', array('setCacheWSDLPermission'), array('http://')); + + $SOAP->expects($this->once()) + ->method('setCacheWSDLPermission') + ->with($this->equalTo(0666)); + + $SOAP->setCachePath(vfsStream::url('tmp/file.wsdl')) + ->cacheWSDL('$fileContents'); + } + +} |