ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
ilWebDAVUriPathResolverTest Class Reference
+ Inheritance diagram for ilWebDAVUriPathResolverTest:
+ Collaboration diagram for ilWebDAVUriPathResolverTest:

Public Member Functions

 getRefIdForWebDAVPath_pathHasOnlyOneElement_ThrowBadRequest ()
 
 getRefIdForWebDAVPath_pathHasNoValidMountPoint_ThrowBadRequest ()
 
 getRefIdForWebDAVPath_repoRootAsMountGiven_callAndReturnValueOfGetRefIdFromPathInRepositoryMount ()
 
 getRefIdFromGivenParentRefAndTitlePath_pathEndsWithSlash_returnElementBeforeSlash ()
 If a path like foo/bar/last/ is given, the return should be the ref_id of 'last'. More...
 
 getRefIdFromGivenParentRefAndTitlePath_pathEndsWithoutSlash_returnLastElement ()
 If a path like foo/bar/last is given, the return should be the ref_id of 'last'. More...
 
 getRefIdFromGivenParentRefAndTitlePath_pathStartsWithSlash_returnLastElement ()
 If a path like /foo//bar/last is given, the return should be the ref_id of 'last'. More...
 
 getRefIdFromGivenParentRefAndTitlePath_pathWithDoubleSlashInBetween_returnLastElement ()
 If a path like foo//bar/last is given, the return should be the ref_id of 'last'. More...
 
 getRefIdFromGivenParentRefAndTitlePath_pathWithTrippleSlashInBetween_returnLastElement ()
 If a path like foo///bar/last is given, the return should be the ref_id of 'last'. More...
 

Protected Member Functions

 setUp ()
 Setup. More...
 

Protected Attributes

 $mocked_repo_helper
 

Detailed Description

Definition at line 3 of file ilWebDAVUriPathResolverTest.php.

Member Function Documentation

◆ getRefIdForWebDAVPath_pathHasNoValidMountPoint_ThrowBadRequest()

ilWebDAVUriPathResolverTest::getRefIdForWebDAVPath_pathHasNoValidMountPoint_ThrowBadRequest ( )

Test:

Definition at line 45 of file ilWebDAVUriPathResolverTest.php.

46  {
47  // Arrange
48  $too_short_path = "some_string_with_a_slash/and_stuff";
49  $correct_exception_thrown = false;
50 
51  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
52  $path_resolver->shouldAllowMockingProtectedMethods();
53 
54  // Assert
55  try {
56  $ref_id = $path_resolver->getRefIdForWebDAVPath($too_short_path);
57  } catch (\Sabre\DAV\Exception\BadRequest $e) {
58  $correct_exception_thrown = $e->getMessage() == 'Invalid mountpoint given';
59  }
60 
61  // Act
62  $this->assertTrue($correct_exception_thrown);
63  }

◆ getRefIdForWebDAVPath_pathHasOnlyOneElement_ThrowBadRequest()

ilWebDAVUriPathResolverTest::getRefIdForWebDAVPath_pathHasOnlyOneElement_ThrowBadRequest ( )

Test:

Definition at line 26 of file ilWebDAVUriPathResolverTest.php.

27  {
28  $path_resolver = new ilWebDAVUriPathResolver($this->mocked_repo_helper);
29  $too_short_path = "some_string_without_a_slash";
30  $correct_exception_thrown = false;
31 
32  try {
33  $path_resolver->getRefIdForWebDAVPath($too_short_path);
34  } catch (\Sabre\DAV\Exception\BadRequest $e) {
35  $correct_exception_thrown = $e->getMessage() == 'Path too short';
36  }
37 
38  $this->assertTrue($correct_exception_thrown);
39  }
Class ilWebDAVUriPathResolver.

◆ getRefIdForWebDAVPath_repoRootAsMountGiven_callAndReturnValueOfGetRefIdFromPathInRepositoryMount()

ilWebDAVUriPathResolverTest::getRefIdForWebDAVPath_repoRootAsMountGiven_callAndReturnValueOfGetRefIdFromPathInRepositoryMount ( )

Test:

Definition at line 69 of file ilWebDAVUriPathResolverTest.php.

70  {
71  // Arrange
72  $too_short_path = "some_string_with_a_slash/ILIAS";
73  $expected_ref_id = 40;
74 
75  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
76  $path_resolver->shouldAllowMockingProtectedMethods();
77  $path_resolver->shouldReceive('getRefIdFromPathInRepositoryMount')->andReturn($expected_ref_id);
78 
79  // Assert
80  $received_ref_id = $path_resolver->getRefIdForWebDAVPath($too_short_path);
81 
82  // Act
83  $this->assertEquals($expected_ref_id, $received_ref_id);
84  }

◆ getRefIdFromGivenParentRefAndTitlePath_pathEndsWithoutSlash_returnLastElement()

ilWebDAVUriPathResolverTest::getRefIdFromGivenParentRefAndTitlePath_pathEndsWithoutSlash_returnLastElement ( )

If a path like foo/bar/last is given, the return should be the ref_id of 'last'.

Test:

Definition at line 116 of file ilWebDAVUriPathResolverTest.php.

