How to use StringTokenScannerTest class

Best Gherkin-php code snippet using .StringTokenScannerTest

Run Gherkin-php automation tests on LambdaTest cloud grid

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

StringTokenScannerTest.php

Source: StringTokenScannerTest.php Github

copy
1<?php
2
3declare(strict_types=1);
4
5namespace Cucumber\Gherkin;
6
7use PHPUnit\Framework\TestCase;
8
9final class StringTokenScannerTest extends TestCase
10{
11    public function testItFindsEofForEmptyStream(): void
12    {
13        $stream = '';
14
15        $scanner = new StringTokenScanner($stream);
16        $token = $scanner->read();
17
18        self::assertTrue($token->isEof());
19    }
20
21    public function testItFindsOneTokenPerLineForPopulatedStream(): void
22    {
23        $contents = "FOO\nBAR\r\nBAZ\n";
24
25        $scanner = new StringTokenScanner($contents);
26
27        $token = $scanner->read();
28        self::assertSame('FOO', $token->getTokenValue());
29
30        $token = $scanner->read();
31        self::assertSame('BAR', $token->getTokenValue());
32
33        $token = $scanner->read();
34        self::assertSame('BAZ', $token->getTokenValue());
35
36        $token = $scanner->read();
37        self::assertSame('EOF', $token->getTokenValue());
38        self::assertTrue($token->isEof());
39    }
40
41    public function testItFindsEmptyLines(): void
42    {
43        $contents = "FOO\n\nBAR\n";
44
45        $scanner = new StringTokenScanner($contents);
46
47        $token = $scanner->read();
48        self::assertSame('FOO', $token->getTokenValue());
49
50        $token = $scanner->read();
51        self::assertSame('', $token->getTokenValue());
52
53        $token = $scanner->read();
54        self::assertSame('BAR', $token->getTokenValue());
55
56        $token = $scanner->read();
57        self::assertSame('EOF', $token->getTokenValue());
58        self::assertTrue($token->isEof());
59    }
60}
61
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

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)