FIx lib/ a-d

remotes/origin/throw-loginexception-failed-login
Joas Schilling 10 years ago
parent 7f3f16d155
commit 55fc6536d3
No known key found for this signature in database
GPG Key ID: 70A0B324C41C0946
  1. 14
      tests/lib/APITest.php
  2. 4
      tests/lib/AllConfigTest.php
  3. 15
      tests/lib/AppTest.php
  4. 2
      tests/lib/CapabilitiesManagerTest.php
  5. 2
      tests/lib/ConfigTest.php
  6. 5
      tests/lib/ContactsManagerTest.php
  7. 4
      tests/lib/ErrorHandlerTest.php
  8. 6
      tests/lib/appconfig.php
  9. 5
      tests/lib/avatarmanagertest.php
  10. 19
      tests/lib/avatartest.php
  11. 12
      tests/lib/db/DBSchemaTest.php
  12. 10
      tests/lib/db/LegacyDBTest.php

@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
class Test_API extends \Test\TestCase {
namespace Test;
class APITest extends \Test\TestCase {
// Helps build a response variable
@ -14,7 +16,7 @@ class Test_API extends \Test\TestCase {
* @param string $message
*/
function buildResponse($shipped, $data, $code, $message=null) {
$resp = new OC_OCS_Result($data, $code, $message);
$resp = new \OC_OCS_Result($data, $code, $message);
$resp->addHeader('KEY', 'VALUE');
return [
'shipped' => $shipped,
@ -26,13 +28,13 @@ class Test_API extends \Test\TestCase {
// Validate details of the result
/**
* @param OC_OCS_Result $result
* @param \OC_OCS_Result $result
*/
function checkResult($result, $success) {
// Check response is of correct type
$this->assertInstanceOf('OC_OCS_Result', $result);
// Check if it succeeded
/** @var $result OC_OCS_Result */
/** @var $result \OC_OCS_Result */
$this->assertEquals($success, $result->succeeded());
}
@ -108,7 +110,7 @@ class Test_API extends \Test\TestCase {
// Test merging one success result
$response = $this->buildResponse(true, $data1, $statusCode);
$result = OC_API::mergeResponses([$response]);
$result = \OC_API::mergeResponses([$response]);
$this->assertEquals($response['response'], $result);
$this->checkResult($result, $succeeded);
}
@ -170,7 +172,7 @@ class Test_API extends \Test\TestCase {
));
// Two shipped success results
$result = OC_API::mergeResponses(array(
$result = \OC_API::mergeResponses(array(
$this->buildResponse($shipped1, $data1, $statusCode1, "message1"),
$this->buildResponse($shipped2, $data2, $statusCode2, "message2"),
));

@ -9,13 +9,13 @@
namespace Test;
/**
* Class TestAllConfig
* Class AllConfigTest
*
* @group DB
*
* @package Test
*/
class TestAllConfig extends \Test\TestCase {
class AllConfigTest extends \Test\TestCase {
/** @var \OCP\IDBConnection */
protected $connection;

@ -7,12 +7,15 @@
* See the COPYING-README file.
*/
namespace Test;
use OCP\IAppConfig;
/**
* Class Test_App
* Class AppTest
*
* @group DB
*/
class Test_App extends \Test\TestCase {
class AppTest extends \Test\TestCase {
const TEST_USER1 = 'user1';
const TEST_USER2 = 'user2';
@ -267,7 +270,7 @@ class Test_App extends \Test\TestCase {
* @dataProvider appVersionsProvider
*/
public function testIsAppCompatible($ocVersion, $appInfo, $expectedResult) {
$this->assertEquals($expectedResult, OC_App::isAppCompatible($ocVersion, $appInfo));
$this->assertEquals($expectedResult, \OC_App::isAppCompatible($ocVersion, $appInfo));
}
/**
@ -280,7 +283,7 @@ class Test_App extends \Test\TestCase {
'requiremin' => '6',
'requiremax' => '6',
);
$this->assertTrue(OC_App::isAppCompatible($ocVersion, $appInfo));
$this->assertTrue(\OC_App::isAppCompatible($ocVersion, $appInfo));
}
/**
@ -478,9 +481,9 @@ class Test_App extends \Test\TestCase {
/**
* Register an app config mock for testing purposes.
*
* @param $appConfig app config mock
* @param IAppConfig $appConfig app config mock
*/
private function registerAppConfig($appConfig) {
private function registerAppConfig(IAppConfig $appConfig) {
\OC::$server->registerService('AppConfig', function ($c) use ($appConfig) {
return $appConfig;
});

@ -21,8 +21,6 @@
namespace Test;
use OC\CapabilitiesManager;
class CapabilitiesManagerTest extends TestCase {
/**

@ -8,7 +8,7 @@
namespace Test;
class ConfigTests extends TestCase {
class ConfigTest extends TestCase {
const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);';
/** @var array */

@ -1,7 +1,8 @@
<?php
namespace Test;
class Test_ContactsManager extends \Test\TestCase {
class ContactsManagerTest extends \Test\TestCase {
/** @var \OC\ContactsManager */
private $cm;
@ -206,4 +207,4 @@ class Test_ContactsManager extends \Test\TestCase {
$this->assertTrue($result);
}
}
}

@ -20,7 +20,9 @@
*
*/
class Test_ErrorHandler extends \Test\TestCase {
namespace Test;
class ErrorHandlerTest extends \Test\TestCase {
/**
* provide username, password combinations for testRemovePassword

@ -7,16 +7,14 @@
* See the COPYING-README file.
*/
namespace Test\Lib;
use Test\TestCase;
namespace Test;
/**
* Class AppConfig
*
* @group DB
*
* @package Test\Lib
* @package Test
*/
class AppConfig extends TestCase {
/** @var \OCP\IAppConfig */

@ -18,6 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace Test;
use OC\AvatarManager;
use Test\Traits\UserTrait;
use Test\Traits\MountProviderTrait;
@ -48,7 +51,7 @@ class AvatarManagerTest extends \Test\TestCase {
}
/**
* @expectedException Exception
* @expectedException \Exception
* @expectedExceptionMessage user does not exist
*/
public function testGetAvatarInvalidUser() {

@ -1,5 +1,4 @@
<?php
/**
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
* This file is licensed under the Affero General Public License version 3 or
@ -7,23 +6,25 @@
* See the COPYING-README file.
*/
namespace Test;
use OCP\Files\Folder;
class AvatarTest extends \Test\TestCase {
/** @var Folder | PHPUnit_Framework_MockObject_MockObject */
/** @var Folder | \PHPUnit_Framework_MockObject_MockObject */
private $folder;
/** @var \OC\Avatar */
private $avatar;
/** @var \OC\User\User | PHPUnit_Framework_MockObject_MockObject $user */
/** @var \OC\User\User | \PHPUnit_Framework_MockObject_MockObject $user */
private $user;
public function setUp() {
parent::setUp();
$this->folder = $this->getMock('\OCP\Files\Folder');
/** @var \OCP\IL10N | PHPUnit_Framework_MockObject_MockObject $l */
/** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
$l = $this->getMock('\OCP\IL10N');
$l->method('t')->will($this->returnArgument(0));
$this->user = $this->getMockBuilder('\OC\User\User')->disableOriginalConstructor()->getMock();
@ -41,7 +42,7 @@ class AvatarTest extends \Test\TestCase {
['avatar.128.jpg', true],
]));
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$file = $this->getMock('\OCP\Files\File');
$file->method('getContent')->willReturn($expected->data());
@ -56,7 +57,7 @@ class AvatarTest extends \Test\TestCase {
['avatar.jpg', true],
]));
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$file = $this->getMock('\OCP\Files\File');
$file->method('getContent')->willReturn($expected->data());
@ -72,8 +73,8 @@ class AvatarTest extends \Test\TestCase {
['avatar.32.png', false],
]));
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2 = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2 = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2->resize(32);
$file = $this->getMock('\OCP\Files\File');
@ -157,7 +158,7 @@ class AvatarTest extends \Test\TestCase {
->with('avatar.png')
->willReturn($newFile);
$image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$image = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$newFile->expects($this->once())
->method('putContent')
->with($image->data());

@ -1,5 +1,4 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
@ -7,14 +6,17 @@
* See the COPYING-README file.
*/
namespace Test\DB;
use OC_DB;
use OCP\Security\ISecureRandom;
/**
* Class Test_DBSchema
* Class DBSchemaTest
*
* @group DB
*/
class Test_DBSchema extends \Test\TestCase {
class DBSchemaTest extends \Test\TestCase {
protected $schema_file = 'static://test_db_scheme';
protected $schema_file2 = 'static://test_db_scheme2';
protected $table1;
@ -23,8 +25,8 @@ class Test_DBSchema extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
$dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml';
$dbfile = \OC::$SERVERROOT.'/tests/data/db_structure.xml';
$dbfile2 = \OC::$SERVERROOT.'/tests/data/db_structure2.xml';
$r = '_' . \OC::$server->getSecureRandom()->
generate(4, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS) . '_';

@ -6,12 +6,16 @@
* See the COPYING-README file.
*/
namespace Test\DB;
use OC_DB;
/**
* Class Test_DB
* Class LegacyDBTest
*
* @group DB
*/
class Test_DB extends \Test\TestCase {
class LegacyDBTest extends \Test\TestCase {
protected $backupGlobals = FALSE;
protected static $schema_file = 'static://test_db_scheme';
@ -45,7 +49,7 @@ class Test_DB extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$dbFile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
$dbFile = \OC::$SERVERROOT.'/tests/data/db_structure.xml';
$r = $this->getUniqueID('_', 4).'_';
$content = file_get_contents( $dbFile );
Loading…
Cancel
Save