/**
  * Search articles using title and asserting
  * for the passed page.
  **/
 public function testRouteListArticlesWithTitlePageWithLimitJsonReturned()
 {
     $term = 'test search title';
     $page = 3;
     $limit = 40;
     Scenario::prepareArticle(null, $term, $limit * $page);
     $response = $this->assertOk('GET', '/api/articles/search/' . $term . '?page=' . $page . '&limit=' . $limit);
     $this->assertCount($limit, $response->articles);
     $this->assertEquals($page, $response->page);
     $this->assertEquals($term . 80, $response->articles[0]->title);
 }
 /**
  * Tests the listing with
  * a provided pagination.
  **/
 public function testRepositoryListArticlesProvidedPaginationCount()
 {
     Scenario::prepareArticle(null, 'testing pagination', 40);
     $articles = $this->repo->listArticles(null, null, 40);
     $this->assertCount(40, $articles);
 }
 /**
  * Tries to get an inexistent edition.
  *
  * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
  **/
 public function testRepositoryEditionAtIndexNotFoundException()
 {
     $article = Scenario::prepareArticle();
     $this->repo->editionAtIndex($article->id, 1233213);
 }
 /**
  * Tests if the user was updated.
  **/
 public function testUpdateUserUserUpdated()
 {
     $changedName = 'pepe moreno';
     $changedPassword = '******';
     $response = $this->assertOk('PUT', 'auth/user', ['name' => $changedName, 'password' => $changedPassword, 'passwordConfirm' => $changedPassword]);
     $user = Scenario::getLoggedUser();
     $this->assertEquals($user->id, $response->user->id);
     $this->assertEquals($user->email, $response->user->email);
     $this->assertEquals($user->name, $response->user->name);
     // Checks the changed password,
     // as it won't be returned in the json.
     $updatedUser = User::findOrFail($user->id);
     $isValid = App::make('hash')->check($changedPassword, $updatedUser->password);
     $this->assertTrue($isValid);
 }
 /**
  * Tests the request of an article's editions
  * history the passed limit and the
  * expected page results.
  **/
 public function testRouteGetEditionsHistoryHistoryPaginatedAndLimitedJsonReturned()
 {
     $limit = 40;
     $page = 3;
     $editions = Scenario::prepareEdition(null, null, 'content', $page * $limit);
     $response = $this->assertOk('GET', '/api/articles/' . $editions[0]->article_id . '/editions?limit=' . $limit . '&page=' . $page);
     $this->assertCount($limit, $response->editions);
     $this->assertEquals($page, $response->page);
     $this->assertEquals('content80', $response->editions[0]->content);
 }
Пример #6
0
 /**
  * Tests if the updateUser method
  * on the repo is working.
  **/
 public function testRepoUpdateUserUserUpdated()
 {
     $user = Scenario::prepareUser();
     $this->repo->update($user, 'new test name', 'new pass test');
     $this->seeInDatabase('users', ['id' => $user->id, 'email' => $user->email, 'name' => 'new test name']);
 }
Пример #7
0
 /**
  * Sets up and logs a new user to
  * be used within the tests.
  **/
 public function setupLoggedUser()
 {
     Scenario::prepareAndLogUser();
 }