src/Database/Column.php
public function foreign($table, $column = 'id', $onUpdate = 'cascade', $onDelete = 'cascade')
    {
        if (DB::connection() instanceof \Illuminate\Database\SQLiteConnection) {
            $this->context->markTestIncomplete('Foreign keys cannot be tested with a SQLite database.');

            return $this;
        }

        $name = $this->getIndexName('foreign');
        $this->assertTrue($this->table->hasForeignKey($name), "The foreign key {$name} does not exist.");

        $key = $this->table->getForeignKey($name);
        $onUpdate && $this->context->assertEquals(strtoupper($onUpdate), $key->onUpdate());
        $onDelete && $this->context->assertEquals(strtoupper($onDelete), $key->onDelete());

        $this->context->assertEquals($table, $key->getForeignTableName());
        $this->context->assertContains($column, $key->getForeignColumns());

        return $this;
    }
public function foreign($table, $column = 'id', $onUpdate = 'cascade', $onDelete = 'cascade')
    {
        if (DB::connection() instanceof \Illuminate\Database\SQLiteConnection) {
            $this->context->markTestIncomplete('Foreign keys cannot be tested with a SQLite database.');

            return $this;
        }

        $name = $this->getIndexName('foreign');
        $this->assertTrue($this->table->hasForeignKey($name), "The foreign key {$name} does not exist.");

        $key = $this->table->getForeignKey($name);
        $onUpdate && $this->context->assertEquals(strtoupper($onUpdate), $key->onUpdate());
        $onDelete && $this->context->assertEquals(strtoupper($onDelete), $key->onDelete());

        $this->context->assertEquals($table, $key->getForeignTableName());
        $this->context->assertContains($column, $key->getForeignColumns());

        return $this;
    }
public function foreign ( $ table , $ column = 'id' , $ onUpdate = 'cascade' , $ onDelete = 'cascade' ) { if ( DB :: connection ( ) instanceof \ Illuminate \ Database \ SQLiteConnection ) { $ this -> context -> markTestIncomplete ( 'Foreign keys cannot be tested with a SQLite database.' ) ; return $ this ; } $ name = $ this -> getIndexName ( 'foreign' ) ; $ this -> assertTrue ( $ this -> table -> hasForeignKey ( $ name ) , "The foreign key {$name} does not exist." ) ; $ key = $ this -> table -> getForeignKey ( $ name ) ; $ onUpdate && $ this -> context -> assertEquals ( strtoupper ( $ onUpdate ) , $ key -> onUpdate ( ) ) ; $ onDelete && $ this -> context -> assertEquals ( strtoupper ( $ onDelete ) , $ key -> onDelete ( ) ) ; $ this -> context -> assertEquals ( $ table , $ key -> getForeignTableName ( ) ) ; $ this -> context -> assertContains ( $ column , $ key -> getForeignColumns ( ) ) ; return $ this ; }
Assert that the table has a foreign key relationship.

@param  string $table
@param  string $column
@param  string $onUpdate
@param  string $onDelete
@return $this
Assert that the table has a foreign key relationship .