mirror of
https://github.com/flextype/flextype.git
synced 2025-08-08 06:06:45 +02:00
feat(tests): add tests for MediaFiles fetchSingle() and fetchCollection method #477
This commit is contained in:
@@ -20,6 +20,24 @@ test('test fetch() method', function () {
|
||||
|
||||
$this->assertTrue(count(flextype('media_files')->fetch('foo.txt')) > 0);
|
||||
$this->assertEquals('Foo', flextype('media_files')->fetch('foo.txt')['title']);
|
||||
$this->assertTrue(count(flextype('media_files')->fetchCollection('/', true)) == 2);
|
||||
$this->assertTrue(count(flextype('media_files')->fetch('/', true)) == 2);
|
||||
$this->assertEquals('Foo', flextype('media_files')->fetch('/', true)['foo.txt']['title']);
|
||||
});
|
||||
|
||||
test('test fetchSingle() method', function () {
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/foo.txt')->put('foo');
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/.meta/foo.txt.yaml')->put(flextype('yaml')->encode(['title' => 'Foo', 'description' => '', 'type' => 'text/plain', 'filesize' => 3, 'uploaded_on' => 1603090370, 'exif' => []]));
|
||||
|
||||
$this->assertTrue(count(flextype('media_files')->fetchSingle('foo.txt')) > 0);
|
||||
$this->assertEquals('Foo', flextype('media_files')->fetchSingle('foo.txt')['title']);
|
||||
});
|
||||
|
||||
test('test fetchCollection() method', function () {
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/foo.txt')->put('foo');
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/.meta/foo.txt.yaml')->put(flextype('yaml')->encode(['title' => 'Foo', 'description' => '', 'type' => 'text/plain', 'filesize' => 3, 'uploaded_on' => 1603090370, 'exif' => []]));
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/bar.txt')->put('foo');
|
||||
flextype('filesystem')->file(PATH['project'] . '/uploads/.meta/bar.txt.yaml')->put(flextype('yaml')->encode(['title' => 'Bar', 'description' => '', 'type' => 'text/plain', 'filesize' => 3, 'uploaded_on' => 1603090370, 'exif' => []]));
|
||||
|
||||
$this->assertTrue(count(flextype('media_files')->fetchCollection('/')) == 2);
|
||||
$this->assertEquals('Foo', flextype('media_files')->fetchCollection('/')['foo.txt']['title']);
|
||||
});
|
||||
|
Reference in New Issue
Block a user