File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,16 @@ class SearchEngines
4646 *
4747 * @param string|null $current Set the current search engine name or null to
4848 * use the default
49+ * @param array<string,string> $engines Custom search engines
4950 */
50- public function __construct (?string $ current = null )
51+ public function __construct (?string $ current = null , array $ engines = [] )
5152 {
5253 if (isset ($ current )) {
5354 $ this ->setCurrent ($ current );
5455 }
56+ if ($ engines ) {
57+ $ this ->setEngines ($ engines );
58+ }
5559 }
5660
5761 /**
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ public function testConstructor() : void
3030 {
3131 $ searchEngines = new SearchEngines ('bing ' );
3232 self ::assertSame ('bing ' , $ searchEngines ->getCurrent ());
33+ self ::assertArrayNotHasKey ('foo ' , $ searchEngines ->getEngines ());
34+ $ searchEngines = new SearchEngines (engines: ['foo ' => 'https://foo.com ' ]);
35+ self ::assertSame ('google ' , $ searchEngines ->getCurrent ());
36+ self ::assertArrayHasKey ('foo ' , $ searchEngines ->getEngines ());
3337 }
3438
3539 public function testGetEngines () : void
You can’t perform that action at this time.
0 commit comments