Skip to content

Commit 900fe5d

Browse files
author
Sergiy Zhovnir
committed
#issue-198 Covered module view model class generator with test
1 parent 752496c commit 900fe5d

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Foo\Bar\ViewModel;
4+
5+
use Magento\Framework\View\Element\Block\ArgumentInterface;
6+
7+
class TestViewModel implements ArgumentInterface
8+
{
9+
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.magento.idea.magento2plugin.actions.generation.generator;
2+
3+
import com.intellij.openapi.project.Project;
4+
import com.intellij.psi.PsiFile;
5+
import com.magento.idea.magento2plugin.actions.generation.data.ViewModelFileData;
6+
7+
public class ModuleViewModelClassGeneratorTest extends BaseGeneratorTestCase {
8+
9+
public void testGenerateViewModelFile() {
10+
Project project = myFixture.getProject();
11+
12+
ViewModelFileData viewModelData = new ViewModelFileData(
13+
"ViewModel",
14+
"TestViewModel",
15+
"Foo_Bar",
16+
"Foo\\Bar\\ViewModel"
17+
);
18+
ModuleViewModelClassGenerator moduleViewModelClassGenerator = new ModuleViewModelClassGenerator(
19+
viewModelData,
20+
project
21+
);
22+
PsiFile viewModelFile = moduleViewModelClassGenerator.generate("test");
23+
24+
String filePath = this.getFixturePath("TestViewModel.php");
25+
PsiFile expectedFile = myFixture.configureByFile(filePath);
26+
27+
assertGeneratedFileIsCorrect(
28+
expectedFile,
29+
"src/app/code/Foo/Bar/ViewModel",
30+
viewModelFile
31+
);
32+
}
33+
}

0 commit comments

Comments
 (0)