From 211955bef84071b025e83bdeeefe496a5002fdd8 Mon Sep 17 00:00:00 2001 From: Christopher Smith <chris@jalakai.co.uk> Date: Thu, 28 Nov 2013 00:49:31 +0000 Subject: [PATCH] test import against auth plugin which doesn't allow adding users --- .../usermanager/_test/csv_import.test.php | 18 +++++++++++++++++- lib/plugins/usermanager/_test/mocks.class.php | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/plugins/usermanager/_test/csv_import.test.php b/lib/plugins/usermanager/_test/csv_import.test.php index 5deb201ba..1f0ee7436 100644 --- a/lib/plugins/usermanager/_test/csv_import.test.php +++ b/lib/plugins/usermanager/_test/csv_import.test.php @@ -47,7 +47,7 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest { global $auth; $before_users = $auth->retrieveUsers(); - io_savefile($this->importfile, $importCsv); + io_savefile($this->importfile, $importCsv); $result = $this->usermanager->tryImport(); $after_users = $auth->retrieveUsers(); @@ -66,6 +66,22 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest { $this->assertEquals($expectedFailures, $this->usermanager->getImportFailures()); // failures as expected } + function test_cantImport(){ + global $auth; + $oldauth = $auth; + + $auth = new auth_mock_authplain(); + $auth->setCanDo('addUser', false); + + $csv = 'User,"Real Name",Email,Groups +importuser,"Ford Prefect",ford@example.com,user +'; + + $this->doImportTest($csv, false, array(), array()); + + $auth = $oldauth; + } + function test_import() { $csv = 'User,"Real Name",Email,Groups importuser,"Ford Prefect",ford@example.com,user diff --git a/lib/plugins/usermanager/_test/mocks.class.php b/lib/plugins/usermanager/_test/mocks.class.php index edf5438b2..f3cc72c27 100644 --- a/lib/plugins/usermanager/_test/mocks.class.php +++ b/lib/plugins/usermanager/_test/mocks.class.php @@ -41,3 +41,10 @@ class admin_mock_usermanager extends admin_plugin_usermanager { } } +class auth_mock_authplain extends auth_plugin_authplain { + + public function setCanDo($op, $canDo) { + $this->cando[$op] = $canDo; + } + +} -- GitLab