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