-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathWorkspaceImportCommandTest.php
More file actions
64 lines (49 loc) · 1.93 KB
/
WorkspaceImportCommandTest.php
File metadata and controls
64 lines (49 loc) · 1.93 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
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespace PHPCR\Tests\Util\Console\Command;
use PHPCR\ImportUUIDBehaviorInterface;
use PHPCR\RepositoryInterface;
use PHPCR\Util\Console\Command\WorkspaceImportCommand;
class WorkspaceImportCommandTest extends BaseCommandTest
{
public function setUp(): void
{
parent::setUp();
$this->addCommand(new WorkspaceImportCommand());
}
public function testImport(): void
{
$this->session->expects($this->once())
->method('getRepository')
->willReturn($this->repository);
$this->repository->expects($this->once())
->method('getDescriptor')
->with(RepositoryInterface::OPTION_XML_IMPORT_SUPPORTED)
->willReturn(true);
$this->session->expects($this->once())
->method('importXml')
->with('/', 'test_import.xml', ImportUUIDBehaviorInterface::IMPORT_UUID_CREATE_NEW);
$ct = $this->executeCommand('phpcr:workspace:import', [
'filename' => 'test_import.xml',
]);
$this->assertStringContainsString('Successfully imported', $ct->getDisplay());
}
public function testImportUuidBehaviorThrow(): void
{
$this->session->expects($this->once())
->method('getRepository')
->willReturn($this->repository);
$this->repository->expects($this->once())
->method('getDescriptor')
->with(RepositoryInterface::OPTION_XML_IMPORT_SUPPORTED)
->willReturn(true);
$this->session->expects($this->once())
->method('importXml')
->with('/', 'test_import.xml', ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
$ct = $this->executeCommand('phpcr:workspace:import', [
'filename' => 'test_import.xml',
'--uuid-behavior' => 'throw',
]);
$this->assertStringContainsString('Successfully imported', $ct->getDisplay());
}
}