-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #629 from tienvx/upload-command
Upload command
- Loading branch information
Showing
32 changed files
with
490 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Runner; | ||
|
||
use Facebook\WebDriver\Remote\LocalFileDetector; | ||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Command\CommandRunner; | ||
use Tienvx\Bundle\MbtBundle\Model\Model\Revision\CommandInterface; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class CustomCommandRunner extends CommandRunner | ||
{ | ||
public const UPLOAD = 'upload'; | ||
|
||
public function __construct(protected string $uploadDir) | ||
{ | ||
} | ||
|
||
public function getAllCommands(): array | ||
{ | ||
return [ | ||
self::UPLOAD, | ||
]; | ||
} | ||
|
||
public function getCommandsRequireTarget(): array | ||
{ | ||
return $this->getAllCommands(); | ||
} | ||
|
||
public function getCommandsRequireValue(): array | ||
{ | ||
return $this->getAllCommands(); | ||
} | ||
|
||
public function run(CommandInterface $command, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
switch ($command->getCommand()) { | ||
case self::UPLOAD: | ||
$driver | ||
->findElement($this->getSelector($command->getTarget())) | ||
->setFileDetector(new LocalFileDetector()) | ||
->sendKeys($this->getFilePath($command)); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
protected function getFilePath(CommandInterface $command): string | ||
{ | ||
return $this->uploadDir . DIRECTORY_SEPARATOR . (string) $command->getValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.