public function testListContents() { $mock = $this->getS3Client(); $mock->shouldReceive('listObjects')->once()->andReturn(Mockery::self()); $result = array('Contents' => array(array('Key' => 'path', 'ContentLength' => 20, 'ContentType' => 'text/plain'))); $mock->shouldReceive('getAll')->with(array('Contents'))->andReturn($result); $adapter = new Adapter($mock, 'bucketname'); $listing = $adapter->listContents(); $this->assertCount(1, $listing); $item = reset($listing); $this->assertArrayHasKey('path', $item); $this->assertArrayHasKey('type', $item); $this->assertArrayHasKey('mimetype', $item); }
public function testListContents() { $mock = $this->getS3Client(); $result = new \ArrayIterator(array(array('Key' => 'file.ext', 'ContentLength' => 20, 'ContentType' => 'text/plain'), array('Key' => 'path/to_another/dir/'))); $mock->shouldReceive('getIterator')->once()->andReturn($result); $adapter = new Adapter($mock, 'bucketname'); $listing = $adapter->listContents(); $this->assertCount(4, $listing); $first = reset($listing); $this->assertArrayHasKey('path', $first); $this->assertArrayHasKey('type', $first); $this->assertArrayHasKey('mimetype', $first); $last = end($listing); $this->assertArrayHasKey('path', $first); $this->assertArrayHasKey('type', $first); $this->assertEquals($last['type'], 'dir'); }