public function testUnsetBelongsTo() { $details = BookDetails::selectOne($this->getConn())->where('books_id', 2)->execute(); $this->assertTrue($details->hasRelation('book')); $this->assertSame($details->books_id, $details->book->id); $details->book = 0; $this->assertFalse($details->hasRelation('book')); $this->assertSame(0, $details->books_id); }
/** * @dataProvider unsetRelationProvider */ public function testUnsetRelationBelongsTo($value) { $book = new Book($this->conn, ['id' => 3]); $details = new BookDetails($this->conn, ['books_id' => 5]); $details->associateRelation('book', $book); $this->assertSame(3, $details->books_id); $this->assertSame($book, $details->book); $details->unsetRelation('book', $value); $this->assertSame($value, $details->books_id); $this->assertFalse($details->book); }