vite config : ignore /local and /public/** to improve perf
This commit is contained in:
parent
3c9eed7804
commit
c11a85e7f8
32 changed files with 1235 additions and 858 deletions
158
public/site/plugins/kql/tests/KqlTest.php
Normal file
158
public/site/plugins/kql/tests/KqlTest.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Kql;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class KqlTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->app = new App([
|
||||
'roots' => [
|
||||
'index' => '/dev/null'
|
||||
],
|
||||
'site' => [
|
||||
'children' => [
|
||||
[
|
||||
'slug' => 'projects'
|
||||
],
|
||||
[
|
||||
'slug' => 'about'
|
||||
],
|
||||
[
|
||||
'slug' => 'contact'
|
||||
]
|
||||
],
|
||||
'content' => [
|
||||
'title' => 'Test Site'
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function testForbiddenMethod()
|
||||
{
|
||||
$this->expectException("Kirby\Exception\PermissionException");
|
||||
$this->expectExceptionMessage('The method "Kirby\Cms\Page::delete()" is not allowed in the API context');
|
||||
$result = Kql::run('site.children.first.delete');
|
||||
}
|
||||
|
||||
public function testRun()
|
||||
{
|
||||
$result = Kql::run('site.title');
|
||||
$expected = 'Test Site';
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testQuery()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'query' => 'site.children',
|
||||
'select' => 'slug'
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
[
|
||||
'slug' => 'projects',
|
||||
],
|
||||
[
|
||||
'slug' => 'about',
|
||||
],
|
||||
[
|
||||
'slug' => 'contact',
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testSelectWithAlias()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'select' => [
|
||||
'myTitle' => 'site.title'
|
||||
]
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'myTitle' => 'Test Site',
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testSelectWithArray()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'select' => ['title', 'url']
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'title' => 'Test Site',
|
||||
'url' => '/'
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testSelectWithBoolean()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'select' => [
|
||||
'title' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'title' => 'Test Site'
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testSelectWithQuery()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'select' => [
|
||||
'children' => [
|
||||
'query' => 'site.children',
|
||||
'select' => 'slug'
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'children' => [
|
||||
[
|
||||
'slug' => 'projects',
|
||||
],
|
||||
[
|
||||
'slug' => 'about',
|
||||
],
|
||||
[
|
||||
'slug' => 'contact',
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testSelectWithString()
|
||||
{
|
||||
$result = Kql::run([
|
||||
'select' => [
|
||||
'title' => 'site.title.upper'
|
||||
]
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'title' => 'TEST SITE'
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue