mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
test: Replace deprecated @expectedException* to $this->expectException*()
This commit is contained in:
parent
fe34a8551c
commit
b1417587ad
59 changed files with 210 additions and 209 deletions
|
@ -71,10 +71,10 @@ class CacheTest extends CakeTestCase {
|
|||
/**
|
||||
* testConfigInvalidEngine method
|
||||
*
|
||||
* @expectedException CacheException
|
||||
* @return void
|
||||
*/
|
||||
public function testConfigInvalidEngine() {
|
||||
$this->expectException(CacheException::class);
|
||||
$settings = array('engine' => 'Imaginary');
|
||||
Cache::config('imaginary', $settings);
|
||||
}
|
||||
|
@ -164,10 +164,10 @@ class CacheTest extends CakeTestCase {
|
|||
/**
|
||||
* test that trying to configure classes that don't extend CacheEngine fail.
|
||||
*
|
||||
* @expectedException CacheException
|
||||
* @return void
|
||||
*/
|
||||
public function testAttemptingToConfigureANonCacheEngineClass() {
|
||||
$this->expectException(CacheException::class);
|
||||
$this->getMock('StdClass', array(), array(), 'RubbishEngine');
|
||||
Cache::config('Garbage', array(
|
||||
'engine' => 'Rubbish'
|
||||
|
@ -308,10 +308,10 @@ class CacheTest extends CakeTestCase {
|
|||
/**
|
||||
* testGroupConfigsThrowsException method
|
||||
*
|
||||
* @expectedException CacheException
|
||||
* @return void
|
||||
*/
|
||||
public function testGroupConfigsThrowsException() {
|
||||
$this->expectException(CacheException::class);
|
||||
Cache::groupConfigs('bogus');
|
||||
}
|
||||
|
||||
|
|
|
@ -166,10 +166,10 @@ class IniReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test an exception is thrown by reading files that exist without .ini extension.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithExistentFileWithoutExtension() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new IniReader($this->path);
|
||||
$reader->read('no_ini_extension');
|
||||
}
|
||||
|
@ -177,10 +177,10 @@ class IniReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test an exception is thrown by reading files that don't exist.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithNonExistentFile() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new IniReader($this->path);
|
||||
$reader->read('fake_values');
|
||||
}
|
||||
|
@ -199,10 +199,10 @@ class IniReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test reading keys with ../ doesn't work.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithDots() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new IniReader($this->path);
|
||||
$reader->read('../empty');
|
||||
}
|
||||
|
|
|
@ -73,10 +73,10 @@ class PhpReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test an exception is thrown by reading files that exist without .php extension.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithExistentFileWithoutExtension() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new PhpReader($this->path);
|
||||
$reader->read('no_php_extension');
|
||||
}
|
||||
|
@ -84,10 +84,10 @@ class PhpReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test an exception is thrown by reading files that don't exist.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithNonExistentFile() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new PhpReader($this->path);
|
||||
$reader->read('fake_values');
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ class PhpReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test reading an empty file.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadEmptyFile() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new PhpReader($this->path);
|
||||
$reader->read('empty');
|
||||
}
|
||||
|
@ -106,10 +106,10 @@ class PhpReaderTest extends CakeTestCase {
|
|||
/**
|
||||
* Test reading keys with ../ doesn't work.
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testReadWithDots() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$reader = new PhpReader($this->path);
|
||||
$reader->read('../empty');
|
||||
}
|
||||
|
|
|
@ -159,10 +159,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
* Test that adding an option using a two letter short value causes an exception.
|
||||
* As they will not parse correctly.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testAddOptionShortOneLetter() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addOption('test', array('short' => 'te'));
|
||||
}
|
||||
|
@ -257,10 +257,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test parsing options that do not exist.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionThatDoesNotExist() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addOption('no-commit', array('boolean' => true));
|
||||
|
||||
|
@ -270,10 +270,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test parsing short options that do not exist.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testShortOptionThatDoesNotExist() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addOption('no-commit', array('boolean' => true));
|
||||
|
||||
|
@ -283,10 +283,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test that options with choices enforce them.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionWithChoices() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addOption('name', array('choices' => array('mark', 'jose')));
|
||||
|
||||
|
@ -372,10 +372,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test parsing arguments.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testParseArgumentTooMany() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addArgument('name', array('help' => 'An argument'))
|
||||
->addArgument('other');
|
||||
|
@ -403,10 +403,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test that when there are not enough arguments an exception is raised
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testPositionalArgNotEnough() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addArgument('name', array('required' => true))
|
||||
->addArgument('other', array('required' => true));
|
||||
|
@ -417,10 +417,10 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
/**
|
||||
* test that arguments with choices enforce them.
|
||||
*
|
||||
* @expectedException ConsoleException
|
||||
* @return void
|
||||
*/
|
||||
public function testPositionalArgWithChoices() {
|
||||
$this->expectException(ConsoleException::class);
|
||||
$parser = new ConsoleOptionParser('test', false);
|
||||
$parser->addArgument('name', array('choices' => array('mark', 'jose')))
|
||||
->addArgument('alias', array('choices' => array('cowboy', 'samurai')))
|
||||
|
|
|
@ -37,10 +37,10 @@ class ProgressShellHelperTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that a callback is required.*
|
||||
*
|
||||
* @expectedException \RuntimeException
|
||||
* @return void
|
||||
*/
|
||||
public function testOutputFailure() {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->helper->output(array('not a callback'));
|
||||
}
|
||||
|
||||
|
|
|
@ -1014,10 +1014,10 @@ TEXT;
|
|||
/**
|
||||
* Test getting an invalid helper
|
||||
*
|
||||
* @expectedException RunTimeException
|
||||
* @return void
|
||||
*/
|
||||
public function testGetInvalidHelper() {
|
||||
$this->expectException(RunTimeException::class);
|
||||
$this->Shell->helper("tomato");
|
||||
}
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ class TaskCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test missingtask exception
|
||||
*
|
||||
* @expectedException MissingTaskException
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadMissingTask() {
|
||||
$this->expectException(MissingTaskException::class);
|
||||
$this->Tasks->load('ThisTaskShouldAlwaysBeMissing');
|
||||
}
|
||||
|
||||
|
|
|
@ -291,10 +291,10 @@ class DbAclTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that allow() with an invalid permission name triggers an error.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testAllowInvalidPermission() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->assertFalse($this->Acl->allow('Micheal', 'tpsReports', 'derp'));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ class AclComponentTest extends CakeTestCase {
|
|||
* test that constructor throws an exception when Acl.classname is a
|
||||
* non-existent class
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testConstrutorException() {
|
||||
$this->expectException(CakeException::class);
|
||||
Configure::write('Acl.classname', 'AclClassNameThatDoesNotExist');
|
||||
$Collection = new ComponentCollection();
|
||||
new AclComponent($Collection);
|
||||
|
@ -80,10 +80,10 @@ class AclComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* test that adapter() whines when the class does not implement AclInterface
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testAdapterException() {
|
||||
$this->expectException(CakeException::class);
|
||||
$thing = new StdClass();
|
||||
$this->Acl->adapter($thing);
|
||||
}
|
||||
|
|
|
@ -298,11 +298,11 @@ class BasicAuthenticateTest extends CakeTestCase {
|
|||
/**
|
||||
* test scope failure.
|
||||
*
|
||||
* @expectedException UnauthorizedException
|
||||
* @expectedExceptionCode 401
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthenticateFailReChallenge() {
|
||||
$this->expectException(UnauthorizedException::class);
|
||||
$this->expectExceptionCode(401);
|
||||
$this->auth->settings['scope'] = array('user' => 'nate');
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
$request->addParams(array('pass' => array(), 'named' => array()));
|
||||
|
|
|
@ -63,10 +63,10 @@ class ControllerAuthorizeTest extends CakeTestCase {
|
|||
/**
|
||||
* testControllerErrorOnMissingMethod
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testControllerErrorOnMissingMethod() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->auth->controller(new Controller());
|
||||
}
|
||||
|
||||
|
|
|
@ -106,11 +106,11 @@ class DigestAuthenticateTest extends CakeTestCase {
|
|||
/**
|
||||
* test the authenticate method
|
||||
*
|
||||
* @expectedException UnauthorizedException
|
||||
* @expectedExceptionCode 401
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthenticateWrongUsername() {
|
||||
$this->expectException(UnauthorizedException::class);
|
||||
$this->expectExceptionCode(401);
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
$request->addParams(array('pass' => array(), 'named' => array()));
|
||||
|
||||
|
@ -183,11 +183,11 @@ DIGEST;
|
|||
/**
|
||||
* test scope failure.
|
||||
*
|
||||
* @expectedException UnauthorizedException
|
||||
* @expectedExceptionCode 401
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthenticateFailReChallenge() {
|
||||
$this->expectException(UnauthorizedException::class);
|
||||
$this->expectExceptionCode(401);
|
||||
$this->auth->settings['scope'] = array('user' => 'nate');
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
$request->addParams(array('pass' => array(), 'named' => array()));
|
||||
|
|
|
@ -566,10 +566,10 @@ class AuthComponentTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testIsAuthorizedMissingFile() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->Controller->Auth->authorize = 'Missing';
|
||||
$this->Controller->Auth->isAuthorized(array('User' => array('id' => 1)));
|
||||
}
|
||||
|
@ -644,10 +644,10 @@ class AuthComponentTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadAuthenticateNoFile() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->Controller->Auth->authenticate = 'Missing';
|
||||
$this->Controller->Auth->identify($this->Controller->request, $this->Controller->response);
|
||||
}
|
||||
|
@ -1153,10 +1153,11 @@ class AuthComponentTest extends CakeTestCase {
|
|||
|
||||
/**
|
||||
* Throw ForbiddenException if AuthComponent::$unauthorizedRedirect set to false
|
||||
* @expectedException ForbiddenException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testForbiddenException() {
|
||||
$this->expectException(ForbiddenException::class);
|
||||
$url = '/party/on';
|
||||
$this->Auth->request = $CakeRequest = new CakeRequest($url);
|
||||
$this->Auth->request->addParams(Router::parse($url));
|
||||
|
@ -1737,11 +1738,11 @@ class AuthComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* testStatelessAuthNoRedirect method
|
||||
*
|
||||
* @expectedException UnauthorizedException
|
||||
* @expectedExceptionCode 401
|
||||
* @return void
|
||||
*/
|
||||
public function testStatelessAuthNoRedirect() {
|
||||
$this->expectException(UnauthorizedException::class);
|
||||
$this->expectExceptionCode(401);
|
||||
if (CakeSession::id()) {
|
||||
session_destroy();
|
||||
CakeSession::$id = null;
|
||||
|
|
|
@ -819,10 +819,10 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests for missing models
|
||||
*
|
||||
* @expectedException MissingModelException
|
||||
* @return void
|
||||
*/
|
||||
public function testPaginateMissingModel() {
|
||||
$this->expectException(MissingModelException::class);
|
||||
$Controller = new PaginatorTestController($this->request);
|
||||
$Controller->constructClasses();
|
||||
$Controller->Paginator->paginate('MissingModel');
|
||||
|
@ -1115,10 +1115,10 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that a really large page number gets clamped to the max page size.
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function testOutOfRangePageNumberGetsClamped() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$Controller = new PaginatorTestController($this->request);
|
||||
$Controller->uses = array('PaginatorControllerPost');
|
||||
$Controller->params['named'] = array(
|
||||
|
@ -1132,10 +1132,10 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that a really REALLY large page number gets clamped to the max page size.
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function testOutOfVeryBigPageNumberGetsClamped() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$Controller = new PaginatorTestController($this->request);
|
||||
$Controller->uses = array('PaginatorControllerPost');
|
||||
$Controller->params['named'] = array(
|
||||
|
|
|
@ -935,10 +935,10 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testAddInputTypeException() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->RequestHandler->addInputType('csv', array('I am not callable'));
|
||||
}
|
||||
|
||||
|
|
|
@ -208,10 +208,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Test that requests are still blackholed when controller has incorrect
|
||||
* visibility keyword in the blackhole callback
|
||||
*
|
||||
* @expectedException BadRequestException
|
||||
* @return void
|
||||
*/
|
||||
public function testBlackholeWithBrokenCallback() {
|
||||
$this->expectException(BadRequestException::class);
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
$request->addParams(array(
|
||||
'controller' => 'posts', 'action' => 'index')
|
||||
|
@ -1496,10 +1496,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* test that blackhole throws an exception when the key is missing and balckHoleCallback is not set.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException SecurityException
|
||||
* @expectedExceptionMessage Missing CSRF token
|
||||
*/
|
||||
public function testCsrfExceptionOnMissingKey() {
|
||||
$this->expectException(SecurityException::class);
|
||||
$this->expectExceptionMessage("Missing CSRF token");
|
||||
$this->Security->validatePost = false;
|
||||
$this->Security->csrfCheck = true;
|
||||
$this->Security->blackHoleCallback = '';
|
||||
|
@ -1542,10 +1542,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* test that blackhole throws an exception when the keys are mismatched and balckHoleCallback is not set.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException SecurityException
|
||||
* @expectedExceptionMessage CSRF token mismatch
|
||||
*/
|
||||
public function testCsrfExceptionOnKeyMismatch() {
|
||||
$this->expectException(SecurityException::class);
|
||||
$this->expectExceptionMessage("CSRF token mismatch");
|
||||
$this->Security->validatePost = false;
|
||||
$this->Security->csrfCheck = true;
|
||||
$this->Security->csrfExpires = '+10 minutes';
|
||||
|
@ -1594,10 +1594,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* test that blackhole throws an exception when the key is expired and balckHoleCallback is not set
|
||||
*
|
||||
* @return void
|
||||
* @expectedException SecurityException
|
||||
* @expectedExceptionMessage CSRF token expired
|
||||
*/
|
||||
public function testCsrfExceptionOnExpiredKey() {
|
||||
$this->expectException(SecurityException::class);
|
||||
$this->expectExceptionMessage("CSRF token expired");
|
||||
$this->Security->validatePost = false;
|
||||
$this->Security->csrfCheck = true;
|
||||
$this->Security->csrfExpires = '+10 minutes';
|
||||
|
@ -1761,11 +1761,11 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* test blackhole will now throw passed exception if debug enabled
|
||||
*
|
||||
* @expectedException SecurityException
|
||||
* @expectedExceptionMessage error description
|
||||
* @return void
|
||||
*/
|
||||
public function testBlackholeThrowsException() {
|
||||
$this->expectException(SecurityException::class);
|
||||
$this->expectExceptionMessage("error description");
|
||||
$this->Security->blackHoleCallback = '';
|
||||
$this->Security->blackHole($this->Controller, 'auth', new SecurityException('error description'));
|
||||
}
|
||||
|
@ -1878,10 +1878,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Auth required throws exception token not found
|
||||
*
|
||||
* @return void
|
||||
* @expectedException AuthSecurityException
|
||||
* @expectedExceptionMessage '_Token' was not found in request data.
|
||||
*/
|
||||
public function testAuthRequiredThrowsExceptionTokenNotFoundPost() {
|
||||
$this->expectException(AuthSecurityException::class);
|
||||
$this->expectExceptionMessage("'_Token' was not found in request data.");
|
||||
$this->Controller->Security->requireAuth = array('protected');
|
||||
$this->Controller->request->params['action'] = 'protected';
|
||||
$this->Controller->request->data = array('some-key' => 'some-value');
|
||||
|
@ -1892,10 +1892,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Auth required throws exception token not found in Session
|
||||
*
|
||||
* @return void
|
||||
* @expectedException AuthSecurityException
|
||||
* @expectedExceptionMessage '_Token' was not found in session.
|
||||
*/
|
||||
public function testAuthRequiredThrowsExceptionTokenNotFoundSession() {
|
||||
$this->expectException(AuthSecurityException::class);
|
||||
$this->expectExceptionMessage("'_Token' was not found in session.");
|
||||
$this->Controller->Security->requireAuth = array('protected');
|
||||
$this->Controller->request->params['action'] = 'protected';
|
||||
$this->Controller->request->data = array('_Token' => 'not empty');
|
||||
|
@ -1906,10 +1906,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Auth required throws exception controller not allowed
|
||||
*
|
||||
* @return void
|
||||
* @expectedException AuthSecurityException
|
||||
* @expectedExceptionMessage Controller 'NotAllowed' was not found in allowed controllers: 'Allowed, AnotherAllowed'.
|
||||
*/
|
||||
public function testAuthRequiredThrowsExceptionControllerNotAllowed() {
|
||||
$this->expectException(AuthSecurityException::class);
|
||||
$this->expectExceptionMessage("Controller 'NotAllowed' was not found in allowed controllers: 'Allowed, AnotherAllowed'.");
|
||||
$this->Controller->Security->requireAuth = array('protected');
|
||||
$this->Controller->request->params['controller'] = 'NotAllowed';
|
||||
$this->Controller->request->params['action'] = 'protected';
|
||||
|
@ -1924,10 +1924,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Auth required throws exception controller not allowed
|
||||
*
|
||||
* @return void
|
||||
* @expectedException AuthSecurityException
|
||||
* @expectedExceptionMessage Action 'NotAllowed::protected' was not found in allowed actions: 'index, view'.
|
||||
*/
|
||||
public function testAuthRequiredThrowsExceptionActionNotAllowed() {
|
||||
$this->expectException(AuthSecurityException::class);
|
||||
$this->expectExceptionMessage("Action 'NotAllowed::protected' was not found in allowed actions: 'index, view'.");
|
||||
$this->Controller->Security->requireAuth = array('protected');
|
||||
$this->Controller->request->params['controller'] = 'NotAllowed';
|
||||
$this->Controller->request->params['action'] = 'protected';
|
||||
|
@ -1959,10 +1959,10 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* Auth required throws exception controller not allowed
|
||||
*
|
||||
* @return void
|
||||
* @expectedException SecurityException
|
||||
* @expectedExceptionMessage The request method must be POST
|
||||
*/
|
||||
public function testMethodsRequiredThrowsExceptionMethodNotAllowed() {
|
||||
$this->expectException(SecurityException::class);
|
||||
$this->expectExceptionMessage("The request method must be POST");
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$this->Controller->Security->requirePost = array('delete');
|
||||
$this->Controller->request->params['controller'] = 'Test';
|
||||
|
|
|
@ -115,10 +115,10 @@ class ComponentCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test missingcomponent exception
|
||||
*
|
||||
* @expectedException MissingComponentException
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadMissingComponent() {
|
||||
$this->expectException(MissingComponentException::class);
|
||||
$this->Components->load('ThisComponentShouldAlwaysBeMissing');
|
||||
}
|
||||
|
||||
|
|
|
@ -1208,11 +1208,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test postConditions raising an exception on unsafe keys.
|
||||
*
|
||||
* @expectedException RuntimeException
|
||||
* @dataProvider dangerousPostConditionsProvider
|
||||
* @return void
|
||||
*/
|
||||
public function testPostConditionsDangerous($data) {
|
||||
$this->expectException(RuntimeException::class);
|
||||
$request = new CakeRequest('controller_posts/index');
|
||||
|
||||
$Controller = new Controller($request);
|
||||
|
@ -1406,11 +1406,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* testMissingAction method
|
||||
*
|
||||
* @expectedException MissingActionException
|
||||
* @expectedExceptionMessage Action TestController::missing() could not be found.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionMissingAction() {
|
||||
$this->expectException(MissingActionException::class);
|
||||
$this->expectExceptionMessage("Action TestController::missing() could not be found.");
|
||||
$url = new CakeRequest('test/missing');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => 'missing'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
@ -1422,11 +1422,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking private methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::private_m() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionPrivate() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::private_m() is not directly accessible.");
|
||||
$url = new CakeRequest('test/private_m/');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => 'private_m'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
@ -1438,11 +1438,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking protected methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::protected_m() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionProtected() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::protected_m() is not directly accessible.");
|
||||
$url = new CakeRequest('test/protected_m/');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => 'protected_m'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
@ -1454,11 +1454,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking hidden methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::_hidden() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionHidden() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::_hidden() is not directly accessible.");
|
||||
$url = new CakeRequest('test/_hidden/');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => '_hidden'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
@ -1470,11 +1470,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking controller methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::redirect() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionBaseMethods() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::redirect() is not directly accessible.");
|
||||
$url = new CakeRequest('test/redirect/');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => 'redirect'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
@ -1486,11 +1486,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking controller methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::admin_add() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionPrefixProtection() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::admin_add() is not directly accessible.");
|
||||
Router::reload();
|
||||
Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin'));
|
||||
|
||||
|
@ -1505,11 +1505,11 @@ class ControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* test invoking controller methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionPrefixProtectionCasing() {
|
||||
$this->expectException(PrivateActionException::class);
|
||||
$this->expectExceptionMessage("Private Action TestController::Admin_add() is not directly accessible.");
|
||||
Router::reload();
|
||||
Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin'));
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ class PagesControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that missing view renders 404 page in production
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @expectedExceptionCode 404
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingView() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$this->expectExceptionCode(404);
|
||||
Configure::write('debug', 0);
|
||||
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
|
||||
$Pages->display('non_existing_page');
|
||||
|
@ -67,11 +67,11 @@ class PagesControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that missing view in debug mode renders missing_view error page
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @expectedExceptionCode 500
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingViewInDebug() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$this->expectExceptionCode(500);
|
||||
Configure::write('debug', 1);
|
||||
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
|
||||
$Pages->display('non_existing_page');
|
||||
|
@ -80,11 +80,11 @@ class PagesControllerTest extends CakeTestCase {
|
|||
/**
|
||||
* Test directory traversal protection
|
||||
*
|
||||
* @expectedException ForbiddenException
|
||||
* @expectedExceptionCode 403
|
||||
* @return void
|
||||
*/
|
||||
public function testDirectoryTraversalProtection() {
|
||||
$this->expectException(ForbiddenException::class);
|
||||
$this->expectExceptionCode(403);
|
||||
App::build(array(
|
||||
'View' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
|
||||
|
|
|
@ -195,9 +195,9 @@ class CakePluginTest extends CakeTestCase {
|
|||
* Tests that CakePlugin::load() throws an exception on unknown plugin
|
||||
*
|
||||
* @return void
|
||||
* @expectedException MissingPluginException
|
||||
*/
|
||||
public function testLoadNotFound() {
|
||||
$this->expectException(MissingPluginException::class);
|
||||
CakePlugin::load('MissingPlugin');
|
||||
}
|
||||
|
||||
|
@ -219,9 +219,9 @@ class CakePluginTest extends CakeTestCase {
|
|||
* Tests that CakePlugin::path() throws an exception on unknown plugin
|
||||
*
|
||||
* @return void
|
||||
* @expectedException MissingPluginException
|
||||
*/
|
||||
public function testPathNotFound() {
|
||||
$this->expectException(MissingPluginException::class);
|
||||
CakePlugin::path('TestPlugin');
|
||||
}
|
||||
|
||||
|
|
|
@ -293,10 +293,10 @@ class ConfigureTest extends CakeTestCase {
|
|||
/**
|
||||
* testLoad method
|
||||
*
|
||||
* @expectedException RuntimeException
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadExceptionOnNonExistantFile() {
|
||||
$this->expectException(RuntimeException::class);
|
||||
Configure::config('test', new PhpReader());
|
||||
Configure::load('non_existing_configuration_file', 'test');
|
||||
}
|
||||
|
@ -485,10 +485,10 @@ class ConfigureTest extends CakeTestCase {
|
|||
/**
|
||||
* testDumpNoAdapter
|
||||
*
|
||||
* @expectedException ConfigureException
|
||||
* @return void
|
||||
*/
|
||||
public function testDumpNoAdapter() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
Configure::dump(TMP . 'test.php', 'does_not_exist');
|
||||
}
|
||||
|
||||
|
|
|
@ -2006,10 +2006,10 @@ class I18nTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that the '' domain causes exceptions.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testTranslateEmptyDomain() {
|
||||
$this->expectException(CakeException::class);
|
||||
I18n::translate('Plural Rule 1', null, '');
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,10 @@ class CakeLogTest extends CakeTestCase {
|
|||
/**
|
||||
* test all the errors from failed logger imports
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testImportingLoggerFailure() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::config('fail', array());
|
||||
}
|
||||
|
||||
|
@ -106,20 +106,20 @@ class CakeLogTest extends CakeTestCase {
|
|||
/**
|
||||
* test config() with invalid key name
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidKeyName() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::config('1nv', array('engine' => 'File'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that loggers have to implement the correct interface.
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testNotImplementingInterface() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::config('fail', array('engine' => 'stdClass'));
|
||||
}
|
||||
|
||||
|
@ -256,10 +256,10 @@ class CakeLogTest extends CakeTestCase {
|
|||
/**
|
||||
* test enable
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testStreamEnable() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::config('spam', array(
|
||||
'engine' => 'File',
|
||||
'file' => 'spam',
|
||||
|
@ -272,10 +272,10 @@ class CakeLogTest extends CakeTestCase {
|
|||
/**
|
||||
* test disable
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testStreamDisable() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::config('spam', array(
|
||||
'engine' => 'File',
|
||||
'file' => 'spam',
|
||||
|
@ -290,20 +290,20 @@ class CakeLogTest extends CakeTestCase {
|
|||
/**
|
||||
* test enabled() invalid stream
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testStreamEnabledInvalid() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::enabled('bogus_stream');
|
||||
}
|
||||
|
||||
/**
|
||||
* test disable invalid stream
|
||||
*
|
||||
* @expectedException CakeLogException
|
||||
* @return void
|
||||
*/
|
||||
public function testStreamDisableInvalid() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
CakeLog::disable('bogus_stream');
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ class LogEngineCollectionTest extends CakeTestCase {
|
|||
* test load with invalid Log
|
||||
*
|
||||
* @return void
|
||||
* @expectedException CakeLogException
|
||||
*/
|
||||
public function testLoadInvalid() {
|
||||
$this->expectException(CakeLogException::class);
|
||||
$result = $this->Collection->load('key', array('engine' => 'ImaginaryFile'));
|
||||
$this->assertInstanceOf('CakeLogInterface', $result);
|
||||
}
|
||||
|
|
|
@ -1389,10 +1389,10 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that an exception is raised when you try to over-write the name attribute.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnNameTranslation() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->loadFixtures('Translate', 'TranslatedItem');
|
||||
$TestModel = new TranslatedItem();
|
||||
$TestModel->bindTranslation(array('name' => 'name'));
|
||||
|
|
|
@ -606,10 +606,10 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test that attaching a non existent Behavior triggers a cake error.
|
||||
*
|
||||
* @expectedException MissingBehaviorException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidBehaviorCausingCakeError() {
|
||||
$this->expectException(MissingBehaviorException::class);
|
||||
$Apple = new Apple();
|
||||
$Apple->Behaviors->load('NoSuchBehavior');
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ class ConnectionManagerTest extends CakeTestCase {
|
|||
* testGetDataSourceException() method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException MissingDatasourceConfigException
|
||||
*/
|
||||
public function testGetDataSourceException() {
|
||||
$this->expectException(MissingDatasourceConfigException::class);
|
||||
ConnectionManager::getDataSource('non_existent_source');
|
||||
}
|
||||
|
||||
|
@ -223,9 +223,9 @@ class ConnectionManagerTest extends CakeTestCase {
|
|||
* testLoadDataSourceException() method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException MissingDatasourceException
|
||||
*/
|
||||
public function testLoadDataSourceException() {
|
||||
$this->expectException(MissingDatasourceException::class);
|
||||
$connection = array('classname' => 'NonExistentDataSource', 'filename' => 'non_existent');
|
||||
ConnectionManager::loadDataSource($connection);
|
||||
}
|
||||
|
|
|
@ -3977,10 +3977,10 @@ SQL;
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException MissingConnectionException
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnBrokenConnection() {
|
||||
$this->expectException(MissingConnectionException::class);
|
||||
new Mysql(array(
|
||||
'driver' => 'mysql',
|
||||
'host' => 'imaginary_host',
|
||||
|
|
|
@ -679,10 +679,11 @@ class DboSourceTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDirectCallThrowsException() {
|
||||
$this->expectException(PDOException::class);
|
||||
$this->db->query('directCall', array(), $this->Model);
|
||||
}
|
||||
|
||||
|
|
|
@ -438,10 +438,10 @@ class ModelDeleteTest extends BaseModelTest {
|
|||
/**
|
||||
* testDeleteAllUnknownColumn method
|
||||
*
|
||||
* @expectedException PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteAllUnknownColumn() {
|
||||
$this->expectException(PDOException::class);
|
||||
$this->loadFixtures('Article');
|
||||
$TestModel = new Article();
|
||||
$result = $TestModel->deleteAll(array('Article.non_existent_field' => 999));
|
||||
|
|
|
@ -140,10 +140,10 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
/**
|
||||
* Tests that creating a model with no existent database table associated will throw an exception
|
||||
*
|
||||
* @expectedException MissingTableException
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingTable() {
|
||||
$this->expectException(MissingTableException::class);
|
||||
$Article = new ArticleB(false, uniqid());
|
||||
$Article->schema();
|
||||
}
|
||||
|
|
|
@ -517,10 +517,10 @@ class ModelReadTest extends BaseModelTest {
|
|||
/**
|
||||
* testParameterMismatch method
|
||||
*
|
||||
* @expectedException PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function testParameterMismatch() {
|
||||
$this->expectException(PDOException::class);
|
||||
$this->skipIf($this->db instanceof Sqlite, 'Sqlite does not accept real prepared statements, no way to check this');
|
||||
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
|
||||
$Article = new Article();
|
||||
|
@ -536,10 +536,10 @@ class ModelReadTest extends BaseModelTest {
|
|||
/**
|
||||
* testVeryStrangeUseCase method
|
||||
*
|
||||
* @expectedException PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function testVeryStrangeUseCase() {
|
||||
$this->expectException(PDOException::class);
|
||||
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
|
||||
$Article = new Article();
|
||||
|
||||
|
@ -5412,10 +5412,10 @@ class ModelReadTest extends BaseModelTest {
|
|||
/**
|
||||
* testCallbackSourceChangeUnknownDatasource method
|
||||
*
|
||||
* @expectedException MissingDatasourceConfigException
|
||||
* @return void
|
||||
*/
|
||||
public function testCallbackSourceChangeUnknownDatasource() {
|
||||
$this->expectException(MissingDatasourceConfigException::class);
|
||||
$this->loadFixtures('Post', 'Author');
|
||||
$TestModel = new Post();
|
||||
$this->assertFalse($TestModel->find('all', array('connection' => 'foo')));
|
||||
|
|
|
@ -978,10 +978,10 @@ class CakeRequestTest extends CakeTestCase {
|
|||
/**
|
||||
* Test __call exceptions
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testMagicCallExceptionOnUnknownMethod() {
|
||||
$this->expectException(CakeException::class);
|
||||
$request = new CakeRequest('some/path');
|
||||
$request->IamABanana();
|
||||
}
|
||||
|
|
|
@ -113,10 +113,10 @@ class CakeResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests the statusCode method
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testStatusCode() {
|
||||
$this->expectException(CakeException::class);
|
||||
$response = new CakeResponse();
|
||||
$this->assertEquals(200, $response->statusCode());
|
||||
$response->statusCode(404);
|
||||
|
@ -402,10 +402,10 @@ class CakeResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests the httpCodes method
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testHttpCodes() {
|
||||
$this->expectException(CakeException::class);
|
||||
$response = new CakeResponse();
|
||||
$result = $response->httpCodes();
|
||||
$this->assertEquals(41, count($result));
|
||||
|
@ -1162,10 +1162,10 @@ class CakeResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* testFileNotFound
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function testFileNotFound() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$response = new CakeResponse();
|
||||
$response->file('/some/missing/folder/file.jpg');
|
||||
}
|
||||
|
@ -1173,11 +1173,11 @@ class CakeResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* test file with ../
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @expectedExceptionMessage The requested file contains `..` and will not be read.
|
||||
* @return void
|
||||
*/
|
||||
public function testFileWithForwardSlashPathTraversal() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$this->expectExceptionMessage("The requested file contains `..` and will not be read.");
|
||||
$response = new CakeResponse();
|
||||
$response->file('my/../cat.gif');
|
||||
}
|
||||
|
@ -1185,11 +1185,11 @@ class CakeResponseTest extends CakeTestCase {
|
|||
/**
|
||||
* test file with ..\
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @expectedExceptionMessage The requested file contains `..` and will not be read.
|
||||
* @return void
|
||||
*/
|
||||
public function testFileWithBackwardSlashPathTraversal() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$this->expectExceptionMessage("The requested file contains `..` and will not be read.");
|
||||
$response = new CakeResponse();
|
||||
$response->file('my\..\cat.gif');
|
||||
}
|
||||
|
@ -1198,11 +1198,11 @@ class CakeResponseTest extends CakeTestCase {
|
|||
* Although unlikely, a file may contain dots in its filename.
|
||||
* This should be allowed, as long as the dots doesn't specify a path (../ or ..\)
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable#
|
||||
* @return void
|
||||
*/
|
||||
public function testFileWithDotsInFilename() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$this->expectExceptionMessageMatches('#The requested file .+my/Some..cat.gif was not found or not readable#');
|
||||
$response = new CakeResponse();
|
||||
$response->file('my/Some..cat.gif');
|
||||
}
|
||||
|
|
|
@ -118,10 +118,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
* testInvalidConnection method
|
||||
*
|
||||
* @dataProvider invalidConnections
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidConnection($data) {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->Socket->config = array_merge($this->Socket->config, $data);
|
||||
$this->Socket->connect();
|
||||
}
|
||||
|
@ -238,10 +238,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testEncrypt
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testEnableCryptoSocketExceptionNoSsl() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.');
|
||||
$configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1);
|
||||
|
||||
|
@ -254,10 +254,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testEnableCryptoSocketExceptionNoTls
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testEnableCryptoSocketExceptionNoTls() {
|
||||
$this->expectException(SocketException::class);
|
||||
$configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1);
|
||||
|
||||
// testing exception on no ssl socket server for ssl and tls methods
|
||||
|
@ -303,10 +303,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testEnableCryptoBadMode
|
||||
*
|
||||
* @expectedException InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
public function testEnableCryptoBadMode() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
// testing wrong encryption mode
|
||||
$this->_connectSocketToSslTls();
|
||||
$this->Socket->enableCrypto('doesntExistMode', 'server');
|
||||
|
@ -342,10 +342,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testEnableCryptoExceptionEnableTwice
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testEnableCryptoExceptionEnableTwice() {
|
||||
$this->expectException(SocketException::class);
|
||||
// testing on tls server
|
||||
$this->_connectSocketToSslTls();
|
||||
$this->Socket->enableCrypto('tls', 'client');
|
||||
|
@ -355,10 +355,10 @@ class CakeSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testEnableCryptoExceptionDisableTwice
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testEnableCryptoExceptionDisableTwice() {
|
||||
$this->expectException(SocketException::class);
|
||||
// testing on tls server
|
||||
$this->_connectSocketToSslTls();
|
||||
$this->Socket->enableCrypto('tls', 'client', false);
|
||||
|
|
|
@ -334,33 +334,33 @@ class CakeEmailTest extends CakeTestCase {
|
|||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage The email set for "_to" is empty.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidEmail() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("The email set for \"_to\" is empty.");
|
||||
$this->CakeEmail->to('');
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email set for "_from". You passed "cake.@"
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidFrom() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("Invalid email set for \"_from\". You passed \"cake.@\"");
|
||||
$this->CakeEmail->from('cake.@');
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email set for "_to". You passed "1"
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidEmailAdd() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("Invalid email set for \"_to\". You passed \"1\"");
|
||||
$this->CakeEmail->addTo('1');
|
||||
}
|
||||
|
||||
|
@ -432,11 +432,10 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* Tests that it is possible to unset the email pattern and make use of filter_var() instead.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email set for "_to". You passed "fail.@example.com"
|
||||
*/
|
||||
public function testUnsetEmailPattern() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("Invalid email set for \"_to\". You passed \"fail.@example.com\"");
|
||||
$email = new CakeEmail();
|
||||
$this->assertSame(CakeEmail::EMAIL_PATTERN, $email->emailPattern());
|
||||
|
||||
|
@ -594,9 +593,9 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* testMessageIdInvalid method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException SocketException
|
||||
*/
|
||||
public function testMessageIdInvalid() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->CakeEmail->messageId('my-email@localhost');
|
||||
}
|
||||
|
||||
|
@ -776,10 +775,10 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* testInvalidHeaders
|
||||
*
|
||||
* @dataProvider invalidHeaders
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidHeaders($value) {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->CakeEmail->setHeaders($value);
|
||||
}
|
||||
|
||||
|
@ -787,10 +786,10 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* testInvalidAddHeaders
|
||||
*
|
||||
* @dataProvider invalidHeaders
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidAddHeaders($value) {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->CakeEmail->addHeaders($value);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testConnectEhloTlsOnNonTlsServer method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectEhloTlsOnNonTlsServer() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.");
|
||||
$this->SmtpTransport->config(array('tls' => true));
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
|
@ -133,11 +133,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testConnectEhloNoTlsOnRequiredTlsServer method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectEhloNoTlsOnRequiredTlsServer() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP authentication method not allowed, check if SMTP server requires TLS.");
|
||||
$this->SmtpTransport->config(array('tls' => false, 'username' => 'user', 'password' => 'pass'));
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
|
@ -167,11 +167,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testConnectFail method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the connection.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectFail() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP server did not accept the connection.");
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
|
||||
|
@ -200,11 +200,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testAuthNotRecognized method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthNotRecognized() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("AUTH command not recognized or not implemented, SMTP server may not require authentication.");
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
|
@ -214,11 +214,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testAuthNotImplemented method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthNotImplemented() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("AUTH command not recognized or not implemented, SMTP server may not require authentication.");
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')
|
||||
->will($this->returnValue("502 5.3.3 Command not implemented\r\n"));
|
||||
|
@ -229,11 +229,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testAuthBadSequence method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP Error: 503 5.5.1 Already authenticated
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadSequence() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP Error: 503 5.5.1 Already authenticated");
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')
|
||||
->will($this->returnValue("503 5.5.1 Already authenticated\r\n"));
|
||||
|
@ -244,11 +244,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testAuthBadUsername method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the username.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadUsername() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP server did not accept the username.");
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n");
|
||||
|
@ -260,11 +260,11 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
/**
|
||||
* testAuthBadPassword method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the password.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadPassword() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->expectExceptionMessage("SMTP server did not accept the password.");
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n");
|
||||
|
|
|
@ -362,10 +362,10 @@ class HttpResponseTest extends CakeTestCase {
|
|||
* testInvalidParseResponseData
|
||||
*
|
||||
* @dataProvider invalidParseResponseDataProvider
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidParseResponseData($value) {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->HttpResponse->parseResponse($value);
|
||||
}
|
||||
|
||||
|
|
|
@ -624,10 +624,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* The "*" asterisk character is only allowed for the following methods: OPTIONS.
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestNotAllowedUri() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->Socket->reset();
|
||||
$request = array('uri' => '*', 'method' => 'GET');
|
||||
$this->Socket->request($request);
|
||||
|
@ -1358,20 +1358,20 @@ class HttpSocketTest extends CakeTestCase {
|
|||
/**
|
||||
* testBadBuildRequestLine method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testBadBuildRequestLine() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->Socket->buildRequestLine('Foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* testBadBuildRequestLine2 method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @return void
|
||||
*/
|
||||
public function testBadBuildRequestLine2() {
|
||||
$this->expectException(SocketException::class);
|
||||
$this->Socket->buildRequestLine("GET * HTTP/1.1\r\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -738,11 +738,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* testMissingController method
|
||||
*
|
||||
* @expectedException MissingControllerException
|
||||
* @expectedExceptionMessage Controller class SomeControllerController could not be found.
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingController() {
|
||||
$this->expectException(MissingControllerException::class);
|
||||
$this->expectExceptionMessage("Controller class SomeControllerController could not be found.");
|
||||
Router::connect('/:controller/:action/*');
|
||||
|
||||
$Dispatcher = new TestDispatcher();
|
||||
|
@ -756,11 +756,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* testMissingControllerInterface method
|
||||
*
|
||||
* @expectedException MissingControllerException
|
||||
* @expectedExceptionMessage Controller class DispatcherTestInterfaceController could not be found.
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingControllerInterface() {
|
||||
$this->expectException(MissingControllerException::class);
|
||||
$this->expectExceptionMessage("Controller class DispatcherTestInterfaceController could not be found.");
|
||||
Router::connect('/:controller/:action/*');
|
||||
|
||||
$Dispatcher = new TestDispatcher();
|
||||
|
@ -774,11 +774,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* testMissingControllerInterface method
|
||||
*
|
||||
* @expectedException MissingControllerException
|
||||
* @expectedExceptionMessage Controller class DispatcherTestAbstractController could not be found.
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingControllerAbstract() {
|
||||
$this->expectException(MissingControllerException::class);
|
||||
$this->expectExceptionMessage("Controller class DispatcherTestAbstractController could not be found.");
|
||||
Router::connect('/:controller/:action/*');
|
||||
|
||||
$Dispatcher = new TestDispatcher();
|
||||
|
@ -1164,11 +1164,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* testAutomaticPluginControllerMissingActionDispatch method
|
||||
*
|
||||
* @expectedException MissingActionException
|
||||
* @expectedExceptionMessage Action MyPluginController::not_here() could not be found.
|
||||
* @return void
|
||||
*/
|
||||
public function testAutomaticPluginControllerMissingActionDispatch() {
|
||||
$this->expectException(MissingActionException::class);
|
||||
$this->expectExceptionMessage("Action MyPluginController::not_here() could not be found.");
|
||||
Router::reload();
|
||||
$Dispatcher = new TestDispatcher();
|
||||
|
||||
|
@ -1181,12 +1181,12 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* testAutomaticPluginControllerMissingActionDispatch method
|
||||
*
|
||||
* @expectedException MissingActionException
|
||||
* @expectedExceptionMessage Action MyPluginController::param:value() could not be found.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function testAutomaticPluginControllerIndexMissingAction() {
|
||||
$this->expectException(MissingActionException::class);
|
||||
$this->expectExceptionMessage("Action MyPluginController::param:value() could not be found.");
|
||||
Router::reload();
|
||||
$Dispatcher = new TestDispatcher();
|
||||
|
||||
|
@ -1283,10 +1283,10 @@ class DispatcherTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests that attaching an inexistent class as filter will throw an exception
|
||||
*
|
||||
* @expectedException MissingDispatcherFilterException
|
||||
* @return void
|
||||
*/
|
||||
public function testDispatcherFilterSuscriberMissing() {
|
||||
$this->expectException(MissingDispatcherFilterException::class);
|
||||
App::build(array(
|
||||
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||
), App::RESET);
|
||||
|
|
|
@ -2450,10 +2450,10 @@ class RouterTest extends CakeTestCase {
|
|||
/**
|
||||
* test that route classes must extend CakeRoute
|
||||
*
|
||||
* @expectedException RouterException
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomRouteException() {
|
||||
$this->expectException(RouterException::class);
|
||||
Router::connect('/:controller', array(), array('routeClass' => 'CakeObject'));
|
||||
}
|
||||
|
||||
|
@ -2840,10 +2840,10 @@ class RouterTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that route classes must extend CakeRoute
|
||||
*
|
||||
* @expectedException RouterException
|
||||
* @return void
|
||||
*/
|
||||
public function testDefaultRouteException() {
|
||||
$this->expectException(RouterException::class);
|
||||
Router::defaultRouteClass('');
|
||||
Router::connect('/:controller', array());
|
||||
}
|
||||
|
@ -2851,20 +2851,20 @@ class RouterTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that route classes must extend CakeRoute
|
||||
*
|
||||
* @expectedException RouterException
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingInvalidDefaultRouteException() {
|
||||
$this->expectException(RouterException::class);
|
||||
Router::defaultRouteClass('CakeObject');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that class must exist
|
||||
*
|
||||
* @expectedException RouterException
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingNonExistentDefaultRouteException() {
|
||||
$this->expectException(RouterException::class);
|
||||
Router::defaultRouteClass('NonExistentClass');
|
||||
}
|
||||
|
||||
|
|
|
@ -508,11 +508,11 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
/**
|
||||
* testGetMockForModelDoesNotExist
|
||||
*
|
||||
* @expectedException MissingModelException
|
||||
* @expectedExceptionMessage Model IDoNotExist could not be found
|
||||
* @return void
|
||||
*/
|
||||
public function testGetMockForModelDoesNotExist() {
|
||||
$this->expectException(MissingModelException::class);
|
||||
$this->expectExceptionMessage("Model IDoNotExist could not be found");
|
||||
$this->getMockForModel('IDoNotExist');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -528,10 +528,10 @@ class CakeTestFixtureTest extends CakeTestCase {
|
|||
/**
|
||||
* test the insert method with invalid fixture
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testInsertInvalid() {
|
||||
$this->expectException(CakeException::class);
|
||||
$Fixture = new InvalidTestFixture();
|
||||
$Fixture->insert($this->criticDb);
|
||||
}
|
||||
|
|
|
@ -402,10 +402,10 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests not using loaded routes during tests
|
||||
*
|
||||
* @expectedException MissingActionException
|
||||
* @return void
|
||||
*/
|
||||
public function testSkipRoutes() {
|
||||
$this->expectException(MissingActionException::class);
|
||||
Router::connect('/:controller/:action/*');
|
||||
include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php';
|
||||
|
||||
|
|
|
@ -752,10 +752,10 @@ class CakeNumberTest extends CakeTestCase {
|
|||
/**
|
||||
* testFromReadableSize
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testFromReadableSizeException() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->Number->fromReadableSize('bogus', false);
|
||||
}
|
||||
|
||||
|
|
|
@ -326,20 +326,20 @@ class ClassRegistryTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that you cannot init() an abstract class. An exception will be raised.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testInitAbstractClass() {
|
||||
$this->expectException(CakeException::class);
|
||||
ClassRegistry::init('ClassRegistryAbstractModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that you cannot init() an abstract class. A exception will be raised.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testInitInterface() {
|
||||
$this->expectException(CakeException::class);
|
||||
ClassRegistry::init('ClassRegistryInterfaceTest');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,10 +225,10 @@ class DebuggerTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that choosing a non-existent format causes an exception
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testOutputAsException() {
|
||||
$this->expectException(CakeException::class);
|
||||
Debugger::outputAs('Invalid junk');
|
||||
}
|
||||
|
||||
|
|
|
@ -183,10 +183,10 @@ class FolderTest extends CakeTestCase {
|
|||
/**
|
||||
* @dataProvider inPathInvalidPathArgumentDataProvider
|
||||
* @param string $path
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The $path argument is expected to be an absolute path.
|
||||
*/
|
||||
public function testInPathInvalidPathArgument($path) {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("The \$path argument is expected to be an absolute path.");
|
||||
$Folder = new Folder();
|
||||
$Folder->inPath($path);
|
||||
}
|
||||
|
|
|
@ -248,10 +248,10 @@ class HashTest extends CakeTestCase {
|
|||
/**
|
||||
* Test get() with an invalid path
|
||||
*
|
||||
* @expectedException InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
public function testGetInvalidPath() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
Hash::get(array('one' => 'two'), new StdClass());
|
||||
}
|
||||
|
||||
|
@ -1900,10 +1900,10 @@ class HashTest extends CakeTestCase {
|
|||
/**
|
||||
* test combine() giving errors on key/value length mismatches.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testCombineErrorMissingValue() {
|
||||
$this->expectException(CakeException::class);
|
||||
$data = array(
|
||||
array('User' => array('id' => 1, 'name' => 'mark')),
|
||||
array('User' => array('name' => 'jose')),
|
||||
|
@ -1914,10 +1914,10 @@ class HashTest extends CakeTestCase {
|
|||
/**
|
||||
* test combine() giving errors on key/value length mismatches.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testCombineErrorMissingKey() {
|
||||
$this->expectException(CakeException::class);
|
||||
$data = array(
|
||||
array('User' => array('id' => 1, 'name' => 'mark')),
|
||||
array('User' => array('id' => 2)),
|
||||
|
@ -2585,10 +2585,10 @@ class HashTest extends CakeTestCase {
|
|||
/**
|
||||
* Tests that nest() throws an InvalidArgumentException when providing an invalid input.
|
||||
*
|
||||
* @expectedException InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
public function testNestInvalid() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$input = array(
|
||||
array(
|
||||
'ParentCategory' => array(
|
||||
|
|
|
@ -342,10 +342,10 @@ class ObjectCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test that setting modParams to an index that doesn't exist doesn't cause errors.
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testTriggerModParamsInvalidIndex() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->_makeMockClasses();
|
||||
$this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject);
|
||||
$this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject);
|
||||
|
|
|
@ -456,11 +456,11 @@ class SecurityTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that short keys cause errors
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @expectedExceptionMessage Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long.
|
||||
* @return void
|
||||
*/
|
||||
public function testEncryptInvalidKey() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->expectExceptionMessage("Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long.");
|
||||
$txt = 'The quick brown fox jumped over the lazy dog.';
|
||||
$key = 'this is too short';
|
||||
Security::encrypt($txt, $key);
|
||||
|
@ -494,11 +494,11 @@ class SecurityTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that short keys cause errors
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @expectedExceptionMessage Invalid key for decrypt(), key must be at least 256 bits (32 bytes) long.
|
||||
* @return void
|
||||
*/
|
||||
public function testDecryptInvalidKey() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->expectExceptionMessage("Invalid key for decrypt(), key must be at least 256 bits (32 bytes) long.");
|
||||
$txt = 'The quick brown fox jumped over the lazy dog.';
|
||||
$key = 'this is too short';
|
||||
Security::decrypt($txt, $key);
|
||||
|
@ -507,11 +507,11 @@ class SecurityTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that empty data cause errors
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @expectedExceptionMessage The data to decrypt cannot be empty.
|
||||
* @return void
|
||||
*/
|
||||
public function testDecryptInvalidData() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->expectExceptionMessage("The data to decrypt cannot be empty.");
|
||||
$txt = '';
|
||||
$key = 'This is a key that is long enough to be ok.';
|
||||
Security::decrypt($txt, $key);
|
||||
|
|
|
@ -2405,10 +2405,10 @@ class ValidationTest extends CakeTestCase {
|
|||
/**
|
||||
* testMimeTypeFalse method
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testMimeTypeFalse() {
|
||||
$this->expectException(CakeException::class);
|
||||
$image = CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif';
|
||||
$File = new File($image, false);
|
||||
$this->skipIf($File->mime(), 'mimeType can be determined, no Exception will be thrown');
|
||||
|
|
|
@ -182,10 +182,10 @@ class XmlTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that the readFile option disables local file parsing.
|
||||
*
|
||||
* @expectedException XmlException
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildFromFileWhenDisabled() {
|
||||
$this->expectException(XmlException::class);
|
||||
$xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml';
|
||||
Xml::build($xml, array('readFile' => false));
|
||||
}
|
||||
|
@ -193,10 +193,10 @@ class XmlTest extends CakeTestCase {
|
|||
/**
|
||||
* Test that the readFile option disables local file parsing.
|
||||
*
|
||||
* @expectedException XmlException
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildFromUrlWhenDisabled() {
|
||||
$this->expectException(XmlException::class);
|
||||
$xml = 'http://www.google.com';
|
||||
Xml::build($xml, array('readFile' => false));
|
||||
}
|
||||
|
@ -219,20 +219,20 @@ class XmlTest extends CakeTestCase {
|
|||
* testBuildInvalidData
|
||||
*
|
||||
* @dataProvider invalidDataProvider
|
||||
* @expectedException XmlException
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildInvalidData($value) {
|
||||
$this->expectException(XmlException::class);
|
||||
Xml::build($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that building SimpleXmlElement with invalid XML causes the right exception.
|
||||
*
|
||||
* @expectedException XmlException
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildInvalidDataSimpleXml() {
|
||||
$this->expectException(XmlException::class);
|
||||
$input = '<derp';
|
||||
Xml::build($input, array('return' => 'simplexml'));
|
||||
}
|
||||
|
@ -1174,10 +1174,10 @@ XML;
|
|||
* testToArrayFail method
|
||||
*
|
||||
* @dataProvider invalidToArrayDataProvider
|
||||
* @expectedException XmlException
|
||||
* @return void
|
||||
*/
|
||||
public function testToArrayFail($value) {
|
||||
$this->expectException(XmlException::class);
|
||||
Xml::toArray($value);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,9 @@ class FlashHelperTest extends CakeTestCase {
|
|||
/**
|
||||
* testFlashThrowsException
|
||||
*
|
||||
* @expectedException UnexpectedValueException
|
||||
*/
|
||||
public function testFlashThrowsException() {
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
CakeSession::write('Message.foo', 'bar');
|
||||
$this->Flash->render('foo');
|
||||
}
|
||||
|
|
|
@ -10918,10 +10918,10 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testHtml5InputException() {
|
||||
$this->expectException(CakeException::class);
|
||||
$this->Form->email();
|
||||
}
|
||||
|
||||
|
|
|
@ -580,9 +580,9 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* testLoadConfigWrongFile method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testBase64InvalidArgumentException() {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->Html->request->webroot = '';
|
||||
$this->Html->image('non-existent-image.png', array('base64' => true));
|
||||
}
|
||||
|
@ -2321,9 +2321,9 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* testLoadConfigWrongFile method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException ConfigureException
|
||||
*/
|
||||
public function testLoadConfigWrongFile() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$this->Html->loadConfig('wrong_file');
|
||||
}
|
||||
|
||||
|
@ -2331,9 +2331,9 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* testLoadConfigWrongReader method
|
||||
*
|
||||
* @return void
|
||||
* @expectedException ConfigureException
|
||||
*/
|
||||
public function testLoadConfigWrongReader() {
|
||||
$this->expectException(ConfigureException::class);
|
||||
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
|
||||
$this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path);
|
||||
}
|
||||
|
|
|
@ -2811,10 +2811,10 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
/**
|
||||
* test that mock classes injected into paginatorHelper are called when using link()
|
||||
*
|
||||
* @expectedException CakeException
|
||||
* @return void
|
||||
*/
|
||||
public function testMockAjaxProviderClassInjection() {
|
||||
$this->expectException(CakeException::class);
|
||||
$mock = $this->getMock('PaginatorHelper', array(), array($this->View), 'PaginatorMockJsHelper');
|
||||
$Paginator = new PaginatorHelper($this->View, array('ajax' => 'PaginatorMockJs'));
|
||||
$Paginator->request->params['paging'] = array(
|
||||
|
|
|
@ -93,10 +93,10 @@ class HelperCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test lazy loading of helpers
|
||||
*
|
||||
* @expectedException MissingHelperException
|
||||
* @return void
|
||||
*/
|
||||
public function testLazyLoadException() {
|
||||
$this->expectException(MissingHelperException::class);
|
||||
$this->Helpers->NotAHelper;
|
||||
}
|
||||
|
||||
|
@ -145,10 +145,10 @@ class HelperCollectionTest extends CakeTestCase {
|
|||
/**
|
||||
* test missinghelper exception
|
||||
*
|
||||
* @expectedException MissingHelperException
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadMissingHelper() {
|
||||
$this->expectException(MissingHelperException::class);
|
||||
$this->Helpers->load('ThisHelperShouldAlwaysBeMissing');
|
||||
}
|
||||
|
||||
|
|
|
@ -399,10 +399,10 @@ class ViewTest extends CakeTestCase {
|
|||
* Test that plugin files with absolute file paths are scoped
|
||||
* to the plugin and do now allow any file path.
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testPluginGetTemplateAbsoluteFail() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$this->Controller->viewPath = 'Pages';
|
||||
$this->Controller->action = 'display';
|
||||
$this->Controller->params['pass'] = array('home');
|
||||
|
@ -614,10 +614,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test for missing views
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingView() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$this->Controller->plugin = null;
|
||||
$this->Controller->name = 'Pages';
|
||||
$this->Controller->viewPath = 'Pages';
|
||||
|
@ -631,10 +631,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test for missing theme views
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingThemeView() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$this->ThemeController->plugin = null;
|
||||
$this->ThemeController->name = 'Pages';
|
||||
$this->ThemeController->viewPath = 'Pages';
|
||||
|
@ -650,10 +650,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test for missing layouts
|
||||
*
|
||||
* @expectedException MissingLayoutException
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingLayout() {
|
||||
$this->expectException(MissingLayoutException::class);
|
||||
$this->Controller->plugin = null;
|
||||
$this->Controller->name = 'Posts';
|
||||
$this->Controller->viewPath = 'Posts';
|
||||
|
@ -666,10 +666,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test for missing theme layouts
|
||||
*
|
||||
* @expectedException MissingLayoutException
|
||||
* @return void
|
||||
*/
|
||||
public function testMissingThemeLayout() {
|
||||
$this->expectException(MissingLayoutException::class);
|
||||
$this->ThemeController->plugin = null;
|
||||
$this->ThemeController->name = 'Posts';
|
||||
$this->ThemeController->viewPath = 'posts';
|
||||
|
@ -1334,10 +1334,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* testBadExt method
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testBadExt() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$this->PostsController->action = 'something';
|
||||
$this->PostsController->ext = '.whatever';
|
||||
|
||||
|
@ -1360,10 +1360,10 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* testAltBadExt method
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @return void
|
||||
*/
|
||||
public function testAltBadExt() {
|
||||
$this->expectException(MissingViewException::class);
|
||||
$View = new TestView($this->PostsController);
|
||||
$View->render('alt_ext');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue