Commit 3fb103b4 authored by Pietro Saccardi's avatar Pietro Saccardi
Browse files

Testing expression parsing and rebuilding

parent 1b007b32
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
<?php
require_once(__DIR__ . '/../syntax/grammar.php');

/**
 * General tests for the ifauthex plugin
 *
@@ -65,6 +67,18 @@ class general_plugin_ifauthex_test extends DokuWikiTest
        'user && user || @group'
    );

    public function test_parse()
    {
        foreach (self::VALID_EXPRESSIONS as $expr) {
            $failureMsg = 'Assertion failed at expression "' . $expr . '".';
            $ast = null;
            $rebuiltExpr = null;
            $this->assertNotNull($ast = parse($expr));
            $this->assertNotNull($rebuiltExpr = $ast->getRepresentation());
            $this->assertEquals($rebuiltExpr, preg_replace('/\s/', '', $expr));
        }
    }

    /**
     * Simple test to make sure the plugin.info.txt is in correct format
     */