-
Notifications
You must be signed in to change notification settings - Fork 1
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 #101 from tr33m4n/feature/add-send-later
Add ability to send snapshots after a test suite has run
- Loading branch information
Showing
25 changed files
with
800 additions
and
582 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
This file was deleted.
Oops, something went wrong.
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,79 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Codeception\Module\Percy\Command; | ||
|
||
use Codeception\CustomCommandInterface; | ||
use Codeception\Lib\Console\Output; | ||
use Codeception\Module\Percy\Definitions; | ||
use Codeception\Module\Percy\ServiceContainer; | ||
use Codeception\Module\Percy\SnapshotManagement; | ||
use Codeception\Util\Debug; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
class ProcessSnapshots extends Command implements CustomCommandInterface | ||
{ | ||
private SnapshotManagement $snapshotManagement; | ||
|
||
/** | ||
* ProcessSnapshots constructor. | ||
* | ||
* @param string|null $name | ||
*/ | ||
public function __construct( | ||
string $name = null | ||
) { | ||
$serviceContainer = new ServiceContainer(null, Definitions::DEFAULT_CONFIG); | ||
$this->snapshotManagement = $serviceContainer->getSnapshotManagement(); | ||
|
||
parent::__construct($name); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function getCommandName(): string | ||
{ | ||
return 'percy:process-snapshots'; | ||
} | ||
|
||
/** | ||
* Get default description | ||
* | ||
* @return string | ||
*/ | ||
public static function getDefaultDescription(): string | ||
{ | ||
return 'Process any snapshots that exist in the snapshot directory, then cleanup'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* Process snapshots | ||
* | ||
* @throws \Codeception\Module\Percy\Exception\AdapterException | ||
* @throws \Codeception\Module\Percy\Exception\ConfigException | ||
* @throws \Codeception\Module\Percy\Exception\StorageException | ||
* @throws \JsonException | ||
* @param \Symfony\Component\Console\Input\InputInterface $input | ||
* @param \Symfony\Component\Console\Output\OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
Debug::setOutput(new Output([])); | ||
|
||
$this->snapshotManagement->sendAll(); | ||
$this->snapshotManagement->resetAll(); | ||
|
||
$io->success('Successfully processed snapshots'); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
Oops, something went wrong.