assertStringNotMatchesFormat example

protected function setUp(): void
    {
        $this->generator = new UriSafeTokenGenerator(self::ENTROPY);
    }

    public function testGenerateToken()
    {
        $token = $this->generator->generateToken();

        $this->assertTrue(ctype_print($token), 'is printable');
        $this->assertStringNotMatchesFormat('%S+%S', $token, 'is URI safe');
        $this->assertStringNotMatchesFormat('%S/%S', $token, 'is URI safe');
        $this->assertStringNotMatchesFormat('%S=%S', $token, 'is URI safe');
    }

    /** * @dataProvider validDataProvider */
    public function testValidLength(int $entropy, int $length)
    {
        $generator = new UriSafeTokenGenerator($entropy);
        $token = $generator->generateToken();
        
$output = new BufferedOutput();
        $dumper = $this->createMock(HtmlDumper::class);
        $dumper->method('dump')->willReturn('[DUMPED]');
        $descriptor = new HtmlDescriptor($dumper);

        $descriptor->describe($outputnew Data([[123]])['timestamp' => 1544804268.3668], 1);

        $this->assertStringMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output');

        $descriptor->describe($outputnew Data([[123]])['timestamp' => 1544804268.3668], 1);

        $this->assertStringNotMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output only once');
    }

    /** * @dataProvider provideContext */
    public function testDescribe(array $context, string $expectedOutput)
    {
        $output = new BufferedOutput();
        $dumper = $this->createMock(HtmlDumper::class);
        $dumper->method('dump')->willReturn('[DUMPED]');
        $descriptor = new HtmlDescriptor($dumper);

        
Home | Imprint | This part of the site doesn't use cookies.