117  {
118  // Arrange
119  $searched_ref_id = 40;
120  $path_title_array = explode('/', "ref30/ref35/ref$searched_ref_id");
121  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
122  $path_resolver->shouldAllowMockingProtectedMethods();
123  $path_resolver->shouldReceive('getChildRefIdByGivenTitle')->andReturn(30, 35, $searched_ref_id);
124 
125  // Act
126  $result_ref = $path_resolver->getRefIdFromGivenParentRefAndTitlePath(25, $path_title_array);
127 
128  // Assert
129  $this->assertEquals($searched_ref_id, $result_ref);
130  }

◆ getRefIdFromGivenParentRefAndTitlePath_pathEndsWithSlash_returnElementBeforeSlash()

ilWebDAVUriPathResolverTest::getRefIdFromGivenParentRefAndTitlePath_pathEndsWithSlash_returnElementBeforeSlash ( )

If a path like foo/bar/last/ is given, the return should be the ref_id of 'last'.

Test:

Definition at line 93 of file ilWebDAVUriPathResolverTest.php.

94  {
95  // Arrange
96  $searched_ref_id = 40;
97  $path_title_array = explode('/', "ref30/ref35/ref$searched_ref_id/");
98 
99  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
100  $path_resolver->shouldAllowMockingProtectedMethods();
101  $path_resolver->shouldReceive('getChildRefIdByGivenTitle')->andReturn(30, 35, $searched_ref_id);
102 
103  // Act
104  $result_ref = $path_resolver->getRefIdFromGivenParentRefAndTitlePath(25, $path_title_array);
105 
106  // Assert
107  $this->assertEquals($searched_ref_id, $result_ref);
108  }

◆ getRefIdFromGivenParentRefAndTitlePath_pathStartsWithSlash_returnLastElement()

ilWebDAVUriPathResolverTest::getRefIdFromGivenParentRefAndTitlePath_pathStartsWithSlash_returnLastElement ( )

If a path like /foo//bar/last is given, the return should be the ref_id of 'last'.

Test:

Definition at line 138 of file ilWebDAVUriPathResolverTest.php.

139  {
140  // Arrange
141  $searched_ref_id = 40;
142  $path_title_array = explode('/', "ref30///ref35/ref$searched_ref_id");
143  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
144  $path_resolver->shouldAllowMockingProtectedMethods();
145  $path_resolver->shouldReceive('getChildRefIdByGivenTitle')->andReturn(30, 35, $searched_ref_id);
146 
147  // Act
148  $result_ref = $path_resolver->getRefIdFromGivenParentRefAndTitlePath(25, $path_title_array);
149 
150  // Assert
151  $this->assertEquals($searched_ref_id, $result_ref);
152  }

◆ getRefIdFromGivenParentRefAndTitlePath_pathWithDoubleSlashInBetween_returnLastElement()

ilWebDAVUriPathResolverTest::getRefIdFromGivenParentRefAndTitlePath_pathWithDoubleSlashInBetween_returnLastElement ( )

If a path like foo//bar/last is given, the return should be the ref_id of 'last'.

Test:

Definition at line 160 of file ilWebDAVUriPathResolverTest.php.

161  {
162  // Arrange
163  $searched_ref_id = 40;
164  $path_title_array = explode('/', "ref30//ref35/ref$searched_ref_id");
165  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
166  $path_resolver->shouldAllowMockingProtectedMethods();
167  $path_resolver->shouldReceive('getChildRefIdByGivenTitle')->andReturn(30, 35, $searched_ref_id);
168 
169  // Act
170  $result_ref = $path_resolver->getRefIdFromGivenParentRefAndTitlePath(25, $path_title_array);
171 
172  // Assert
173  $this->assertEquals($searched_ref_id, $result_ref);
174  }

◆ getRefIdFromGivenParentRefAndTitlePath_pathWithTrippleSlashInBetween_returnLastElement()

ilWebDAVUriPathResolverTest::getRefIdFromGivenParentRefAndTitlePath_pathWithTrippleSlashInBetween_returnLastElement ( )

If a path like foo///bar/last is given, the return should be the ref_id of 'last'.

Test:

Definition at line 182 of file ilWebDAVUriPathResolverTest.php.

183  {
184  // Arrange
185  $searched_ref_id = 40;
186  $path_title_array = explode('/', "ref30///ref35/ref$searched_ref_id");
187  $path_resolver = \Mockery::mock('ilWebDAVUriPathResolver')->makePartial();
188  $path_resolver->shouldAllowMockingProtectedMethods();
189  $path_resolver->shouldReceive('getChildRefIdByGivenTitle')->andReturn(30, 35, $searched_ref_id);
190 
191  // Act
192  $result_ref = $path_resolver->getRefIdFromGivenParentRefAndTitlePath(25, $path_title_array);
193 
194  // Assert
195  $this->assertEquals($searched_ref_id, $result_ref);
196  }

◆ setUp()

ilWebDAVUriPathResolverTest::setUp ( )
protected

Setup.

Definition at line 11 of file ilWebDAVUriPathResolverTest.php.

12  {
13  require_once('./Services/WebDAV/classes/tree/class.ilWebDAVUriPathResolver.php');
14  require_once('./Services/WebDAV/classes/class.ilWebDAVRepositoryHelper.php');
15 
16  $this->mocked_repo_helper = \Mockery::mock('ilWebDAVRepositoryHelper');
17 
18  parent::setUp();
19  }

Field Documentation

◆ $mocked_repo_helper

ilWebDAVUriPathResolverTest::$mocked_repo_helper
protected

Definition at line 6 of file ilWebDAVUriPathResolverTest.php.


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