From d4f6b7d319e204f7cad1cac690a155d1d437263e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 1 Jan 2010 15:14:37 -0500 Subject: [PATCH] more tests --- classes/ComicPressAdmin.inc | 2 +- test/ComicPressAdminTest.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index df323c9..a3a4568 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -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(); diff --git a/test/ComicPressAdminTest.php b/test/ComicPressAdminTest.php index 9920b64..6ecbd92 100644 --- a/test/ComicPressAdminTest.php +++ b/test/ComicPressAdminTest.php @@ -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(); + } } ?>