Commit fde2ae6 1 parent 3cebce5 commit fde2ae6 Copy full SHA for fde2ae6
File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,41 @@ class PageCommand extends GeneratorCommand
30
30
*/
31
31
protected $ type = 'Page ' ;
32
32
33
+ /**
34
+ * Build the class with the given name.
35
+ *
36
+ * @param string $name
37
+ * @return string
38
+ */
39
+ protected function buildClass ($ name )
40
+ {
41
+ $ result = parent ::buildClass ($ name );
42
+
43
+ $ pageName = $ this ->argument ('name ' );
44
+
45
+ $ baseClass = 'Tests\Browser\Pages\Page ' ;
46
+
47
+ if (! Str::contains ($ pageName , '/ ' ) && class_exists ($ baseClass )) {
48
+ return $ result ;
49
+ } elseif (! class_exists ($ baseClass )) {
50
+ $ baseClass = 'Laravel\Dusk\Page ' ;
51
+ }
52
+
53
+ $ lineEndingCount = [
54
+ "\r\n" => substr_count ($ result , "\r\n" ),
55
+ "\r" => substr_count ($ result , "\r" ),
56
+ "\n" => substr_count ($ result , "\n" ),
57
+ ];
58
+
59
+ $ eol = array_keys ($ lineEndingCount , max ($ lineEndingCount ))[0 ];
60
+
61
+ return str_replace (
62
+ 'use Laravel\Dusk\Browser; ' .$ eol ,
63
+ 'use Laravel\Dusk\Browser; ' .$ eol ."use {$ baseClass }; " .$ eol ,
64
+ $ result
65
+ );
66
+ }
67
+
33
68
/**
34
69
* Get the stub file for the generator.
35
70
*
You can’t perform that action at this time.
0 commit comments