Skip to content

Commit

Permalink
tests: Avoid using dynamic properties
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Nov 23, 2023
1 parent 974c7f8 commit 7fad13b
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/unit/Activity/CommentEventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CommentEventHandlerTest extends TestCase {
private $activityManager;
/** @var NotificationHelper */
private $notificationHelper;
/** @var ChangeHelper */
private $changeHelper;
/** @var CardMapper */
private $cardMapper;

Expand Down
8 changes: 6 additions & 2 deletions tests/unit/Activity/DeckProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class DeckProviderTest extends TestCase {

/** @var DeckProvider */
private $provider;

/** @var IL10N */
private $l10n;

/** @var IURLGenerator|MockObject */
private $urlGenerator;

Expand All @@ -57,6 +59,9 @@ class DeckProviderTest extends TestCase {
/** @var ICommentsManager|MockObject */
private $commentsManager;

private $l10nFactory;
private $config;

/** @var CardService|MockObject */
private $cardService;

Expand All @@ -71,7 +76,6 @@ public function setUp(): void {
$this->commentsManager = $this->createMock(ICommentsManager::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->config = $this->createMock(IConfig::class);
$this->config = $this->createMock(IConfig::class);
$this->cardService = $this->createMock(CardService::class);
$this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->l10nFactory, $this->config, $this->userId, $this->cardService);
}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Db/BoardMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BoardMapperTest extends TestCase {

/** @var IDBConnection */
private $dbConnection;
private $labelMapper;
/** @var AclMapper|\PHPUnit\Framework\MockObject\MockObject */
private $aclMapper;
/** @var BoardMapper */
Expand Down
12 changes: 8 additions & 4 deletions tests/unit/Db/RelationalEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@

namespace OCA\Deck\Db;

class MyRelationalEntity extends RelationalEntity {
protected $foo;
}

class RelationalEntityTest extends \Test\TestCase {
public function testRelation() {
$entity = new RelationalEntity();
$entity->foo = null;
$entity = new MyRelationalEntity();
$entity->setFoo(null);
$entity->addRelation('foo');
$entity->setFoo('test');
$this->assertEquals([], $entity->getUpdatedFields());
}

public function testWithoutRelation() {
$entity = new RelationalEntity();
$entity->foo = null;
$entity = new MyRelationalEntity();
$entity->setFoo(null);
$entity->setFoo('test');
$this->assertEquals(['foo' => true], $entity->getUpdatedFields());
}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Middleware/ExceptionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ExceptionMiddlewareTest extends \Test\TestCase {
private $logger;
/** @var IConfig */
private $config;
private $request;
private $controller;
private $exceptionMiddleware;

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/Reference/CardReferenceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
use Test\TestCase;

class CardReferenceProviderTest extends TestCase {
private $cardService;
private $boardService;
private $stackService;
private $urlGenerator;
private $l10n;
private $userId;
private $provider;

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

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Service/BoardServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class BoardServiceTest extends TestCase {

/** @var BoardService */
private $service;
/** @var IConfig */
private $config;
/** @var L10N */
private $l10n;
/** @var LabelMapper */
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Service/PermissionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

class PermissionServiceTest extends \Test\TestCase {

/** @var IRequest */
private $request;
private $circlesService;
/** @var PermissionService*/
private $service;
/** @var ILogger */
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controller/BoardApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

class BoardApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $request;
private $userId = 'admin';
private $controller;
private $boardService;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controller/BoardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCP\IUser;

class BoardControllerTest extends \Test\TestCase {
private $l10n;
private $controller;
private $request;
private $userManager;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controller/BoardImportApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

class BoardImportApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $request;
private $userId = 'admin';
/** @var BoardImportApiController */
private $controller;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/controller/StackApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

class StackApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $request;
private $userId = 'admin';
private $controller;
private $boardService;
Expand Down

0 comments on commit 7fad13b

Please sign in to comment.