You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
998 B
53 lines
998 B
<?php |
|
|
|
namespace yiiunit\extensions\mongo\file; |
|
|
|
use yii\mongo\file\Query; |
|
use yiiunit\extensions\mongo\MongoTestCase; |
|
|
|
/** |
|
* @group mongo |
|
*/ |
|
class QueryTest extends MongoTestCase |
|
{ |
|
protected function setUp() |
|
{ |
|
parent::setUp(); |
|
$this->setUpTestRows(); |
|
} |
|
|
|
protected function tearDown() |
|
{ |
|
$this->dropFileCollection(); |
|
parent::tearDown(); |
|
} |
|
|
|
/** |
|
* Sets up test rows. |
|
*/ |
|
protected function setUpTestRows() |
|
{ |
|
$collection = $this->getConnection()->getFileCollection(); |
|
for ($i = 1; $i <= 10; $i++) { |
|
$collection->storeBytes('content' . $i, ['filename' => 'name' . $i]); |
|
} |
|
} |
|
|
|
// Tests : |
|
|
|
public function testAll() |
|
{ |
|
$connection = $this->getConnection(); |
|
$query = new Query; |
|
$rows = $query->from('fs')->all($connection); |
|
$this->assertEquals(10, count($rows)); |
|
} |
|
|
|
public function testOne() |
|
{ |
|
$connection = $this->getConnection(); |
|
$query = new Query; |
|
$row = $query->from('fs')->one($connection); |
|
$this->assertTrue($row instanceof \MongoGridFSFile); |
|
} |
|
} |