Skip to content

Commit

Permalink
Adding backend tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Sik committed Oct 28, 2015
1 parent dd32aeb commit 202b59a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/tests/TransformerTest.php
Expand Up @@ -93,6 +93,14 @@ public function testNonArrayableItem()
$this->assertTrue(is_array($item));
}

public function testNullItem()
{
$item = $this->transformer->transformItem(null);

$this->assertTrue(is_null($item));
}


public function testRelationSelf()
{
/** @var App\Models\TestEntity $entity */
Expand Down
26 changes: 26 additions & 0 deletions api/tests/integration/UserTest.php
Expand Up @@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

use App\Models\Image;
use App\Models\User;
use App\Models\UserProfile;
use Illuminate\Support\Facades\Cache;
Expand Down Expand Up @@ -166,6 +167,7 @@ public function testPutOne()
$this->assertEquals($user['firstName'], $createdUser->first_name);
$this->assertObjectNotHasAttribute('_userCredential', $response);
$this->assertObjectNotHasAttribute('_userProfile', $response);
$this->assertObjectNotHasAttribute('_uploadedAvatar', $response);
}

public function testPutOneNoCredentials()
Expand Down Expand Up @@ -521,4 +523,28 @@ public function testUpdateEmailConfirmedInvalidToken()
]);
$this->assertResponseStatus(422);
}

public function testGetAvatarImage()
{
$avatar = factory(Image::class)->create();

$user = $this->createUser([
'avatar_img_id' => $avatar->image_id
]);

$token = $this->tokenFromUser($user);

$this->getJson('/users/'.$user->user_id, [
'HTTP_AUTHORIZATION' => 'Bearer '.$token,
'With-Nested' => 'uploadedAvatar',
]);

$this->assertResponseOk();
$this->shouldReturnJson();

$response = json_decode($this->response->getContent(), true);

$this->assertEquals($response['_uploadedAvatar']['imageId'], $avatar->image_id);

}
}

0 comments on commit 202b59a

Please sign in to comment.