2022-08-10 16:09:29 +00:00
|
|
|
<?php
|
2022-08-15 20:28:25 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
declare( strict_types=1 );
|
2022-08-10 16:09:29 +00:00
|
|
|
|
2022-08-15 20:28:25 +00:00
|
|
|
namespace Tests\Functions;
|
|
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
use Hosterra\FluxBuilder\Functions\Limit;
|
2022-08-10 16:09:29 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
final class LimitFunctionTest extends TestCase {
|
|
|
|
|
public function testSimpleLimit() {
|
|
|
|
|
$expression = new Limit( 1 );
|
2022-08-10 16:09:29 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
$query = '|> limit(n: 1, offset: 0) ';
|
2022-12-16 12:36:01 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
$this->assertEquals( $query, $expression->__toString() );
|
|
|
|
|
}
|
2022-12-16 12:36:01 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
public function testLimitWithOffset() {
|
|
|
|
|
$expression = new Limit( 10, 2 );
|
2022-12-16 12:36:01 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
$query = '|> limit(n: 10, offset: 2) ';
|
2022-08-10 16:09:29 +00:00
|
|
|
|
2024-03-30 16:44:38 +01:00
|
|
|
$this->assertEquals( $query, $expression->__toString() );
|
|
|
|
|
}
|
2022-08-15 20:28:25 +00:00
|
|
|
}
|