2024-07-21 01:47:21 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2024-06-08 23:58:45 +00:00
|
|
|
|
|
|
|
namespace Test\Unit;
|
|
|
|
|
|
|
|
use BitBadger\PDODocument\Op;
|
|
|
|
use PHPUnit\Framework\Attributes\TestDox;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit tests for the Op enumeration
|
|
|
|
*/
|
2024-06-21 13:46:41 +00:00
|
|
|
#[TestDox('Op (Unit tests)')]
|
2024-06-08 23:58:45 +00:00
|
|
|
class OpTest extends TestCase
|
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for Equal')]
|
|
|
|
public function testToSQLSucceedsForEqual(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('=', Op::Equal->toSQL(), 'Equal SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for Greater')]
|
|
|
|
public function testToSQLSucceedsForGreater(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('>', Op::Greater->toSQL(), 'Greater SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for GreaterOrEqual')]
|
|
|
|
public function testToSQLSucceedsForGreaterOrEqual(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('>=', Op::GreaterOrEqual->toSQL(), 'GreaterOrEqual SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for Less')]
|
|
|
|
public function testToSQLSucceedsForLess(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('<', Op::Less->toSQL(), 'Less SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for LessOrEqual')]
|
|
|
|
public function testToSQLSucceedsForLessOrEqual(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('<=', Op::LessOrEqual->toSQL(), 'LessOrEqual SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for NotEqual')]
|
|
|
|
public function testToSQLSucceedsForNotEqual(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('<>', Op::NotEqual->toSQL(), 'NotEqual SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for Between')]
|
|
|
|
public function testToSQLSucceedsForBetween(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('BETWEEN', Op::Between->toSQL(), 'Between SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for In')]
|
|
|
|
public function testToSQLSucceedsForIn(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('IN', Op::In->toSQL(), 'In SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
#[TestDox('toSQL() succeeds for InArray')]
|
|
|
|
public function testToSQLSucceedsForInArray(): void
|
|
|
|
{
|
|
|
|
$this->assertEquals('??|', Op::InArray->toSQL(), 'InArray SQL operator incorrect');
|
|
|
|
}
|
|
|
|
|
|
|
|
#[TestDox('toSQL() succeeds for Exists')]
|
|
|
|
public function testToSQLSucceedsForExists(): void
|
|
|
|
{
|
|
|
|
$this->assertEquals('IS NOT NULL', Op::Exists->toSQL(), 'Exists SQL operator incorrect');
|
|
|
|
}
|
|
|
|
|
|
|
|
#[TestDox('toSQL() succeeds for NotExists')]
|
2024-07-21 01:47:21 +00:00
|
|
|
public function testToSQLSucceedsForNEX(): void
|
2024-06-08 23:58:45 +00:00
|
|
|
{
|
2024-09-27 02:15:00 +00:00
|
|
|
$this->assertEquals('IS NULL', Op::NotExists->toSQL(), 'NotExists SQL operator incorrect');
|
2024-06-08 23:58:45 +00:00
|
|
|
}
|
|
|
|
}
|