public function testScriptFields() { $orderItems = OrderItem::find()->fields(['quantity', 'subtotal', 'total' => ['script' => "doc['quantity'].value * doc['subtotal'].value"]])->all(); foreach ($orderItems as $item) { $this->assertEquals($item->subtotal * $item->quantity, $item->total); } }