This repository was archived by the owner on May 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ public function listShares() {
153153 * @return \Icewind\SMB\IShare
154154 */
155155 public function getShare ($ name ) {
156- return new Share ($ this , $ name );
156+ return new Share ($ this , $ name, $ this -> system );
157157 }
158158
159159 /**
Original file line number Diff line number Diff line change @@ -43,17 +43,22 @@ class Share extends AbstractShare {
4343 /**
4444 * @param Server $server
4545 * @param string $name
46+ * @param System $system
4647 */
47- public function __construct ($ server , $ name ) {
48+ public function __construct ($ server , $ name, System $ system = null ) {
4849 parent ::__construct ();
4950 $ this ->server = $ server ;
5051 $ this ->name = $ name ;
51- $ this ->system = new System ();
52+ $ this ->system = (! is_null ( $ system )) ? $ system : new System ();
5253 $ this ->parser = new Parser (new TimeZoneProvider ($ this ->server ->getHost (), $ this ->system ));
5354 }
5455
5556 protected function getConnection () {
5657 $ workgroupArgument = ($ this ->server ->getWorkgroup ()) ? ' -W ' . escapeshellarg ($ this ->server ->getWorkgroup ()) : '' ;
58+ $ smbClientPath = $ this ->system ->getSmbclientPath ();
59+ if (!$ smbClientPath ) {
60+ throw new DependencyException ('Can \'t find smbclient binary in path ' );
61+ }
5762 $ command = sprintf ('%s%s %s --authentication-file=%s %s ' ,
5863 $ this ->system ->hasStdBuf () ? 'stdbuf -o0 ' : '' ,
5964 $ this ->system ->getSmbclientPath (),
Original file line number Diff line number Diff line change @@ -33,4 +33,20 @@ public function testHostEscape() {
3333 $ share = $ this ->server ->getShare ($ this ->config ->share );
3434 $ share ->dir ($ this ->root );
3535 }
36+
37+ /**
38+ * @expectedException \Icewind\SMB\Exception\DependencyException
39+ */
40+ public function testNoSmbclient () {
41+ $ system = $ this ->getMockBuilder ('\Icewind\SMB\System ' )
42+ ->setMethods (['getSmbclientPath ' ])
43+ ->getMock ();
44+ $ share = new \Icewind \SMB \Share ($ this ->server , 'dummy ' , $ system );
45+
46+ $ system ->expects ($ this ->any ())
47+ ->method ('getSmbclientPath ' )
48+ ->will ($ this ->returnValue ('' ));
49+
50+ $ share ->mkdir ('' );
51+ }
3652}
You can’t perform that action at this time.
0 commit comments