Skip to content

Commit

Permalink
Update testing 404 and 403
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancoisbbs committed Sep 17, 2016
1 parent 094677e commit bf68057
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
6 changes: 4 additions & 2 deletions tests/Http/Controllers/Admin/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,13 @@ public function testSaveProfileNotAuthorize()

try
{
$this->call('POST', action($this->controller.'@postProfile'), [
$response = $this->call('POST', action($this->controller.'@postProfile'), [
'id' => $userOther->id,
'email' => str_replace('\'', '', $faker->email)
]);
$this->assertTrue(false);

$this->assertEquals(403,$response->getStatusCode());

} catch (\Symfony\Component\HttpKernel\Exception\HttpException $e)
{
$this->assertEquals(trans('permission-util::errors.unthorized'), $e->getMessage());
Expand Down
42 changes: 21 additions & 21 deletions tests/Http/Controllers/Front/AssetControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
<?php

class AssetControllerTest extends ExpendableTestCase {
class AssetControllerTest extends ExpendableTestCase
{

protected $controller = 'Front\AssetController';


public function testAssetNotFound()
{
try
{
$this->call('GET', 'storage/moximanager/'.rand());
$this->assertTrue(false);
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
try {
$response = $this->call('GET', 'storage/moximanager/' . rand());
$this->assertEquals(404, $response->getStatusCode());

} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
$this->assertTrue(true);
}

}

public function testAssetNotAllowed()
{

\File::makeDirectory(storage_path('other'),0755,false,true);
copy(realpath(__DIR__.'/../../../data/5601729.gif'), storage_path('other/5601729.gif'));
\File::makeDirectory(storage_path('other'), 0755, false, true);
copy(realpath(__DIR__ . '/../../../data/5601729.gif'), storage_path('other/5601729.gif'));

try {
$response = $this->call('GET', 'storage/other/5601729.gif');
$this->assertEquals(404, $response->getStatusCode());

try
{
$this->call('GET', 'storage/other/5601729.gif');
$this->assertTrue(false);
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
$this->assertTrue(true);
}

}

public function testAssetFound()
{
\File::makeDirectory(storage_path('moximanager'),0755,false,true);
\File::makeDirectory(storage_path('moximanager'), 0755, false, true);

copy(realpath(__DIR__.'/../../../data/exports/2015-03-17 2015-03-19.csv'), storage_path('moximanager/2015-03-172015-03-19.csv'));
copy(realpath(__DIR__ . '/../../../data/exports/2015-03-17 2015-03-19.csv'), storage_path('moximanager/2015-03-172015-03-19.csv'));
$response = $this->call('GET', 'storage/moximanager/2015-03-172015-03-19.csv');
$this->assertEquals(200,$response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode());
}

public function testAssetImageFound()
{
\File::makeDirectory(storage_path('moximanager'),0755,false,true);
\File::makeDirectory(storage_path('moximanager'), 0755, false, true);

copy(realpath(__DIR__.'/../../../data/5601729.gif'), storage_path('moximanager/5601729.gif'));
copy(realpath(__DIR__ . '/../../../data/5601729.gif'), storage_path('moximanager/5601729.gif'));
$response = $this->call('GET', 'storage/moximanager/5601729.gif');
$this->assertEquals(200,$response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode());
}
}

0 comments on commit bf68057

Please sign in to comment.