Skip to content

Commit

Permalink
Merge 41e8328 into 0cdea1e
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Jul 15, 2022
2 parents 0cdea1e + 41e8328 commit 765aa09
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 302 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/main.yml
Expand Up @@ -7,22 +7,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0']
name: PHP ${{ matrix.php-versions }}
php-versions: ['8.1']
dependency-versions: ['lowest', 'highest']
name: PHP ${{ matrix.php-versions }} with ${{ matrix.dependency-versions }} versions of Composer dependencies
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov
tools: phpstan, phpcs, php-cs-fixer:3, phpunit, composer:v2
#extensions: mbstring, intl
tools: phpstan, phpcs, php-cs-fixer:3

- name: Checkout
uses: actions/checkout@v2

- name: Install
run: composer install
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependency-versions }}

- name: Run PHP CS
run: phpcs --standard=PSR12 src tests
Expand All @@ -34,12 +36,12 @@ jobs:
run: phpstan analyse src tests

- name: Test & Generate Code Coverage
run: phpunit
run: ./vendor/bin/phpunit

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=clover.xml -v
if: matrix.php-versions == '8.0'
if: matrix.php-versions == '8.1'
16 changes: 8 additions & 8 deletions composer.json
Expand Up @@ -16,20 +16,20 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/orm": "^2.8",
"jmgq/a-star": "^2.1",
"php-webdriver/webdriver": "^1.11",
"symfony/config": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/expression-language": "^5.4",
"symfony/http-kernel": "^5.4",
"symfony/messenger": "^5.4",
"symfony/validator": "^5.4",
"symfony/config": "^6.1",
"symfony/dependency-injection": "^6.1",
"symfony/expression-language": "^6.1",
"symfony/http-kernel": "^6.1",
"symfony/messenger": "^6.1",
"symfony/validator": "^6.1",
"tienvx/single-color-petrinet": "^1.5",
"tienvx/assignments-evaluator-bundle": "^1.0"
"tienvx/assignments-evaluator-bundle": "^1.0.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand Down
5 changes: 5 additions & 0 deletions src/Command/CommandRunner.php
Expand Up @@ -58,4 +58,9 @@ protected function getSelect(WebDriverElement $element): WebDriverSelect
{
return new WebDriverSelect($element);
}

public function validateTarget(CommandInterface $command): bool
{
return $command->getTarget() && $this->isValidSelector($command->getTarget());
}
}
54 changes: 54 additions & 0 deletions src/Command/Runner/CustomCommandRunner.php
@@ -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();
}
}
5 changes: 0 additions & 5 deletions src/Command/Runner/KeyboardCommandRunner.php
Expand Up @@ -51,11 +51,6 @@ public function run(CommandInterface $command, ValuesInterface $values, RemoteWe
}
}

public function validateTarget(CommandInterface $command): bool
{
return $command->getTarget() && $this->isValidSelector($command->getTarget());
}

/**
* Don't allow to upload local file.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/Command/Runner/MouseCommandRunner.php
Expand Up @@ -219,11 +219,6 @@ public function run(CommandInterface $command, ValuesInterface $values, RemoteWe
}
}

public function validateTarget(CommandInterface $command): bool
{
return $command->getTarget() && $this->isValidSelector($command->getTarget());
}

protected function getPoint(string $target): WebDriverPoint
{
list($x, $y) = explode(',', $target);
Expand Down
5 changes: 0 additions & 5 deletions src/Command/Runner/WaitCommandRunner.php
Expand Up @@ -87,9 +87,4 @@ public function run(CommandInterface $command, ValuesInterface $values, RemoteWe
break;
}
}

public function validateTarget(CommandInterface $command): bool
{
return $command->getTarget() && $this->isValidSelector($command->getTarget());
}
}
71 changes: 23 additions & 48 deletions src/Entity/Bug.php
Expand Up @@ -12,69 +12,48 @@
use Tienvx\Bundle\MbtBundle\Model\ProgressInterface;
use Tienvx\Bundle\MbtBundle\Model\TaskInterface;
use Tienvx\Bundle\MbtBundle\Repository\BugRepository;
use Tienvx\Bundle\MbtBundle\ValueObject\Bug\Step;

/**
* @ORM\Entity(repositoryClass=BugRepository::class)
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity(repositoryClass: BugRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Bug extends BugModel
{
/**
* @ORM\Column(type="integer")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Column(type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected ?int $id = null;

/**
* @ORM\Column(type="string")
* @Assert\NotBlank
*/
#[ORM\Column(type: 'string')]
#[Assert\NotBlank]
protected string $title;

/**
* @ORM\Column(type="array")
* @Assert\All({
* @Assert\Type("\Tienvx\Bundle\MbtBundle\ValueObject\Bug\Step")
* })
* @Assert\Valid
*/
#[ORM\Column(type: 'array')]
#[Assert\All([
new Assert\Type(type: Step::class),
])]
#[Assert\Valid]
protected array $steps = [];

/**
* @ORM\ManyToOne(targetEntity="\Tienvx\Bundle\MbtBundle\Entity\Task", inversedBy="bugs")
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\ManyToOne(targetEntity: Task::class, inversedBy: 'bugs')]
#[ORM\JoinColumn(nullable: false)]
protected TaskInterface $task;

/**
* @ORM\Column(type="text")
*/
#[ORM\Column(type: 'text')]
protected string $message;

/**
* @ORM\Embedded(class="Progress")
*/
#[ORM\Embedded(class: Progress::class)]
protected ProgressInterface $progress;

/**
* @ORM\Column(type="boolean")
*/
#[ORM\Column(type: 'boolean')]
protected bool $closed = false;

/**
* @ORM\Embedded(class="\Tienvx\Bundle\MbtBundle\Entity\Bug\Video")
*/
#[ORM\Embedded(class: Video::class)]
protected VideoInterface $video;

/**
* @ORM\Column(name="created_at", type="datetime")
*/
#[ORM\Column(name: 'created_at', type: 'datetime')]
protected DateTimeInterface $createdAt;

/**
* @ORM\Column(name="updated_at", type="datetime")
*/
#[ORM\Column(name: 'updated_at', type: 'datetime')]
protected DateTimeInterface $updatedAt;

public function __construct()
Expand All @@ -84,18 +63,14 @@ public function __construct()
$this->video = new Video();
}

/**
* @ORM\PrePersist
*/
#[ORM\PrePersist]
public function prePersist(): void
{
$this->setCreatedAt(new DateTime());
$this->setUpdatedAt(new DateTime());
}

/**
* @ORM\PreUpdate
*/
#[ORM\PreUpdate]
public function preUpdate(): void
{
$this->setUpdatedAt(new DateTime());
Expand Down
12 changes: 3 additions & 9 deletions src/Entity/Bug/Video.php
Expand Up @@ -6,18 +6,12 @@
use Doctrine\ORM\Mapping\Embeddable;
use Tienvx\Bundle\MbtBundle\Model\Bug\Video as VideoModel;

/**
* @Embeddable
*/
#[Embeddable]
class Video extends VideoModel
{
/**
* @ORM\Column(type="boolean")
*/
#[ORM\Column(type: 'boolean')]
protected bool $recording = false;

/**
* @ORM\Column(type="text", nullable=true)
*/
#[ORM\Column(type: 'text', nullable: true)]
protected ?string $errorMessage = null;
}

0 comments on commit 765aa09

Please sign in to comment.