Skip to content
Snippets Groups Projects
Commit 2d94d2e9 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #508 from owncloud/increase-test-coverage

testing findByUserId()
parents a3321b7f 374ab70c
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,9 @@ class MailAccount extends Entity{
public function __construct($params = array()) {
if (isset($params['accountId'])) {
$this->setId($params['accountId']);
}
if (isset($params['accountName'])) {
$this->setName($params['accountName']);
}
......
......@@ -64,6 +64,14 @@ class MailAccountMapperTest extends \PHPUnit_Framework_TestCase {
$result = $this->mapper->find($b->getUserId(), $b->getId());
$this->assertEquals($b->toJson(), $result->toJson());
$result = $this->mapper->findByUserId($b->getUserId());
$c = array_filter($result, function($a) use($b){
/** @var MailAccount $a */
return $a->getId() === $b->getId();
});
$c = array_pop($c);
$this->assertEquals($b->toJson(), $c->toJson());
}
public function testSave() {
......@@ -85,5 +93,4 @@ class MailAccountMapperTest extends \PHPUnit_Framework_TestCase {
$this->assertNotNull($b->getId());
$this->assertEquals($b->getId(), $c->getId());
}
}
......@@ -47,4 +47,24 @@ class TestMailAccount extends \PHPUnit_Framework_TestCase {
), $a->toJson());
}
public function testMailAccountConstruct() {
$expected = [
'accountId' => 12345,
'accountName' => 'Peter Parker',
'emailAddress' => 'peter.parker@marvel.com',
'imapHost' => 'mail.marvel.com',
'imapPort' => 159,
'imapUser' => 'spiderman',
'imapSslMode' => 'tls',
'smtpHost' => 'smtp.marvel.com',
'smtpPort' => 458,
'smtpUser' => 'spiderman',
'smtpSslMode' => 'ssl'
];
$a = new MailAccount($expected);
// TODO: fix inconsistency
$expected['name'] = $expected['accountName'];
unset($expected['accountName']);
$this->assertEquals($expected, $a->toJson());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment