public function testBatchRemoveForCompositePrimaryKey() { $ids = []; $depart = new UserDepartmentAssignment(); $depart->userId = 1; $depart->departmentId = 2; $depart->save(false); $ids[] = ['userId' => $depart->userId, 'departmentId' => $depart->departmentId]; $depart = new UserDepartmentAssignment(); $depart->userId = 3; $depart->departmentId = 5; $depart->save(false); $ids[] = ['departmentId' => $depart->departmentId, 'userId' => $depart->userId]; for ($i = 0; $i < 2; $i++) { $depart = new UserDepartmentAssignment(); $depart->userId = $i + 1; $depart->departmentId = $i * 2; } Yii::$app->request->setBodyParams($ids); $this->specify('Remove a AR with single primary key', function () { $action = new BatchRemoveAction("batch-remove", null, ['modelClass' => 'tests\\codeception\\unit\\models\\base\\UserDepartmentAssignment']); $n = $action->run(); expect("Number of deleted records should be 2: ", $n)->equals(2); }); }