Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v1
- name: Install symfony/clock
run: composer require --dev symfony/clock
if: ${{ matrix.php-version != '7.4' && matrix.php-version != '8.0' }}
- name: Validate composer config
run: composer validate
- name: Install dependencies
Expand All @@ -50,7 +53,7 @@ jobs:
nohup php -S 0.0.0.0:8080 -t features/fixtures/project/web > features/fixtures/project/var/logs/server.log 2>&1 &
sleep 5
- name: Functional tests
run: vendor/bin/behat --no-snippets --format=progress --profile=travis -vvv
run: vendor/bin/behat --no-snippets --format=progress --profile=actions -vvv
- name: Upload logs
uses: actions/upload-artifact@master
with:
Expand Down
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

25 changes: 13 additions & 12 deletions Behat/Context/AdminContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FSi\Bundle\AdminBundle\Behat\Context;

use Assert\Assertion;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Session;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -63,10 +64,10 @@ public function theFollowingAdminElementsWereRegistered(TableNode $table): void
foreach ($table->getHash() as $serviceRow) {
$id = $serviceRow['Id'];
$class = $serviceRow['Class'];
expect($this->manager->hasElement($id))->toBe(true);
expect($this->manager->getElement($id))->toBeAnInstanceOf($class);
Assertion::true($this->manager->hasElement($id));
Assertion::isInstanceOf($this->manager->getElement($id), $class);
if (true === array_key_exists('Parent', $serviceRow) && '' !== $serviceRow['Parent']) {
expect($this->manager->getElement($id)->getParentId())->toBe($serviceRow['Parent']);
Assertion::same($this->manager->getElement($id)->getParentId(), $serviceRow['Parent']);
}
}
}
Expand All @@ -79,8 +80,8 @@ public function elementHaveFollowingOptionsDefined(AbstractElement $adminElement
foreach ($options->getHash() as $optionRow) {
$option = $optionRow['Option'];
$value = $optionRow['Value'];
expect($adminElement->hasOption($option))->toBe(true);
expect($adminElement->getOption($option))->toBe($value);
Assertion::true($adminElement->hasOption($option));
Assertion::eq($adminElement->getOption($option), $value);
}
}

Expand All @@ -92,8 +93,8 @@ public function thereAreFollowingAdminElementsAvailable(TableNode $table): void
foreach ($table->getHash() as $elementRow) {
$id = $elementRow['Id'];
$name = $elementRow['Name'];
expect($this->manager->hasElement($id))->toBe(true);
expect($this->manager->getElement($id)->getName())->toBe($name);
Assertion::true($this->manager->hasElement($id));
Assertion::same($this->manager->getElement($id)->getName(), $name);
}
}

Expand All @@ -102,23 +103,23 @@ public function thereAreFollowingAdminElementsAvailable(TableNode $table): void
*/
public function iShouldSeeTitleAtTopBar($navbarBrandText): void
{
expect($this->getPage(AdminPanel::class)->getNavbarBrandText())->toBe($navbarBrandText);
Assertion::eq($this->getPage(AdminPanel::class)->getNavbarBrandText(), $navbarBrandText);
}

/**
* @Given I should see :page page header :headerContent
*/
public function iShouldSeePageHeader(Page $page, $headerContent): void
{
expect($page->getHeader())->toBe($headerContent);
Assertion::eq($page->getHeader(), $headerContent);
}

/**
* @Given /^translations are enabled in application$/
*/
public function translationsAreEnabledInApplication(): void
{
expect($this->translator)->toBeAnInstanceOf(TranslatorInterface::class);
Assertion::isInstanceOf($this->translator, TranslatorInterface::class);
}

/**
Expand All @@ -127,7 +128,7 @@ public function translationsAreEnabledInApplication(): void
*/
public function iShouldSeeLanguageDropdownButtonInNavigationBarWithText($button): void
{
expect($this->getPage(AdminPanel::class)->getLanguageDropdown()->hasLink($button))->toBe(true);
Assertion::true($this->getPage(AdminPanel::class)->getLanguageDropdown()->hasLink($button));
}

