Skip to content

Commit

Permalink
Tests: Add lazy-accessor for MongoDB
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Dec 26, 2020
1 parent 6c8c186 commit feec5ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/LazyContainerProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace XHGui\Test;

use LazyProperty\LazyPropertiesTrait;
use MongoDB;
use Slim\Slim as App;
use Slim\View;
use XHGui\Controller\ImportController;
Expand All @@ -24,6 +25,8 @@ trait LazyContainerProperties
protected $import;
/** @var MongoSearcher */
private $mongo;
/** @var MongoDB */
protected $mongodb;
/** @var RunController */
protected $runs;
/** @var App */
Expand All @@ -44,6 +47,7 @@ protected function setupProperties(): void
'app',
'import',
'mongo',
'mongodb',
'runs',
'saver',
'searcher',
Expand Down Expand Up @@ -90,6 +94,11 @@ protected function getMongo()
return $this->di['searcher.mongodb'];
}

protected function getMongoDb()
{
return $this->di[MongoDB::class];
}

protected function getSearcher()
{
return $this->di['searcher'];
Expand Down
4 changes: 2 additions & 2 deletions tests/Searcher/MongoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function testSaveRemove(): void

public function testTruncateResultsPreserveIndexes(): void
{
$mongoDb = $this->getDi()[MongoDB::class];
$mongoDb = $this->mongodb;
$collection = $mongoDb->results;

// dropping "results" collection using raw client
Expand Down Expand Up @@ -252,7 +252,7 @@ public function testTruncateResultsPreserveIndexes(): void

public function testTruncateWatchesPreserveIndexes(): void
{
$mongoDb = $this->getDi()[MongoDB::class];
$mongoDb = $this->mongodb;
$collection = $mongoDb->watches;

// dropping "watches" collection using raw client
Expand Down

0 comments on commit feec5ad

Please sign in to comment.