Skip to content

Commit 9161f6c

Browse files
juliusknorrMichaIng
authored andcommitted
Remove tests that just prove mocked calls and don't actually validate anything useful
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 1e266e8 commit 9161f6c

File tree

2 files changed

+0
-82
lines changed

2 files changed

+0
-82
lines changed

tests/lib/Security/CredentialsManagerTest.php

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -24,92 +24,11 @@
2424

2525
namespace Test\Security;
2626

27-
use OC\Security\CredentialsManager;
28-
use OCP\DB\IResult;
29-
use OCP\DB\QueryBuilder\IExpressionBuilder;
30-
use OCP\DB\QueryBuilder\IQueryBuilder;
31-
use OCP\IDBConnection;
32-
use OCP\Security\ICrypto;
33-
3427
/**
3528
* @group DB
3629
*/
3730
class CredentialsManagerTest extends \Test\TestCase {
3831

39-
/** @var ICrypto */
40-
protected $crypto;
41-
42-
/** @var IDBConnection */
43-
protected $dbConnection;
44-
45-
/** @var CredentialsManager */
46-
protected $manager;
47-
48-
protected function setUp(): void {
49-
parent::setUp();
50-
$this->crypto = $this->createMock(ICrypto::class);
51-
$this->dbConnection = $this->getMockBuilder(IDBConnection::class)
52-
->disableOriginalConstructor()
53-
->getMock();
54-
$this->manager = new CredentialsManager($this->crypto, $this->dbConnection);
55-
}
56-
57-
private function getQueryResult($row) {
58-
$result = $this->createMock(IResult::class);
59-
60-
$result->expects($this->any())
61-
->method('fetch')
62-
->willReturn($row);
63-
64-
return $result;
65-
}
66-
67-
public function testStore() {
68-
$userId = 'abc';
69-
$identifier = 'foo';
70-
$credentials = 'bar';
71-
72-
$this->crypto->expects($this->once())
73-
->method('encrypt')
74-
->with(json_encode($credentials))
75-
->willReturn('baz');
76-
77-
$this->dbConnection->expects($this->once())
78-
->method('setValues')
79-
->with(CredentialsManager::DB_TABLE,
80-
['user' => $userId, 'identifier' => $identifier],
81-
['credentials' => 'baz']
82-
);
83-
84-
$this->manager->store($userId, $identifier, $credentials);
85-
}
86-
87-
public function testRetrieve() {
88-
$userId = 'abc';
89-
$identifier = 'foo';
90-
91-
$this->crypto->expects($this->once())
92-
->method('decrypt')
93-
->with('baz')
94-
->willReturn(json_encode('bar'));
95-
96-
$eb = $this->createMock(IExpressionBuilder::class);
97-
$qb = $this->createMock(IQueryBuilder::class);
98-
$qb->method('select')->willReturnSelf();
99-
$qb->method('from')->willReturnSelf();
100-
$qb->method('where')->willReturnSelf();
101-
$qb->method('expr')->willReturn($eb);
102-
$qb->expects($this->once())
103-
->method('execute')
104-
->willReturn($this->getQueryResult(['credentials' => 'baz']));
105-
106-
$this->dbConnection->expects($this->once())
107-
->method('getQueryBuilder')
108-
->willReturn($qb);
109-
110-
$this->manager->retrieve($userId, $identifier);
111-
}
112-
11332
/**
11433
* @dataProvider credentialsProvider
11534
*/

tests/lib/TestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use OCP\IDBConnection;
3434
use OCP\IL10N;
3535
use OCP\Security\ISecureRandom;
36-
use PHPUnit\Util\Test;
3736

3837
abstract class TestCase extends \PHPUnit\Framework\TestCase {
3938
/** @var \OC\Command\QueueBus */

0 commit comments

Comments
 (0)