| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace AccessTests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use CommonTestClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use kalanis\kw_files\Access\CompositeAdapter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use kalanis\kw_files\FilesException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use kalanis\kw_files\Interfaces\IProcessDirs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use kalanis\kw_files\Interfaces\IProcessFiles; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use kalanis\kw_files\Interfaces\IProcessNodes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use kalanis\kw_paths\PathsException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class CompositeTest extends CommonTestClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @throws FilesException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @throws PathsException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public function testBasic(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $lib = new CompositeAdapter(new XProcessNode(), new XProcessDir(), new XProcessFile()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->assertInstanceOf(XProcessNode::class, $lib->getNode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->assertInstanceOf(XProcessDir::class, $lib->getDir()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->assertInstanceOf(XProcessFile::class, $lib->getFile()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->assertFalse($lib->exists([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->assertFalse($lib->isReadable([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->assertFalse($lib->isReadable([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertFalse($lib->isWritable([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertFalse($lib->isDir([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->assertFalse($lib->isFile([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->assertNull($lib->size([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->assertNull($lib->created([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->assertTrue($lib->createDir([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->assertEmpty($lib->readDir([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $this->assertTrue($lib->copyDir([], [])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->assertTrue($lib->moveDir([], [])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->assertTrue($lib->deleteDir([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->assertTrue($lib->saveFile([], '')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->assertEmpty($lib->readFile([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->assertTrue($lib->copyFile([], [])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->assertTrue($lib->moveFile([], [])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->assertTrue($lib->deleteFile([])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | class XProcessNode implements IProcessNodes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     public function exists(array $entry): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     public function isReadable(array $entry): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function isWritable(array $entry): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     public function isDir(array $entry): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function isFile(array $entry): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     public function size(array $entry): ?int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public function created(array $entry): ?int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | class XProcessDir implements IProcessDirs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     public function createDir(array $entry, bool $deep = false): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     public function readDir(array $entry, bool $loadRecursive = false, bool $wantSize = false): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     public function copyDir(array $source, array $dest): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     public function moveDir(array $source, array $dest): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function deleteDir(array $entry, bool $deep = false): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | class XProcessFile implements IProcessFiles | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function saveFile(array $entry, $content): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     public function readFile(array $entry, ?int $offset = null, ?int $length = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     public function copyFile(array $source, array $dest): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     public function moveFile(array $source, array $dest): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |     public function deleteFile(array $entry): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 148 |  |  |  |