more tests

This commit is contained in:
John Bintz 2010-01-01 15:14:37 -05:00
parent f6ab4c7c0f
commit d4f6b7d319
2 changed files with 23 additions and 1 deletions

View File

@ -476,7 +476,7 @@ class ComicPressAdmin {
* Handle an update.
*/
function handle_update() {
if ($method = ComicPressAdmin::verify_nonces()) {
if ($method = $this->verify_nonces()) {
switch ($method) {
case 'attachments':
$this->handle_update_attachments();

View File

@ -315,6 +315,28 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
$_REQUEST = $_POST = $request;
$this->assertEquals($expected_result, ComicPressAdmin::verify_nonces());
}
function providerTestHandleUpdate() {
return array(
array(false, array()),
array('attachments', array('handle_update_attachments')),
array('test', array('test')),
);
}
/**
* @dataProvider providerTestHandleUpdate
*/
function testHandleUpdate($nonce_return, $expected_methods) {
$_REQUEST = array('cp' => true);
$admin = $this->getMock('ComicPressAdmin', array_merge($expected_methods, array('verify_nonces')));
$admin->expects($this->once())->method('verify_nonces')->will($this->returnValue($nonce_return));
foreach ($expected_methods as $method) {
$admin->expects($this->once())->method($method);
}
$admin->handle_update();
}
}
?>