1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Tahaa Karim <[email protected]> |
5
|
|
|
* |
6
|
|
|
* ownCloud - Mail |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Mail\Db; |
23
|
|
|
|
24
|
|
|
use OC\AppFramework\Db\Db; |
25
|
|
|
|
26
|
|
|
class AliasMapperTest extends \PHPUnit_Framework_TestCase { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var AliasMapper |
30
|
|
|
*/ |
31
|
|
|
private $mapper; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var \OC\DB\Connection |
35
|
|
|
*/ |
36
|
|
|
private $db; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Alias |
40
|
|
|
*/ |
41
|
|
|
private $alias; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Initialize Mapper |
45
|
|
|
*/ |
46
|
|
|
public function setup(){ |
47
|
|
|
$db = \OC::$server->getDatabaseConnection(); |
48
|
|
|
$this->db = new Db($db); |
|
|
|
|
49
|
|
|
$this->mapper = new AliasMapper($this->db); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testFind(){ |
53
|
|
|
|
54
|
|
|
$this->alias = new Alias(); |
55
|
|
|
$this->alias->setAccountId(1); |
56
|
|
|
$this->alias->setAlias('[email protected]'); |
57
|
|
|
$this->alias->setName('alias'); |
58
|
|
|
|
59
|
|
|
/** @var Alias $b */ |
60
|
|
|
$b = $this->mapper->insert($this->alias); |
61
|
|
|
|
62
|
|
|
$result = $this->mapper->find($b->getId(), 'user12345'); |
63
|
|
|
|
64
|
|
|
$this->assertEquals($b, $result); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
View Code Duplication |
protected function tearDown() { |
|
|
|
|
68
|
|
|
parent::tearDown(); |
69
|
|
|
|
70
|
|
|
$sql = 'DELETE FROM *PREFIX*mail_aliases WHERE `id` = ?'; |
71
|
|
|
$stmt = $this->db->prepare($sql); |
72
|
|
|
if (!empty($this->alias)) { |
73
|
|
|
$stmt->execute([$this->alias->getId()]); |
74
|
|
|
} |
75
|
|
|
if (!empty($this->address2)) { |
76
|
|
|
$stmt->execute([$this->alias->getId()]); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..