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

53 lines
1.1 KiB

12 years ago
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
12 years ago
*/
class VariableTest extends PHPUnit\Framework\TestCase
12 years ago
{
/**
* @var \flight\Engine
*/
private $app;
protected function setUp(): void
{
$this->app = new \flight\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
}
}