/**
Expand All @@ -138,7 +139,7 @@ public function languageDropdownButtonShouldHaveFollowingLinks(TableNode $dropdo
$links = $this->getPage(AdminPanel::class)->getLanguageDropdownOptions();

foreach ($dropdownLinks->getHash() as $link) {
expect($links)->toContain($link['Link']);
Assertion::inArray($link['Link'], $links);
}
}

Expand Down
20 changes: 11 additions & 9 deletions Behat/Context/DataContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FSi\Bundle\AdminBundle\Behat\Context;

use Assert\Assertion;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Session;
use DateTime;
Expand All @@ -29,7 +30,6 @@

use function array_key_exists;
use function count;
use function expect;
use function file_exists;

class DataContext extends AbstractContext
Expand Down Expand Up @@ -99,6 +99,8 @@ public function entityToClassName(string $entityName): string
return Subscriber::class;
case 'person':
return Person::class;
default:
throw new InvalidArgumentException(sprintf('Unknown entity name "%s"', $entityName));
}
}

Expand All @@ -118,7 +120,7 @@ public function thereIsNumberOfEntities(int $count, string $className): void

$entityManager->flush();

expect(count($this->getRepository($className)->findAll()))->toBe($count);
Assertion::count($this->getRepository($className)->findAll(), $count);
}

/**
Expand All @@ -138,23 +140,23 @@ public function thereIsAnEntityWithField(string $className, string $field, $valu
$entityManager->persist($instance);
$entityManager->flush();

expect($this->getRepository($className)->findOneBy([$field => $value]))->toBeAnInstanceOf($className);
Assertion::isInstanceOf($this->getRepository($className)->findOneBy([$field => $value]), $className);
}

/**
* @Then there should be a :className with :field :value present in the database
*/
public function entityWithFieldShouldExist(string $className, string $field, $value): void
{
expect($this->getRepository($className)->findOneBy([$field => $value]))->toBeAnInstanceOf($className);
Assertion::isInstanceOf($this->getRepository($className)->findOneBy([$field => $value]), $className);
}

/**
* @Given :className with :field :value should not exist in database anymore
*/
public function entityShouldNotExistInDatabaseAnymore(string $className, string $field, $value): void
{
expect($this->getRepository($className)->findOneBy([$field => $value]))->toBe(null);
Assertion::null($this->getRepository($className)->findOneBy([$field => $value]));
}

/**
Expand All @@ -178,7 +180,7 @@ public function thereShouldNotBeAnyEntities(string $className): void
*/
public function thereShouldExistsNumberOfEntities($count, string $className): void
{
expect(count($this->getRepository($className)->findAll()))->toBe($count);
Assertion::count($this->getRepository($className)->findAll(), $count);
}

/**
Expand Down Expand Up @@ -237,7 +239,7 @@ public function entityShouldHaveElementsInCollection(
$entity = $this->getRepository($className)->findOneBy([$field => $value]);
$this->getEntityManager()->refresh($entity);

expect(count($this->getEntityField($entity, $collectionName)))->toBe($expectedCount);
Assertion::count($this->getEntityField($entity, $collectionName), $expectedCount);
}

/**
Expand All @@ -248,7 +250,7 @@ public function entityWithIdShouldHaveChangedField(string $className, $id, strin
$entity = $this->getRepository($className)->find($id);
$this->getEntityManager()->refresh($entity);

expect($this->getEntityField($entity, $field))->toBe($value);
Assertion::eq($this->getEntityField($entity, $field), $value);
}

/**
Expand All @@ -259,7 +261,7 @@ public function entityWithIdShouldNotHaveChangedFieldValue(string $className, $i
$entity = $this->getRepository($className)->find($id);
$this->getEntityManager()->refresh($entity);

expect($this->getEntityField($entity, $field))->notToBe($value);
Assertion::notEq($this->getEntityField($entity, $field), $value);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Behat/Context/DisplayContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FSi\Bundle\AdminBundle\Behat\Context;

use Assert\Assertion;
use Behat\Gherkin\Node\TableNode;
use FSi\Bundle\AdminBundle\Behat\Element\Display;

Expand All @@ -23,7 +24,7 @@ public function iShouldSeeDisplayWithFollowingFields(TableNode $table): void
{
$display = $this->getElement(Display::class);
foreach ($table->getHash() as $row) {
expect($display->hasFieldWithName($row['Field name']))->toBe(true);
Assertion::true($display->hasFieldWithName($row['Field name']), true);
}
}
}
Loading