Skip to content

Instantly share code, notes, and snippets.

@c9s
Created April 10, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/f42ecf45093f85ccab7c5157d319c563 to your computer and use it in GitHub Desktop.
Save c9s/f42ecf45093f85ccab7c5157d319c563 to your computer and use it in GitHub Desktop.
<?php
public function testRepoFetchColumn()
{
$this->assertResultSuccess(Book::create([ 'title' => 'Book 1' ]));
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
// create one book with duplicated title
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
$q = Book::masterRepo()->select('DISTINCT title');
$titles = $q->fetchColumn(0);
$this->assertCount(2, $titles);
foreach ($titles as $title) {
$this->assertStringMatchesFormat('Book %i', $title);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment