summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-01-26 18:48:36 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-01-26 18:48:36 +0000
commit0010d42b5dcc725e166945c3345a365d5aa115e3 (patch)
tree002771da07ff631c6cd89e3dab4c29503ae4b04f
parent244d9cdf63f2f748f6ceff25362d9fa20df4056f (diff)
downloadwebtrees-0010d42b5dcc725e166945c3345a365d5aa115e3.tar.gz
webtrees-0010d42b5dcc725e166945c3345a365d5aa115e3.tar.bz2
webtrees-0010d42b5dcc725e166945c3345a365d5aa115e3.zip
Tests
-rw-r--r--tests/app/ModuleTest.php52
-rw-r--r--tests/app/Services/SearchServiceTest.php22
2 files changed, 59 insertions, 15 deletions
diff --git a/tests/app/ModuleTest.php b/tests/app/ModuleTest.php
index a4fc138ca6..f47481b231 100644
--- a/tests/app/ModuleTest.php
+++ b/tests/app/ModuleTest.php
@@ -17,18 +17,62 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees;
+use Fisharebest\Webtrees\Module\ModuleBlockInterface;
+use Fisharebest\Webtrees\Module\ModuleChartInterface;
+use Fisharebest\Webtrees\Module\ModuleConfigInterface;
+use Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface;
+use Fisharebest\Webtrees\Module\ModuleMenuInterface;
+use Fisharebest\Webtrees\Module\ModuleReportInterface;
+use Fisharebest\Webtrees\Module\ModuleSidebarInterface;
+use Fisharebest\Webtrees\Module\ModuleThemeInterface;
+
/**
- * Test harness for the class Module
+ * Test the modules
+ *
+ * @coversNothing
*/
class ModuleTest extends \Fisharebest\Webtrees\TestCase
{
+ protected static $uses_database = true;
+
+ /**
+ * @covers \Fisharebest\Webtrees\Module::findByComponent
+ *
+ * @return void
+ */
+ public function testFindByComponent(): void
+ {
+ $tree = $this->importTree('demo.ged');
+ $user = User::create('UserName', 'RealName', 'user@example.com', 'secret');
+
+ $this->assertNotEmpty(Module::findByComponent('block', $tree, $user)->all());
+ $this->assertNotEmpty(Module::findByComponent('chart', $tree, $user)->all());
+ $this->assertNotEmpty(Module::findByComponent('menu', $tree, $user)->all());
+ $this->assertNotEmpty(Module::findByComponent('report', $tree, $user)->all());
+ $this->assertNotEmpty(Module::findByComponent('sidebar', $tree, $user)->all());
+ $this->assertNotEmpty(Module::findByComponent('tab', $tree, $user)->all());
+ }
+
/**
- * Test that the class exists
+ * @covers \Fisharebest\Webtrees\Module::findByInterface
*
* @return void
*/
- public function testClassExists(): void
+ public function testFindByInterface(): void
{
- $this->assertTrue(class_exists('\Fisharebest\Webtrees\Module'));
+ $tree = $this->importTree('demo.ged');
+ $user = User::create('UserName', 'RealName', 'user@example.com', 'secret');
+
+ $this->assertNotEmpty(Module::findByInterface(ModuleBlockInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleChartInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleConfigInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleMenuInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleReportInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleReportInterface::class)->all());
+ $this->assertNotEmpty(Module::findByInterface(ModuleSidebarInterface::class)->all());
+
+ // THe core modules do not contain any of these.
+ $this->assertEmpty(Module::findByInterface(ModuleHistoricEventsInterface::class)->all());
+ $this->assertEmpty(Module::findByInterface(ModuleThemeInterface::class)->all());
}
}
diff --git a/tests/app/Services/SearchServiceTest.php b/tests/app/Services/SearchServiceTest.php
index 75e5386da4..1ffb6ad309 100644
--- a/tests/app/Services/SearchServiceTest.php
+++ b/tests/app/Services/SearchServiceTest.php
@@ -39,36 +39,36 @@ class SearchServiceTest extends TestCase
$tree = $this->importTree('demo.ged');
$result = $search_service->searchFamilies([$tree], ['windsor']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchFamilyNames([$tree], ['charles', 'diana']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchIndividuals([$tree], ['windsor']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchIndividualNames([$tree], ['windsor']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchMedia([$tree], ['windsor']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchNotes([$tree], ['windsor']);
- $this->assertFalse($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchRepositories([$tree], ['national']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchSources([$tree], ['england']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchSourcesByName([$tree], ['england']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchSubmitters([$tree], ['greg']);
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
$result = $search_service->searchPlaces($tree, 'England');
- $this->assertTrue($result->isNotEmpty());
+ $this->assertInstanceOf(Collection::class, $result);
}
}