Skip to content

Commit

Permalink
fixup! feat: add internal addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Aug 12, 2024
1 parent 17c108d commit a81e7bb
Showing 1 changed file with 23 additions and 40 deletions.
63 changes: 23 additions & 40 deletions tests/Integration/Db/InternalAddressMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,45 +185,28 @@ public function testRemoveDomain(): void {
$this->assertEmpty($rows);
}

/* public function testFindAll(): void {
public function testFindAll(): void {
$uid = $this->user->getUID();
$qb = $this->db->getQueryBuilder();
$qb->i('mail_internal_address')
->values([
'user_id' => $qb->createNamedParameter($uid),
'address' => $qb->createNamedParameter('[email protected]'),
'type' => $qb->createNamedParameter('individual'),
],
)->insert('mail_internal_address')
->values([
'user_id' => $qb->createNamedParameter($uid),
'address' => $qb->createNamedParameter('[email protected]'),
'type' => $qb->createNamedParameter('individual'),
])
->executeStatement();
$result = $qb->executeQuery();
$result->closeCursor();
$rows = $this->mapper->findAll($uid);
$this->assertCount(2, $rows);
$resultArray = [];
foreach ($rows as $row) {
$resultArray[] = $row->jsonSerialize();
}
$expected = [
[
'id' => 1,
'user_id' => $uid,
'address' => '[email protected]',
'type' => 'individual',
],
[
'id' => 2,
'user_id' => $uid,
'address' => '[email protected]',
'type' => 'individual',
],
];
$this->assertEquals($expected, $resultArray);
}*/

$this->db->beginTransaction();

$data = [
['user_id' => $uid, 'address' => '[email protected]', 'type' => 'individual'],
['user_id' => $uid, 'address' => '[email protected]', 'type' => 'individual'],
];
$sql = 'INSERT INTO oc_mail_internal_address (user_id, address, type) VALUES (:user_id, :address, :type)';
$stmt = $this->db->prepare($sql);

foreach ($data as $row) {
$stmt->execute($row);
}

$this->db->commit();

$results = $this->mapper->findAll($uid);

$this->assertCount(2, $results);
$this->assertEquals($results[0]->getAddress(), '[email protected]');
$this->assertEquals($results[1]->getAddress(), '[email protected]');
}
}

0 comments on commit a81e7bb

Please sign in to comment.