How to use TransformationAnnotationReader class

Best Behat code snippet using .TransformationAnnotationReader

Run Behat automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

TransformationAnnotationReader.php

Source: TransformationAnnotationReader.php Github

copy
1<?php
2
3/*
4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <[email protected]>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11namespace Behat\Behat\Transformation\Context\Annotation;
12
13use Behat\Behat\Context\Annotation\AnnotationReader;
14use Behat\Behat\Transformation\Call\RuntimeTransformation;
15use ReflectionMethod;
16
17/**
18 * Step transformation annotation reader.
19 *
20 * Reads step transformations from a context method annotation.
21 *
22 * @author Konstantin Kudryashov <ever.zet@gmail.com>
23 */
24class TransformationAnnotationReader implements AnnotationReader
25{
26    /**
27     * @var string
28     */
29    private static $regex = '/^\@transform\s+(.+)$/i';
30
31    /**
32     * Loads step callees (if exist) associated with specific method.
33     *
34     * @param string           $contextClass
35     * @param ReflectionMethod $method
36     * @param string           $docLine
37     * @param string           $description
38     *
39     * @return null|RuntimeTransformation
40     */
41    public function readCallee($contextClass, ReflectionMethod $method, $docLine, $description)
42    {
43        if (!preg_match(self::$regex, $docLine, $match)) {
44            return null;
45        }
46
47        $pattern = $match[1];
48        $callable = array($contextClass, $method->getName());
49
50        return new RuntimeTransformation($pattern, $callable, $description);
51    }
52}
53
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used methods in TransformationAnnotationReader

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)