I used this package to define my model class.
When I run my unit test, I got this:
Call to a member function getMarshaler() on null
at vendor/baopham/dynamodb/src/DynamoDbModel.php:115
111▕ }
112▕
113▕ protected function setupDynamoDb()
114▕ {
➜ 115▕ $this->marshaler = static::$dynamoDb->getMarshaler();
116▕ $this->attributeFilter = static::$dynamoDb->getAttributeFilter();
117▕ }
118▕
119▕ public function newCollection(array $models = [], $index = null)
I have added service provider like this in boostrap/providers.php:
I tried to register the BaoPham\DynamoDb\DynamoDbServiceProvider::class, before AppServiceProvider too but couldn't work.
This is my model class:
<?php
namespace App\Models;
use BaoPham\DynamoDb\DynamoDbModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class MyModel extends DynamoDbModel
{
use HasFactory;
/**
* The composite key of the table in form of ['hash_key', 'range_key'].
*
* @var array
*/
protected $compositeKey = ['key', 'timestamp'];
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = ['key', 'timestamp', 'value'];
}
The test that I ran:
<?php
use App\Models\MyModel;
it('can fill key, timestamp, and value attributes', function () {
$attributes = [
'key' => 'test-key',
'timestamp' => time(),
'value' => 'test-value',
];
$keyValue = new KeyValue($attributes);
expect($keyValue->key)->toBe($attributes['key']);
expect($keyValue->timestamp)->toBe($attributes['timestamp']);
expect($keyValue->value)->toBe($attributes['value']);
});
Describe the bug
I used this package to define my model class. When I run my unit test, I got this:
I have added service provider like this in
boostrap/providers.php
:I tried to register the
BaoPham\DynamoDb\DynamoDbServiceProvider::class,
beforeAppServiceProvider
too but couldn't work.This is my model class:
The test that I ran:
Schema
protected $compositeKey = ['key', 'timestamp'];
Version info