PHP code example of amoifr / pickle-panther-bundle

1. Go to this page and download the library: Download amoifr/pickle-panther-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amoifr / pickle-panther-bundle example snippets


final class HomepageTest extends BasePantherTest
{
    public function testHomepage(): void
    {
        $this->createScenarioRunner()->runTest(__DIR__.'/Scenario/homepage.yaml');
    }
}

return [
    // ...
    Amoifr\PicklePantherBundle\PicklePantherBundle::class => ['test' => true],
];

use Amoifr\PicklePantherBundle\Attribute\Sentence;
use Amoifr\PicklePantherBundle\Sentence\AbstractSentenceProvider;

final class CheckoutSentences extends AbstractSentenceProvider
{
    #[Sentence('Ajoute le produit [sku] au panier', 'fr')]
    #[Sentence('Add product [sku] to the cart', 'en')]
    public function addToCart(string $sku): void
    {
        $this->client()->clickLink(/* ... */);
        $this->testCase()->assertSelectorExists('.cart-item');
    }
}
yaml
# tests/E2E/Scenario/homepage.yaml
scenarios:
  - nom: "La page d'accueil se charge"
    contexte:
      navigateur: desktop          # desktop | mobile
    etapes:
      - action: "Visite la page avec l'[/]"          # value written inline in the brackets
      - action: "Vérifie que le texte [text] est présent dans le sélecteur [selector]"
        args: { text: "Bienvenue", selector: "h1" }   # or listed explicitly under args
xml
<extensions>
    <bootstrap class="Symfony\Component\Panther\ServerExtension"/>
    <bootstrap class="Amoifr\PicklePantherBundle\Report\HtmlReportExtension">
        <parameter name="output_dir" value="var/pickle-panther"/>
    </bootstrap>
</extensions>

<php>
    <env name="PANTHER_WEB_SERVER_DIR" value="./public"/>
    <env name="PICKLE_PANTHER_OUTPUT_DIR" value="./var/pickle-panther"/>
    <!-- Recommended in CI/Docker: -->
    <env name="PANTHER_NO_SANDBOX" value="1"/>
</php>