Test create document

pull/1/head
Victor Dubiniuk 10 years ago
parent d6c44f6c75
commit 8bc55b679a

@ -12,18 +12,15 @@
namespace OCA\Documents\Controller; namespace OCA\Documents\Controller;
class DocumentControllerTest extends \PHPUnit_Framework_TestCase { class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
private $appName; private $appName = 'documents';
private $request; private $request;
private $l10n; private $l10n;
private $settings; private $settings;
private $uid; private $uid = 'jack_the_documents_tester';
private $password; private $password = 'password';
private $controller; private $controller;
public function setUp(){ public function setUp(){
$this->appName = 'documents';
$this->uid = 'jack_the_documents_tester';
$this->password = 'password';
$this->request = $this->getMockBuilder('\OCP\IRequest') $this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock() ->getMock()
@ -43,14 +40,19 @@ class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
$this->l10n, $this->l10n,
$this->uid $this->uid
); );
if (!\OCP\User::userExists($this->uid)){
\OC_User::createUser($this->uid, $this->password);
}
\OC_User::getUserSession()->login($this->uid, $this->password);
\OC_Util::setupFS();
} }
public function tearDown(){ public static function tearDownAfterClass(){
\OC_User::deleteUser($this->uid); \OC_User::deleteUser(\OC_User::getUserSession()->getUser()->getUID());
} }
public function testRename(){ public function testRename(){
$this->login();
$result = array( $result = array(
'status' => 'error', 'status' => 'error',
'message' => (string) $this->l10n->t('You don\'t have permission to rename this document') 'message' => (string) $this->l10n->t('You don\'t have permission to rename this document')
@ -63,15 +65,11 @@ class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($result, $response); $this->assertEquals($result, $response);
} }
protected function login(){ public function testCreate(){
if (!\OCP\User::userExists($this->uid)){ $currentDir = getcwd();
\OC_User::createUser($this->uid, $this->password); chdir('../../../');
} $response = $this->controller->create();
if (!\OC_User::isLoggedIn()){ chdir($currentDir);
$result = \OC_User::getUserSession()->login($this->uid, $this->password); $this->assertEquals('success', $response['status']);
if ($result){
\OC_Util::setupFS(\OC_User::getUserSession()->getUser()->getUID());
}
}
} }
} }

Loading…
Cancel
Save