- Add In/InArray support - Add ORDER BY support for `Find` functions - Update dependencies - Implement fixes identified via static analysis Reviewed-on: #5
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * @author Daniel J. Summers <daniel@bitbadger.solutions>
 | 
						|
 * @license MIT
 | 
						|
 */
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace Test\Unit\Mapper;
 | 
						|
 | 
						|
use BitBadger\PDODocument\{Configuration, DocumentException, Mode};
 | 
						|
use BitBadger\PDODocument\Mapper\ExistsMapper;
 | 
						|
use PHPUnit\Framework\Attributes\TestDox;
 | 
						|
use PHPUnit\Framework\TestCase;
 | 
						|
 | 
						|
/**
 | 
						|
 * Unit tests for the ExistsMapper class
 | 
						|
 */
 | 
						|
#[TestDox('Exists Mapper (Unit tests)')]
 | 
						|
class ExistsMapperTest extends TestCase
 | 
						|
{
 | 
						|
    #[TestDox('map() succeeds for PostgreSQL')]
 | 
						|
    public function testMapSucceedsForPostgreSQL(): void
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            Configuration::overrideMode(Mode::PgSQL);
 | 
						|
            $this->assertFalse((new ExistsMapper())->map([false, 'nope']), 'Result should have been false');
 | 
						|
        } finally {
 | 
						|
            Configuration::overrideMode(null);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    #[TestDox('map() succeeds for SQLite')]
 | 
						|
    public function testMapSucceedsForSQLite(): void
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            Configuration::overrideMode(Mode::SQLite);
 | 
						|
            $this->assertTrue((new ExistsMapper())->map([1, 'yep']), 'Result should have been true');
 | 
						|
        } finally {
 | 
						|
            Configuration::overrideMode(null);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    #[TestDox('map() fails when mode not set')]
 | 
						|
    public function testMapFailsWhenModeNotSet(): void
 | 
						|
    {
 | 
						|
        $this->expectException(DocumentException::class);
 | 
						|
        Configuration::overrideMode(null);
 | 
						|
        (new ExistsMapper())->map(['0']);
 | 
						|
    }
 | 
						|
}
 |