Skip to content

Commit

Permalink
fix account mapper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
butonic committed Jun 1, 2017
1 parent 2eb7880 commit 5b85e52
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/lib/User/AccountMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OC\User\Account;
use OC\User\AccountMapper;
use OC\User\AccountTermMapper;
use OCP\IConfig;
use OCP\IDBConnection;
use Test\TestCase;

Expand All @@ -37,13 +38,13 @@
*/
class AccountMapperTest extends TestCase {

/**
* @var IDBConnection
*/
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
protected $config;

/** @var IDBConnection */
protected $connection;
/**
* @var AccountMapper
*/

/** @var AccountMapper */
protected $mapper;

public static function setUpBeforeClass() {
Expand Down Expand Up @@ -76,8 +77,16 @@ public static function setUpBeforeClass() {

public function setUp() {
parent::setUp();

$this->config = $this->createMock(IConfig::class);

$this->connection = \OC::$server->getDatabaseConnection();
$this->mapper = new AccountMapper($this->connection, new AccountTermMapper($this->connection));

$this->mapper = new AccountMapper(
$this->config,
$this->connection,
new AccountTermMapper($this->connection)
);
}

public static function tearDownAfterClass () {
Expand All @@ -91,7 +100,6 @@ public static function tearDownAfterClass () {
public function testFindAll() {
$result = $this->mapper->find("testfind");
$this->assertEquals(4, count($result));

}

/**
Expand All @@ -101,7 +109,6 @@ public function testFindByUserId() {
$result = $this->mapper->find("testfind1");
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind1", array_shift($result)->getUserId());

}

/**
Expand All @@ -111,7 +118,6 @@ public function testFindByDisplayName() {
$result = $this->mapper->find('test find 2');
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind2", array_shift($result)->getUserId());

}

/**
Expand All @@ -121,7 +127,6 @@ public function testFindByEmail() {
$result= $this->mapper->find('test3@find.tld');
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind3", array_shift($result)->getUserId());

}

/**
Expand All @@ -131,7 +136,6 @@ public function testFindBySearchTerm() {
$result = $this->mapper->find('term 4 b');
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind4", array_shift($result)->getUserId());

}

/**
Expand All @@ -143,6 +147,5 @@ public function testFindLimitAndOffset() {
//results are ordered by display name
$this->assertEquals("TestFind3", array_shift($result)->getUserId());
$this->assertEquals("TestFind4", array_shift($result)->getUserId());

}
}

0 comments on commit 5b85e52

Please sign in to comment.