getInstance(); $storage->setUpload($file); $storage->addLocalCopies($file, 'baz'); $this->assertTrue(in_array('baz', $storage->getLocalCopies($file))); } public function testAddLocalCopies() { $file = new File('foo', 'bar'); $storage = $this->getInstance(); $storage->setUpload($file); $storage->addLocalCopies($file, 'baz'); $storage->addLocalCopies($file, 'qux'); $this->assertTrue(in_array('baz', $storage->getLocalCopies($file))); $this->assertTrue(in_array('qux', $storage->getLocalCopies($file))); $this->assertCount(2, $storage->getLocalCopies($file)); } public function testGetLocalCopies() { $file = new File('foo', 'bar'); $storage = $this->getInstance(); $storage->setUpload($file); $this->assertEquals([], $storage->getLocalCopies($file)); $storage->addLocalCopies($file, 'baz'); $storage->addLocalCopies($file, 'qux'); $this->assertTrue(in_array('baz', $storage->getLocalCopies($file))); $this->assertTrue(in_array('qux', $storage->getLocalCopies($file))); $this->assertCount(2, $storage->getLocalCopies($file)); } public function testRemoveFiles() { $file = new File('foo', 'bar'); $storage = $this->getInstance(); $storage->setUpload($file); $storage->addLocalCopies($file, 'baz'); $this->assertTrue(in_array('baz', $storage->getLocalCopies($file))); $storage->removeFiles($file); $this->assertEquals([], $storage->getLocalCopies($file)); } /** * @return TmpLocalAwareStorageInterface * @throws \common_Exception */ private function getInstance() { /** @var TempFlyStorageAssociation $instance */ return new TempFlyStorageAssociation($this->getServiceManagerMock()); } /** * @return ServiceManager * @throws \common_Exception */ private function getServiceManagerMock() { $config = new \common_persistence_KeyValuePersistence([], new \common_persistence_InMemoryKvDriver()); $serviceManager = new ServiceManager($config); $pmProphecy = $this->prophesize(PersistenceManager::class); $pmProphecy->setServiceLocator(Argument::any())->willReturn(null); $pmProphecy->getPersistenceById('default_kv') ->willReturn(new \common_persistence_KeyValuePersistence([], new \common_persistence_InMemoryKvDriver())); $pm = $pmProphecy->reveal(); $serviceManager->register(PersistenceManager::SERVICE_ID, $pm); return $serviceManager; } }