Commit 6590854b authored by Jeremy Mikola's avatar Jeremy Mikola

Clean up BucketFunctionalTest

parent 9b219418
This diff is collapsed.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace MongoDB\Tests\GridFS; namespace MongoDB\Tests\GridFS;
use MongoDB\GridFS;
use MongoDB\Collection; use MongoDB\Collection;
use MongoDB\GridFS\Bucket;
use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase; use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;
/** /**
...@@ -12,28 +12,44 @@ use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase; ...@@ -12,28 +12,44 @@ use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;
abstract class FunctionalTestCase extends BaseFunctionalTestCase abstract class FunctionalTestCase extends BaseFunctionalTestCase
{ {
protected $bucket; protected $bucket;
protected $collectionWrapper; protected $chunksCollection;
protected $filesCollection;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
foreach(['fs.files', 'fs.chunks'] as $collection){
$col = new Collection($this->manager, $this->getDatabaseName(), $collection); $this->bucket = new Bucket($this->manager, $this->getDatabaseName());
$col->drop(); $this->bucket->drop();
}
$this->bucket = new \MongoDB\GridFS\Bucket($this->manager, $this->getDatabaseName()); $this->chunksCollection = new Collection($this->manager, $this->getDatabaseName(), 'fs.chunks');
$this->collectionWrapper = $this->bucket->getCollectionWrapper(); $this->filesCollection = new Collection($this->manager, $this->getDatabaseName(), 'fs.files');
} }
public function tearDown() /**
* Rewinds a stream and asserts its contents.
*
* @param string $expectedContents
* @param resource $stream
*/
protected function assertStreamContents($expectedContents, $stream)
{ {
foreach(['fs.files', 'fs.chunks'] as $collection){ $this->assertEquals($expectedContents, stream_get_contents($stream, -1,.0));
$col = new Collection($this->manager, $this->getDatabaseName(), $collection); }
$col->drop();
} /**
if ($this->hasFailed()) { * Creates an in-memory stream with the given data.
return; *
} * @param string $data
* @return resource
*/
protected function createStream($data = '')
{
$stream = fopen('php://temp', 'w+b');
fwrite($stream, $data);
rewind($stream);
return $stream;
} }
public function provideInsertChunks() public function provideInsertChunks()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment