public function testMetaRelationshipReturnsModels()
 {
     $user = Factory::create('User', ['id' => 1]);
     Factory::times(2)->create('PostMeta', ['meta_key' => 'pal_user_id', 'meta_value' => 1]);
     $meta = $user->meta;
     assertThat($meta, is(traversableWithSize(2)));
 }
 public function testCreateRelatedMetaModelsWhenCreatesNewGallery()
 {
     $attributes = ['post_content' => 'Dummy content.', 'post_title' => 'Dummy Title 1', 'post_date' => date('Y-m-d H:i:s'), 'pal_user_id' => 1, 'pal_gallery_id' => 1];
     $gallery = Gallery::create($attributes);
     $meta = $gallery->meta;
     assertThat($meta, is(traversableWithSize(2)));
 }
 public function testUsersRelationshipReturnsModels()
 {
     $host = Factory::create('Host');
     Factory::create('User', ['id' => 1, 'host_id' => 1]);
     Factory::create('User', ['id' => 2, 'host_id' => 1]);
     $users = $host->users;
     assertThat($host->users, is(traversableWithSize(2)));
 }
 public function testShouldFormatTraversableAccordingToConvertMethod()
 {
     $items = ['foo', 'bar', 'baz'];
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result of `formatTraversable` should be a Generator.', $result, is(anInstanceOf('Generator')));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('Every item in the result should be an array.', iterator_to_array($result), everyItem(is(typeOf('array'))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be the same size as the number of items passed to `formatTraversable`.', $result, is(traversableWithSize(count($items))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be correctly formatted.', iterator_to_array($result), is(anArray([['count' => 1], ['count' => 2], ['count' => 3]])));
 }
 public function testHasAReadableDescription()
 {
     $this->assertDescription('a traversable with size <3>', traversableWithSize(equalTo(3)));
 }
 public function testGetByUsersCreatesNewGalleries()
 {
     $galleryStubs = [$this->galleryStub, $this->galleryStub];
     $stub = Mockery::mock('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface')->shouldReceive('setAuth')->times(2)->andReturn(Mockery::self())->shouldReceive('all')->times(2)->andReturn($galleryStubs)->getMock();
     $mock = Test::double('RemoteGallery', ['newModel' => $stub]);
     $userStubs = [['host' => 'DummyHost', 'credentials' => ['foo']], ['host' => 'AnotherDummyHost', 'credentials' => ['bar']]];
     $galleries = RemoteGallery::getByUsers($userStubs);
     $mock->verifyInvokedMultipleTimes('setHost', 2);
     $mock->verifyInvokedMultipleTimes('newModel', 2);
     $mock->verifyInvokedMultipleTimes('modifyAttributes', 4);
     $mock->verifyInvoked('newCollection');
     assertThat($galleries, is(traversableWithSize(4)));
 }