Permalink
Browse files

PHPUnit updates

  • Loading branch information...
troydavisson committed Aug 19, 2016
1 parent 1d6f85b commit e7e8b0f1d2cf8ad1b6c3ca50d98c1e63c05b7fc0
@@ -24,7 +24,7 @@
"league/csv": ">=6.0"
},
"require-dev": {
"phpunit/phpunit": "4.1.*",
"phpunit/phpunit": "5.*",
"psr/log": "1.*",
"monolog/monolog": "1.10.*",
"gsaulmon/guzzlerecorder": "2.*"
@@ -14,10 +14,12 @@ public function it_tracks()
$this->assertNull($cpb->get('test'));
}
/** @test **/
/**
* @test
* @expectedException InvalidArgumentException
* **/
public function it_barfs_when_not_given_enough_information_to_build_absolute_urls()
{
$this->setExpectedException('InvalidArgumentException');
$cpb = new Capabilities;
$cpb->add('Login', '/rets/Login');
}
@@ -31,11 +31,13 @@ public function it_loads_config_from_array()
$this->assertSame('pass', $config->getPassword());
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\InvalidConfiguration
**/
public function it_complains_about_bad_config()
{
$this->setExpectedException('PHRETS\\Exceptions\\InvalidConfiguration', "Login URL and Username must be provided");
$config = Configuration::load();
Configuration::load();
}
/** @test **/
@@ -120,14 +122,13 @@ public function it_keeps_digest_as_the_default()
$this->assertSame(Configuration::AUTH_DIGEST, $c->getHttpAuthenticationMethod());
}
/** @test **/
/**
* @test
* @expectedException InvalidArgumentException
**/
public function it_doesnt_allow_bogus_auth_methods()
{
$c = new Configuration;
$this->setExpectedException(
'\\InvalidArgumentException',
"Given authentication method is invalid. Must be 'basic' or 'digest'"
);
$c->setHttpAuthenticationMethod('bogus');
}
@@ -85,10 +85,12 @@ public function it_gets_keyed_resource_data()
$this->assertInstanceOf('\PHRETS\Models\Metadata\Resource', $resources['Property']);
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\MetadataNotFound
* **/
public function it_errors_with_bad_resource_name()
{
$this->setExpectedException('PHRETS\\Exceptions\\MetadataNotFound');
$this->session->GetResourcesMetadata('Bogus');
}
@@ -119,15 +119,16 @@ public function it_doesnt_die_when_no_count_is_given()
$this->assertCount(40, $results);
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\AutomaticPaginationError
* **/
public function it_detects_broken_pagination()
{
$this->session->Login();
$this->setExpectedException('\PHRETS\Exceptions\AutomaticPaginationError');
// this is manually faked in the fixture
$results = $this->session->Search(
$this->session->Search(
'Property',
'BROKENPAGINATION',
'(LIST_22=90000000+)',
@@ -14,15 +14,17 @@ public function it_logs_in()
/** @test **/
public function it_made_the_request()
{
$connect = $this->session->Login();
$this->session->Login();
$this->assertSame('http://retsgw.flexmls.com:80/rets2_1/Login', $this->session->getLastRequestURL());
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\RETSException
* **/
public function it_throws_an_exception_when_making_a_bad_request()
{
$this->session->Login();
$this->setExpectedException('\PHRETS\Exceptions\RETSException', null, 20203);
$this->session->Search('Property', 'Z', '*'); // no such class by that name
}
@@ -126,7 +128,10 @@ public function it_detects_when_to_use_user_agent_authentication()
$this->assertArrayHasKey('Accept', $last_request['request']->getHeaders());
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\CapabilityUnavailable
**/
public function it_doesnt_allow_requests_to_unsupported_capabilities()
{
$config = new \PHRETS\Configuration;
@@ -140,8 +145,6 @@ public function it_doesnt_allow_requests_to_unsupported_capabilities()
$session = new \PHRETS\Session($config);
$session->Login();
$this->setExpectedException('\PHRETS\Exceptions\CapabilityUnavailable');
// make a request for metadata to a server that doesn't support metadata
$session->GetSystemMetadata();
}
@@ -13,10 +13,12 @@ public function it_holds()
$this->assertSame('Test Description', $metadata->getDescription());
}
/** @test **/
/**
* @test
* @expectedException BadMethodCallException
**/
public function it_doesnt_like_bad_methods()
{
$this->setExpectedException('\\BadMethodCallException');
$metadata = new Resource;
$metadata->totallyBogus();
}
@@ -1,7 +1,6 @@
<?php
use PHRETS\Configuration;
use PHRETS\Http\Client;
use PHRETS\Session;
class SessionTest extends PHPUnit_Framework_TestCase {
@@ -16,13 +15,12 @@ public function it_builds()
$this->assertSame($c, $s->getConfiguration());
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\MissingConfiguration
*/
public function it_detects_invalid_configurations()
{
$this->setExpectedException(
'PHRETS\\Exceptions\\MissingConfiguration',
"Cannot issue Login without a valid configuration loaded"
);
$c = new Configuration;
$c->setLoginUrl('http://www.reso.org/login');
@@ -69,7 +67,7 @@ public function it_disables_redirects_when_desired()
/** @test **/
public function it_uses_the_set_logger()
{
$logger = $this->getMock('Logger', ['debug']);
$logger = $this->createMock(\Monolog\Logger::class);
// expect that the string 'Context' will be changed into an array
$logger->expects($this->atLeastOnce())->method('debug')->withConsecutive(
@@ -89,7 +87,7 @@ public function it_uses_the_set_logger()
/** @test **/
public function it_fixes_the_logger_context_automatically()
{
$logger = $this->getMock('Logger', ['debug']);
$logger = $this->createMock(\Monolog\Logger::class);
// just expect that a debug message is spit out
$logger->expects($this->atLeastOnce())->method('debug')->with($this->matchesRegularExpression('/logger/'));
@@ -85,10 +85,12 @@ public function it_compares()
$this->assertTrue($v->isAtLeast('1.7.2'));
}
/** @test **/
/**
* @test
* @expectedException \PHRETS\Exceptions\InvalidRETSVersion
* **/
public function it_fails_bad_versions()
{
$this->setExpectedException('PHRETS\\Exceptions\\InvalidRETSVersion', "RETS version '2.0' given is not understood");
$v = new RETSVersion;
$v->setVersion('2.0');
}

0 comments on commit e7e8b0f

Please sign in to comment.