PHP code example of allure-framework / allure-php-commons

1. Go to this page and download the library: Download allure-framework/allure-php-commons 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/ */

    

allure-framework / allure-php-commons example snippets




use Qameta\Allure\Attribute\AttributeSetInterface;
use Qameta\Allure\Attribute\DisplayName;
use Qameta\Allure\Attribute\Tag;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
class MyAttribute implements AttributeSetInterface
{
    private array $tags;

    public function __construct(
        private string $displayName,
        string ...$tags,
    ) {
        $this->tags = $tags;
    }
    
    public function getAttributes() : array
    {
        return [
            new DisplayName($this->displayName),
            ...array_map(
                fn (string $tag): Tag => new Tag($tag),
                $this->tags,
            ),
        ];
    }
}

// Example of usage
#[MyAttribute('Test name', 'tag 1', 'tag 2')]
class MyTestClass
{
}
json
{
    "hp": "^8",
        "allure-framework/allure-php-commons": "^2"
    }
}