/** * @group postgres * @test */ public function shouldBatchInsertWithoutReturning() { //given $product1 = Product::create(array('name' => 'product1')); $order1 = Order::create(array('name' => 'order1')); $product2 = Product::create(array('name' => 'product2')); $order2 = Order::create(array('name' => 'order2')); $inserter = new BatchInserter(); $inserter->add(new OrderProduct(array('id_order' => $order1->getId(), 'id_product' => $product1->getId()))); $inserter->add(new OrderProduct(array('id_order' => $order2->getId(), 'id_product' => $product2->getId()))); //when $inserter->execute(); //then $this->assertNotNull(OrderProduct::where(array('id_order' => $order1->getId()))->fetch()); $this->assertNotNull(OrderProduct::where(array('id_order' => $order2->getId()))->fetch()); }
/** * @test */ public function shouldFetchRelationThroughNullRelation() { $order = Order::create(array('name' => 'name')); OrderProduct::create(array('id_order' => $order->getId())); //when $orderProducts = OrderProduct::where()->with('product->category')->fetchAll(); //then $this->assertNull($orderProducts[0]->product); }
/** * @test */ public function shouldInsertRecordWithoutValues() { // when $order = Order::create(array()); // then $this->assertNotNull($order); $this->assertNotNull($order->getId()); $this->assertNull($order->name); }