6 use Drupal\Core\Extension\ExtensionList;
7 use PHPUnit\Framework\TestCase;
21 $module = $this->getMockBuilder(ExtensionList::class)
22 ->setMethods([
'getPathname'])
23 ->disableOriginalConstructor()
24 ->getMockForAbstractClass();
26 $module->method(
"getPathname")->willReturn(
"./tmp");
29 $dir = $retriever->getSchemaDirectory();
30 $this->assertEquals($dir,
'./schema');
37 $module = $this->getMockBuilder(ExtensionList::class)
38 ->setMethods([
'getPathname'])
39 ->disableOriginalConstructor()
40 ->getMockForAbstractClass();
42 $module->method(
"getPathname")->willReturn(
"./tmp");
45 $ids = $retriever->getAllIds();
46 $this->assertEquals([
'catalog',
'dataset',
'dataset.ui'], $ids);
53 $module = $this->getMockBuilder(ExtensionList::class)
54 ->setMethods([
'getPathname'])
55 ->disableOriginalConstructor()
56 ->getMockForAbstractClass();
58 $module->method(
"getPathname")->willReturn(
"./tmp");
61 $schema = $retriever->retrieve(
'dataset');
62 $json = json_decode($schema);
63 $this->assertNotFalse($json);
70 $this->expectExceptionMessage(
"Schema blah not found.");
71 $module = $this->getMockBuilder(ExtensionList::class)
72 ->setMethods([
'getPathname'])
73 ->disableOriginalConstructor()
74 ->getMockForAbstractClass();
76 $module->method(
"getPathname")->willReturn(
"./tmp");
79 $retriever->retrieve(
'blah');
86 $this->expectExceptionMessage(
"No schema directory found.");
87 $module = $this->getMockBuilder(ExtensionList::class)
88 ->setMethods([
'getPathname'])
89 ->disableOriginalConstructor()
90 ->getMockForAbstractClass();
92 $module->method(
"getPathname")->willReturn(
"/abcd");
95 $retriever->retrieve(
'dataset');