-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathWorkspaceQueryCommandTest.php
More file actions
57 lines (44 loc) · 1.42 KB
/
WorkspaceQueryCommandTest.php
File metadata and controls
57 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace PHPCR\Tests\Util\Console\Command;
use PHPCR\Query\QueryInterface;
use PHPCR\Util\Console\Command\WorkspaceQueryCommand;
use PHPUnit\Framework\MockObject\MockObject;
class WorkspaceQueryCommandTest extends BaseCommandTest
{
/**
* @var QueryInterface&MockObject
*/
protected $query;
public function setUp(): void
{
parent::setUp();
$this->addCommand(new WorkspaceQueryCommand());
$this->query = $this->createMock(QueryInterface::class);
}
public function testQuery(): void
{
$this->queryManager
->method('getSupportedQueryLanguages')
->willReturn(['JCR-SQL2']);
$this->session
->method('getWorkspace')
->willReturn($this->workspace);
$this->workspace
->method('getQueryManager')
->willReturn($this->queryManager);
$this->queryManager->expects($this->once())
->method('createQuery')
->with('SELECT foo FROM foo', 'JCR-SQL2')
->willReturn($this->query);
$this->query->expects($this->once())
->method('getLanguage')
->willReturn('FOOBAR');
$this->query->expects($this->once())
->method('execute')
->willReturn([]);
$this->executeCommand('phpcr:workspace:query', [
'query' => 'SELECT foo FROM foo',
]);
}
}