Esempio n. 1
0
 /**
  * Test exists()
  *
  * @return void
  */
 public function testExists()
 {
     $rootDir = '/' . uniqid('test_', true);
     $response = new Response(200, ['Content-Type' => 'application/json'], file_get_contents(__DIR__ . '/../../assets/DirectoryTest_getAll.json'));
     $mockedClient = $this->getMockBuilder('\\Seafile\\Client\\Http\\Client')->getMock();
     $mockedClient->method('getConfig')->willReturn('http://example.com/');
     // expect 3 requests...
     $mockedClient->expects($this->exactly(2))->method('request')->with(self::equalTo('GET'), self::equalTo('http://example.com/repos/some-crazy-id/dir/'), self::equalTo(['query' => ['p' => $rootDir]]))->willReturn($response);
     /**
      * @var Client $mockedClient
      */
     $directoryResource = new Directory($mockedClient);
     $lib = new Library();
     $lib->id = 'some-crazy-id';
     self::assertFalse($directoryResource->exists($lib, 'does_not_exist', $rootDir));
     // ...2nd request...
     // ...3rd request. For 'test_dir' see mock response json file, it's there
     self::assertTrue($directoryResource->exists($lib, 'test_dir', $rootDir));
 }