Example #1
0
 /**
  * Tests Collection::createIfNotExist
  *
  * @author Serghei Iakovlev <*****@*****.**>
  * @since  2016-03-13
  */
 public function testShouldCreateIfNotExistDocument()
 {
     $this->specify("Collection::createIfNotExist does not work correctly", function () {
         $song = new Songs();
         $song->artist = 'Cinema Strange';
         $song->name = 'Catacomb Kittens';
         expect($song->createIfNotExist(['name', 'artist']))->true();
         $song = new Songs();
         $song->artist = 'Cinema Strange';
         $song->name = 'Catacomb Kittens';
         expect($song->createIfNotExist(['name', 'artist']))->false();
         expect(Songs::count())->equals(5);
         expect(Songs::count([['artist' => 'Cinema Strange']]))->equals(2);
     });
 }