tests/DatalogTest.php
/**
     * @testdox Foreign key modifications are tracked in the datalog by their titles (rather than IDs).
     * This means that modifications to one record's title may result in changes appearing in the datalog of other
     * records.
     * @test
     */
@testdox Foreign key modifications are tracked in the datalog by their titles (rather than IDs).
This means that modifications to one record's title may result in changes appearing in the datalog of other
records.
@test
@testdox Foreign key modifications are tracked in the datalog by their titles ( rather than IDs ) . This means that modifications to one record ' s title may result in changes appearing in the datalog of other records . @test
public function foreignKeyTitles()
    {
        $user = $this->getTestUser();
        $book1 = new Model\Book();
        $book1->setUser($user);
        $book1->title = 'Test Book with FK';
        $book1->save();
        $this->assertEquals(1, $book1->id);
        $this->assertEquals('Test Book with FK', $book1->title);
        $this->assertCount(2, $book1->getDatalog());
        $author = new Model\Author();
        $author->setUser($user);
        $author->name = 'Book Author';
        $author->save();
        $this->assertCount(2, $author->getDatalog());
        $book = new Model\Book();
        $book->setUser($user);
        $book->title = 'Test Book';
        $book->author_id = $author->id;
        $book->save();
        $this->assertCount(3, $book->getDatalog());
        $datalog = $book->getDatalog();
        $this->assertEquals('author_id', $datalog[1]->field);
        $this->assertEquals('Book Author', $datalog[1]->new_value);
    }
public function foreignKeyTitles ( ) { $ user = $ this -> getTestUser ( ) ; $ book1 = new Model \ Book ( ) ; $ book1 -> setUser ( $ user ) ; $ book1 -> title = 'Test Book with FK' ; $ book1 -> save ( ) ; $ this -> assertEquals ( 1 , $ book1 -> id ) ; $ this -> assertEquals ( 'Test Book with FK' , $ book1 -> title ) ; $ this -> assertCount ( 2 , $ book1 -> getDatalog ( ) ) ; $ author = new Model \ Author ( ) ; $ author -> setUser ( $ user ) ; $ author -> name = 'Book Author' ; $ author -> save ( ) ; $ this -> assertCount ( 2 , $ author -> getDatalog ( ) ) ; $ book = new Model \ Book ( ) ; $ book -> setUser ( $ user ) ; $ book -> title = 'Test Book' ; $ book -> author_id = $ author -> id ; $ book -> save ( ) ; $ this -> assertCount ( 3 , $ book -> getDatalog ( ) ) ; $ datalog = $ book -> getDatalog ( ) ; $ this -> assertEquals ( 'author_id' , $ datalog [ 1 ] -> field ) ; $ this -> assertEquals ( 'Book Author' , $ datalog [ 1 ] -> new_value ) ; }
@testdox Foreign key modifications are tracked in the datalog by their titles (rather than IDs).
@testdox Foreign key modifications are tracked in the datalog by their titles ( rather than IDs ) .
// Set up. // Create an author. // Create a book. // Check that the recorded value for author_id was actually the title of the Author record.