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.
flight-core/tests/VariableTest.php

52 lines
1019 B

12 years ago
<?php
declare(strict_types=1);
namespace tests;
use flight\Engine;
use PHPUnit\Framework\TestCase;
class VariableTest extends TestCase
12 years ago
{
private Engine $app;
protected function setUp(): void
{
$this->app = new Engine();
12 years ago
}
12 years ago
// Set and get a variable
public function testSetAndGet()
{
$this->app->set('a', 1);
$var = $this->app->get('a');
12 years ago
$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);
12 years ago
}
// Clear all variables
public function testClearAll()
{
$this->app->set('c', 1);
$this->app->clear();
$var = $this->app->get('c');
$this->assertNull($var);
12 years ago
}
// Check if a variable exists
public function testHas()
{
$this->app->set('d', 1);
$this->assertTrue($this->app->has('d'));
12 years ago
}
}