ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\WOPI\Discovery\CreatableSuffixesTest Class Reference
+ Inheritance diagram for ILIAS\WOPI\Discovery\CreatableSuffixesTest:
+ Collaboration diagram for ILIAS\WOPI\Discovery\CreatableSuffixesTest:

Public Member Functions

 testTemplatesCreatingAnotherFileTypeAreLeftOut ()
 
 testSuffixesAreLowercasedSortedAndUnique ()
 
 testNoEditnewActionsMeansNothingCanBeCreated ()
 
 testTemplatesAreOfferedOnlyWhenAskedFor ()
 
 testAnExtensionOfferedAsRegularFormatIsNoTemplate ()
 
 testFormatsCarryTheAppNameAndAreSortedByIt ()
 

Private Member Functions

 repositoryWith (array $editnew_rows)
 

Detailed Description

Definition at line 25 of file CreatableSuffixesTest.php.

Member Function Documentation

◆ repositoryWith()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::repositoryWith ( array  $editnew_rows)
private
Parameters
list<array{extstring, target_ext: ?string, app?: string}> $editnew_rows

Definition at line 30 of file CreatableSuffixesTest.php.

30 : ActionDBRepository
31 {
32 $rows = array_map(
33 static fn(array $row): array => [
34 'ext' => $row['ext'],
35 'target_ext' => $row['target_ext'],
36 'app_name' => $row['app'] ?? 'Word',
37 ],
38 $editnew_rows
39 );
40
41 $db = $this->createMock(\ilDBInterface::class);
42 $db->expects($this->once())
43 ->method('queryF')
44 ->with($this->anything(), ['text'], [ActionTarget::EDIT_NEW->value])
45 ->willReturn($this->createStub(\ilDBStatement::class));
46 $db->method('fetchAssoc')->willReturnOnConsecutiveCalls(...[...$rows, null]);
47
48 return new ActionDBRepository($db);
49 }

References ILIAS\$db, and ILIAS\Scripts\PHPStan\$rows.

Referenced by ILIAS\WOPI\Discovery\CreatableSuffixesTest\testAnExtensionOfferedAsRegularFormatIsNoTemplate(), ILIAS\WOPI\Discovery\CreatableSuffixesTest\testFormatsCarryTheAppNameAndAreSortedByIt(), ILIAS\WOPI\Discovery\CreatableSuffixesTest\testNoEditnewActionsMeansNothingCanBeCreated(), ILIAS\WOPI\Discovery\CreatableSuffixesTest\testSuffixesAreLowercasedSortedAndUnique(), ILIAS\WOPI\Discovery\CreatableSuffixesTest\testTemplatesAreOfferedOnlyWhenAskedFor(), and ILIAS\WOPI\Discovery\CreatableSuffixesTest\testTemplatesCreatingAnotherFileTypeAreLeftOut().

+ Here is the caller graph for this function:

◆ testAnExtensionOfferedAsRegularFormatIsNoTemplate()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testAnExtensionOfferedAsRegularFormatIsNoTemplate ( )

Definition at line 92 of file CreatableSuffixesTest.php.

92 : void
93 {
94 $rows = [
95 ['ext' => 'odt', 'target_ext' => 'docx'],
96 ['ext' => 'odt', 'target_ext' => null],
97 ];
98
99 $this->assertSame(['odt'], $this->repositoryWith($rows)->getCreatableSuffixes());
100 $this->assertSame([], $this->repositoryWith($rows)->getTemplateSuffixes());
101 }

References ILIAS\Scripts\PHPStan\$rows, and ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

◆ testFormatsCarryTheAppNameAndAreSortedByIt()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testFormatsCarryTheAppNameAndAreSortedByIt ( )

Definition at line 103 of file CreatableSuffixesTest.php.

103 : void
104 {
105 $repository = $this->repositoryWith([
106 ['ext' => 'xlsx', 'target_ext' => null, 'app' => 'Excel'],
107 ['ext' => 'pptx', 'target_ext' => null, 'app' => 'PowerPoint'],
108 ['ext' => 'docx', 'target_ext' => null, 'app' => 'Word'],
109 ['ext' => 'xltx', 'target_ext' => 'xlsx', 'app' => 'Excel'],
110 ['ext' => 'ods', 'target_ext' => null, 'app' => 'Excel'],
111 ]);
112
113 $this->assertSame(
114 ['ods' => 'Excel', 'xlsx' => 'Excel', 'pptx' => 'PowerPoint', 'docx' => 'Word'],
115 $repository->getCreatableFormats()
116 );
117 }

References ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

◆ testNoEditnewActionsMeansNothingCanBeCreated()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testNoEditnewActionsMeansNothingCanBeCreated ( )

Definition at line 75 of file CreatableSuffixesTest.php.

75 : void
76 {
77 $this->assertSame([], $this->repositoryWith([])->getCreatableSuffixes());
78 }

References ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

◆ testSuffixesAreLowercasedSortedAndUnique()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testSuffixesAreLowercasedSortedAndUnique ( )

Definition at line 64 of file CreatableSuffixesTest.php.

64 : void
65 {
66 $repository = $this->repositoryWith([
67 ['ext' => 'PPTX', 'target_ext' => null],
68 ['ext' => 'docx', 'target_ext' => 'DOCX'],
69 ['ext' => 'pptx', 'target_ext' => null],
70 ]);
71
72 $this->assertSame(['docx', 'pptx'], $repository->getCreatableSuffixes());
73 }

References ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

◆ testTemplatesAreOfferedOnlyWhenAskedFor()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testTemplatesAreOfferedOnlyWhenAskedFor ( )

Definition at line 80 of file CreatableSuffixesTest.php.

80 : void
81 {
82 $rows = [
83 ['ext' => 'docx', 'target_ext' => null],
84 ['ext' => 'dotx', 'target_ext' => 'docx'],
85 ['ext' => 'xltx', 'target_ext' => 'xlsx', 'app' => 'Excel'],
86 ];
87
88 $this->assertSame(['docx', 'dotx', 'xltx'], $this->repositoryWith($rows)->getCreatableSuffixes(true));
89 $this->assertSame(['dotx', 'xltx'], $this->repositoryWith($rows)->getTemplateSuffixes());
90 }

References ILIAS\Scripts\PHPStan\$rows, and ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

◆ testTemplatesCreatingAnotherFileTypeAreLeftOut()

ILIAS\WOPI\Discovery\CreatableSuffixesTest::testTemplatesCreatingAnotherFileTypeAreLeftOut ( )

Definition at line 51 of file CreatableSuffixesTest.php.

51 : void
52 {
53 $repository = $this->repositoryWith([
54 ['ext' => 'docx', 'target_ext' => null],
55 ['ext' => 'dotx', 'target_ext' => 'docx'],
56 ['ext' => 'xlsx', 'target_ext' => null],
57 ['ext' => 'xltx', 'target_ext' => 'xlsx'],
58 ['ext' => 'pdf', 'target_ext' => null],
59 ]);
60
61 $this->assertSame(['docx', 'pdf', 'xlsx'], $repository->getCreatableSuffixes());
62 }

References ILIAS\WOPI\Discovery\CreatableSuffixesTest\repositoryWith().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: