mirror of https://github.com/flightphp/core
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							52 lines
						
					
					
						
							1019 B
						
					
					
				
			
		
		
	
	
							52 lines
						
					
					
						
							1019 B
						
					
					
				<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace tests;
 | 
						|
 | 
						|
use flight\Engine;
 | 
						|
use PHPUnit\Framework\TestCase;
 | 
						|
 | 
						|
class VariableTest extends TestCase
 | 
						|
{
 | 
						|
    private Engine $app;
 | 
						|
 | 
						|
    protected function setUp(): void
 | 
						|
    {
 | 
						|
        $this->app = new Engine();
 | 
						|
    }
 | 
						|
 | 
						|
    // Set and get a variable
 | 
						|
    public function testSetAndGet()
 | 
						|
    {
 | 
						|
        $this->app->set('a', 1);
 | 
						|
        $var = $this->app->get('a');
 | 
						|
        $this->assertEquals(1, $var);
 | 
						|
    }
 | 
						|
 | 
						|
    // Clear a specific variable
 | 
						|
    public function testClear()
 | 
						|
    {
 | 
						|
        $this->app->set('b', 1);
 | 
						|
        $this->app->clear('b');
 | 
						|
        $var = $this->app->get('b');
 | 
						|
        $this->assertNull($var);
 | 
						|
    }
 | 
						|
 | 
						|
    // Clear all variables
 | 
						|
    public function testClearAll()
 | 
						|
    {
 | 
						|
        $this->app->set('c', 1);
 | 
						|
        $this->app->clear();
 | 
						|
        $var = $this->app->get('c');
 | 
						|
        $this->assertNull($var);
 | 
						|
    }
 | 
						|
 | 
						|
    // Check if a variable exists
 | 
						|
    public function testHas()
 | 
						|
    {
 | 
						|
        $this->app->set('d', 1);
 | 
						|
        $this->assertTrue($this->app->has('d'));
 | 
						|
    }
 | 
						|
}
 |