L10N tests do not require DB

* Makes CI a bit more efficient
* Cleanup getMock warning
This commit is contained in:
Roeland Jago Douma 2016-08-25 22:37:14 +02:00
parent 680d7f22bb
commit c5bdb4d4e8
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
2 changed files with 16 additions and 8 deletions

View File

@ -15,7 +15,6 @@ use Test\TestCase;
* Class FactoryTest * Class FactoryTest
* *
* @package Test\L10N * @package Test\L10N
* @group DB
*/ */
class FactoryTest extends TestCase { class FactoryTest extends TestCase {
@ -44,7 +43,9 @@ class FactoryTest extends TestCase {
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->userSession = $this->getMock('\OCP\IUserSession'); $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->serverRoot = \OC::$SERVERROOT; $this->serverRoot = \OC::$SERVERROOT;
} }
@ -110,7 +111,8 @@ class FactoryTest extends TestCase {
->method('getSystemValue') ->method('getSystemValue')
->with('installed', false) ->with('installed', false)
->willReturn(true); ->willReturn(true);
$user = $this->getMock('\OCP\IUser'); $user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getUID') ->method('getUID')
->willReturn('MyUserUid'); ->willReturn('MyUserUid');
@ -143,7 +145,8 @@ class FactoryTest extends TestCase {
->method('getSystemValue') ->method('getSystemValue')
->with('installed', false) ->with('installed', false)
->willReturn(true); ->willReturn(true);
$user = $this->getMock('\OCP\IUser'); $user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getUID') ->method('getUID')
->willReturn('MyUserUid'); ->willReturn('MyUserUid');
@ -185,7 +188,8 @@ class FactoryTest extends TestCase {
->method('getSystemValue') ->method('getSystemValue')
->with('installed', false) ->with('installed', false)
->willReturn(true); ->willReturn(true);
$user = $this->getMock('\OCP\IUser'); $user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getUID') ->method('getUID')
->willReturn('MyUserUid'); ->willReturn('MyUserUid');
@ -230,7 +234,8 @@ class FactoryTest extends TestCase {
->method('getSystemValue') ->method('getSystemValue')
->with('installed', false) ->with('installed', false)
->willReturn(true); ->willReturn(true);
$user = $this->getMock('\OCP\IUser'); $user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getUID') ->method('getUID')
->willReturn('MyUserUid'); ->willReturn('MyUserUid');

View File

@ -14,7 +14,6 @@ use DateTime;
/** /**
* Class Test_L10n * Class Test_L10n
* @group DB
*/ */
class L10nLegacyTest extends \Test\TestCase { class L10nLegacyTest extends \Test\TestCase {
@ -124,7 +123,11 @@ class L10nLegacyTest extends \Test\TestCase {
} }
public function testFactoryGetLanguageCode() { public function testFactoryGetLanguageCode() {
$factory = new \OC\L10N\Factory($this->getMock('OCP\IConfig'), $this->getMock('OCP\IRequest'), $this->getMock('OCP\IUserSession'), \OC::$SERVERROOT); $factory = new \OC\L10N\Factory(
$this->getMockBuilder('OCP\IConfig')->getMock(),
$this->getMockBuilder('OCP\IRequest')->getMock(),
$this->getMockBuilder('OCP\IUserSession')->getMock(),
\OC::$SERVERROOT);
$l = $factory->get('lib', 'de'); $l = $factory->get('lib', 'de');
$this->assertEquals('de', $l->getLanguageCode()); $this->assertEquals('de', $l->getLanguageCode());
} }