loadClosest() public static method

The closest context is found by replacing last digits with zero until one is loaded successfully.
See also: Context::load()
public static loadClosest ( string $context = '' ) : string
$context string Name of the context or full class name that defines the context.
return string The loaded context. `null` if no context was loaded.
Example #1
0
 public function testLoad()
 {
     // Default context is 5.7.0.
     $this->assertEquals('\\SqlParser\\Contexts\\ContextMySql50700', Context::$loadedContext);
     $this->assertTrue(isset(Context::$KEYWORDS['STORED']));
     $this->assertFalse(isset(Context::$KEYWORDS['AUTHORS']));
     Context::load('MySql50600');
     $this->assertEquals('\\SqlParser\\Contexts\\ContextMySql50600', Context::$loadedContext);
     $this->assertFalse(isset(Context::$KEYWORDS['STORED']));
     $this->assertTrue(isset(Context::$KEYWORDS['AUTHORS']));
     Context::loadClosest('MySql50712');
     $this->assertEquals('\\SqlParser\\Contexts\\ContextMySql50700', Context::$loadedContext);
     $this->assertEquals(null, Context::loadClosest('Sql'));
     // Restoring context.
     Context::load('');
     $this->assertEquals('\\SqlParser\\Contexts\\ContextMySql50700', Context::$defaultContext);
     $this->assertTrue(isset(Context::$KEYWORDS['STORED']));
     $this->assertFalse(isset(Context::$KEYWORDS['AUTHORS']));
 }