File tree 3 files changed +27
-4
lines changed
src/PhpStormMetaGenerator
3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ $entitiesPath = CMS_FOLDER . 'modules';
31
31
$adminEntitiesPath = CMS_FOLDER . 'adminentities';
32
32
33
33
$metaGenerator = new MetaGenerator($phpStormMetaFilePath);
34
- $metaGenerator->addDriver(new EntitiesDriver ($entitiesPath)) // Add entities driver
35
- ->addDriver(new AdminEntitiesDriver ($adminEntitiesPath)) // Add admin-entities driver
34
+ $metaGenerator->addDriver(new DriverEntities ($entitiesPath)) // Add entities driver
35
+ ->addDriver(new DriverAdminEntities ($adminEntitiesPath)) // Add admin-entities driver
36
36
->scan()
37
37
->printFile();
38
38
```
Original file line number Diff line number Diff line change @@ -114,8 +114,12 @@ public function render()
114
114
*/
115
115
public function setMetaFilePath ($ metaFilePath )
116
116
{
117
+ if (!is_string ($ metaFilePath )) {
118
+ throw new InvalidArgumentException ('Meta-file path must be a string. ' );
119
+ }
120
+
117
121
$ dirName = dirname ($ metaFilePath );
118
- if (!file_exists ( $ dirName ) || ! is_dir ($ dirName )) {
122
+ if (!is_dir ($ dirName )) {
119
123
throw new InvalidArgumentException ('Invalid file path. ' );
120
124
}
121
125
Original file line number Diff line number Diff line change @@ -22,9 +22,19 @@ public function testMetaFilePath()
22
22
$ this ->assertEquals ($ metaGenerator ->getMetaFilePath (), 'path1 ' );
23
23
$ metaGenerator ->setMetaFilePath ('path2 ' );
24
24
$ this ->assertEquals ($ metaGenerator ->getMetaFilePath (), 'path2 ' );
25
+
26
+ $ throw = false ;
27
+ try {
28
+ $ metaGenerator ->setMetaFilePath (1 );
29
+ } catch (InvalidArgumentException $ e ) {
30
+ $ throw = true ;
31
+ }
32
+ if (!$ throw ) {
33
+ $ this ->fail ('Set meta-file path exception is not thrown. ' );
34
+ }
25
35
}
26
36
27
- public function testNamespaces ()
37
+ public function testDrivers ()
28
38
{
29
39
$ metaGenerator = new MetaGenerator ($ this ->metaFilePath );
30
40
$ this ->assertTrue (empty ($ metaGenerator ->getDrivers ()));
@@ -39,4 +49,13 @@ public function testNamespaces()
39
49
$ this ->assertSame ($ metaGenerator ->getDrivers ()[1 ], $ secondDriver );
40
50
}
41
51
52
+ public function testScan ()
53
+ {
54
+ $ metaGenerator = new MetaGenerator ($ this ->metaFilePath );
55
+ $ metaGenerator ->addDriver (new DriverEntities ($ this ->entitiesRoot ))
56
+ ->addDriver (new DriverAdminEntities ($ this ->adminEntitiesRoot ));
57
+ $ this ->assertSame ($ metaGenerator ->scan (), $ metaGenerator );
58
+ $ this ->assertEquals ($ metaGenerator ->get (), file_get_contents (__DIR__ . '/data/hostcms/.phpstorm.meta.php ' ));
59
+ }
60
+
42
61
}
You can’t perform that action at this time.
0 commit comments