public function testUpdateRecord()
 {
     $seed = $this->seed();
     $seedId = array_get($seed, 'id.S');
     $newName = 'New Name';
     $this->testModel = $this->testModel->find($seedId);
     $updated = $this->testModel->update(['name' => $newName]);
     $this->assertTrue($updated);
     $query = ['TableName' => $this->testModel->getTable(), 'Key' => ['id' => ['S' => $seedId]]];
     $record = $this->dynamoDbClient->getItem($query)->toArray();
     $this->assertEquals($newName, array_get($record, 'Item.name.S'));
 }
Esempio n. 2
0
 /** 
  * Test iterator's toJSON() method
  */
 public function testIteratorJSON()
 {
     TestModel::getCollection()->drop();
     $names = array('A', 'B', 'C');
     foreach ($names as $name) {
         $m = new TestModel();
         $m->name = $name;
         $m->update();
     }
     $json = TestModel::search(array(), array('name' => 1))->toJSON();
     $data = json_decode($json, true);
     $i = 0;
     foreach ($data as $row) {
         $this->assertEquals($names[$i++], $row['name']);
     }
 }
Esempio n. 3
0
 public function testGetCountModel()
 {
     for ($i = 0; $i < 10; $i++) {
         $model = new TestModel();
         $model->title = 'title ' . $i;
         $model->description = 'A small desc ' . $i;
         $model->create();
     }
     $model->title = 'update to have 11 records and 10 head';
     $model->update();
     $m = new TestModel();
     $this->assertEquals(10, $m->getCount());
 }