8 use \Magento\Framework\Module\ModuleList;
17 private static $allFixture = [
'foo' => [
'key' =>
'value'],
'bar' => [
'another' =>
'value']];
24 private static $enabledFixture = [
'foo' => 1,
'bar' => 0];
43 $this->config = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
44 $this->loader = $this->createMock(\
Magento\Framework\Module\
ModuleList\Loader::class);
45 $this->model =
new ModuleList($this->config, $this->loader);
50 $this->config->expects($this->exactly(2))->method(
'resetData');
51 $this->setLoadAllExpectation();
52 $this->setLoadConfigExpectation();
53 $expected = [
'foo' => self::$allFixture[
'foo']];
54 $this->assertSame($expected, $this->model->getAll());
55 $this->assertSame($expected, $this->model->getAll());
60 $this->loader->expects($this->exactly(2))->method(
'load')->willReturn([]);
61 $this->setLoadConfigExpectation(
false);
62 $this->assertEquals([], $this->model->getAll());
63 $this->assertEquals([], $this->model->getAll());
68 $this->config->expects($this->exactly(2))->method(
'resetData');
69 $this->setLoadAllExpectation();
70 $this->setLoadConfigExpectation();
71 $this->assertSame([
'key' =>
'value'], $this->model->getOne(
'foo'));
72 $this->assertNull($this->model->getOne(
'bar'));
77 $this->config->expects($this->exactly(2))->method(
'resetData');
78 $this->setLoadAllExpectation(
false);
79 $this->setLoadConfigExpectation();
80 $this->assertSame([
'foo'], $this->model->getNames());
81 $this->assertSame([
'foo'], $this->model->getNames());
86 $this->config->expects($this->exactly(2))->method(
'resetData');
87 $this->setLoadAllExpectation(
false);
88 $this->setLoadConfigExpectation();
89 $this->assertTrue($this->model->has(
'foo'));
90 $this->assertFalse($this->model->has(
'bar'));
95 $this->config->expects($this->once())->method(
'resetData');
96 $this->setLoadConfigExpectation(
true);
97 $this->assertTrue($this->model->isModuleInfoAvailable());
102 $this->config->expects($this->at(0))->method(
'get')->willReturn([
'modules' =>
'testModule']);
103 $this->config->expects($this->at(1))->method(
'get')->willReturn(
null);
104 $this->assertFalse($this->model->isModuleInfoAvailable());
113 private function setLoadConfigExpectation($isExpected =
true)
116 $this->config->expects($this->exactly(2))->method(
'get')->willReturn(self::$enabledFixture);
118 $this->config->expects($this->never())->method(
'get');
128 private function setLoadAllExpectation($isExpected =
true)
131 $this->loader->expects($this->once())->method(
'load')->willReturn(self::$allFixture);
133 $this->loader->expects($this->never())->method(
'load');
testIsModuleInfoAvailable()
testIsModuleInfoAvailableNoConfig()