Example #1
0
 /**
  * TodosControllerのテスト
  *
  * @return void
  */
 public function testTodosRoutes()
 {
     // フィルタを有効にする
     Route::enableFilters();
     // GET /todos
     $response = $this->call('GET', '/todos');
     $this->assertEquals(200, $response->getStatusCode());
     // POST /todos
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos', $input);
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertHasOldInput();
     // POST /todos/1/update
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/update', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // PUT /todos/1/title
     $input = [];
     $response = $this->call('PUT', '/todos/1/title', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // POST /todos/1/delete
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/delete', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // POST /todos/1/restore
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/restore', $input);
     $this->assertEquals(404, $response->getStatusCode());
 }
 /**
  * Initializes the test step by enabling filters
  *
  * @param  bool  $enableFilters
  * @return void
  */
 protected function initTestStep($enableFilters = TRUE)
 {
     $this->be(User::first());
     if ($enableFilters) {
         Route::enableFilters();
     }
 }
 /**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     Artisan::call('migrate');
     $this->seed(__CLASS__ . 'Seeder');
     Route::enableFilters();
 }
 public function testFailToLoadDashboardBeforeLoggingIn(TestGuy $I)
 {
     Route::enableFilters();
     $I->am('a user');
     $I->amOnPage('day004_dashboard');
     $I->seeInCurrentUrl('day004_login');
 }
Example #5
0
 /**
  * Prepare for the tests to be run.
  */
 public function prepareForTests()
 {
     // Enable your route filters, very important!
     \Route::enableFilters();
     \Route::any('{all}', 'Tdt\\Core\\BaseController@handleRequest')->where('all', '.*');
     \Mail::pretend(true);
 }
 protected function prepareForTests()
 {
     parent::prepareForTests();
     Route::enableFilters();
     $this->current_realm = Config::get('app.url');
     $user = User::where('identifier', '=', 'sebastian.marcet')->first();
     $this->be($user);
     Session::start();
     $scope = $this->getScopes();
     $this->client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
     $this->client_secret = 'ITc/6Y5N7kOtGKhg';
     $params = array('client_id' => $this->client_id, 'redirect_uri' => 'https://www.test.com/oauth2', 'response_type' => OAuth2Protocol::OAuth2Protocol_ResponseType_Code, 'scope' => implode(' ', $scope), OAuth2Protocol::OAuth2Protocol_AccessType => OAuth2Protocol::OAuth2Protocol_AccessType_Offline);
     Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
     $response = $this->action("POST", "OAuth2ProviderController@authorize", $params, array(), array(), array());
     $status = $response->getStatusCode();
     $url = $response->getTargetUrl();
     $content = $response->getContent();
     $comps = @parse_url($url);
     $query = $comps['query'];
     $output = array();
     parse_str($query, $output);
     $params = array('code' => $output['code'], 'redirect_uri' => 'https://www.test.com/oauth2', 'grant_type' => OAuth2Protocol::OAuth2Protocol_GrantType_AuthCode);
     $response = $this->action("POST", "OAuth2ProviderController@token", $params, array(), array(), array("HTTP_Authorization" => " Basic " . base64_encode($this->client_id . ':' . $this->client_secret)));
     $status = $response->getStatusCode();
     $this->assertResponseStatus(200);
     $content = $response->getContent();
     $response = json_decode($content);
     $access_token = $response->access_token;
     $refresh_token = $response->refresh_token;
     $this->access_token = $access_token;
 }
 public function setUp()
 {
     parent::setUp();
     Route::enableFilters();
     $user = User::find(1);
     $this->be($user);
 }
 public function testLoginRouteRedirectsWhenLoggedIn()
 {
     Route::enableFilters();
     $user = $this->factory->create('user');
     Sentry::login($user);
     $this->client->request('GET', URL::action('AuthController@getLogin'));
     $this->assertRedirectedTo('/');
 }
 /**
  * Set session and enable Laravel filters
  *
  */
 public function setUp()
 {
     parent::setUp();
     // Enable session
     Session::start();
     // Enable filters
     Route::enableFilters();
 }
 public function setup()
 {
     parent::setUp();
     Session::start();
     //enable filters as filters are disabled by default
     Route::enableFilters();
     $this->prepareForTests();
 }
Example #11
0
 protected function request($method = 'GET', $uri = '', $params = [], $server = [], $content = null)
 {
     $files = [];
     $changeHistory = true;
     \Route::enableFilters();
     // http://laravel.com/api/4.2/Illuminate/Foundation/Testing/TestCase.html#method_call
     return $this->call($method, $uri, $params, $files, $server, $content, $changeHistory);
 }
Example #12
0
 /**
  * Creates the application.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     $unitTesting = true;
     $testEnvironment = 'testing';
     return require __DIR__ . '/../../bootstrap/start.php';
     Session::start();
     Route::enableFilters();
 }
 /**
  *
  * @return void
  */
 public function testCreateBillFailBillIdIsset()
 {
     Route::enableFilters();
     $this->call('PUT', Config::get('ff-qiwi-gate::app.url') . '/qiwi/gate/api/v2/prv/1/bills/4a5s6d', array('user' => 'tel:+79161234567', 'amount' => '123.34', 'ccy' => 'RUB', 'comment' => 'Test!'), array(), array('HTTP_Authorization' => 'Basic ' . base64_encode('1:password')));
     $oResponse = $this->response()->getData();
     $this->assertEquals(215, $oResponse->response->result_code);
     $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
 }
 public function setUp()
 {
     parent::setUp();
     Route::enableFilters();
     // Authentication as super user.
     $user = User::firstOrCreate(['email' => '*****@*****.**']);
     Auth::login($user);
 }
 public function testTracking()
 {
     Route::enableFilters();
     $request = Request::instance();
     $ab = Mockery::mock('Jamesblackwell\\AB\\Tester');
     $ab->shouldReceive('track')->with($request)->once();
     $this->app['ab'] = $ab;
     $this->app->events->fire('router.before', [$request]);
 }
Example #16
0
 public function setUp()
 {
     parent::setUp();
     Route::enableFilters();
     // готовим мерчанта
     Merchant::truncate();
     $merchant = new Merchant();
     $merchant->create(array('username' => 'username', 'password' => 'password'));
 }
 protected function prepareForTests()
 {
     parent::prepareForTests();
     Route::enableFilters();
     $this->current_realm = Config::get('app.url');
     $this->user = User::where('identifier', '=', 'sebastian.marcet')->first();
     $this->be($this->user);
     Session::start();
 }
Example #18
0
 public function testBackendAdmin()
 {
     $routes = ['admin/user/create', 'admin/user/update', 'admin/user/review', 'admin/user/register', 'admin/user/registersuccess'];
     Route::enableFilters();
     Auth::loginUsingId(5);
     foreach ($routes as $route) {
         $this->check('GET', $route);
     }
 }
Example #19
0
 /**
  * Set up function for all tests
  *
  */
 public function setUp()
 {
     parent::setUp();
     if ($this->useDatabase) {
         $this->setUpDb();
     }
     // To test auth, we must re-enable filters on the routes
     // By default, filters are disabled in testing
     Route::enableFilters();
 }
 public function setUp()
 {
     parent::setUp();
     Artisan::call('migrate');
     Artisan::call('db:seed');
     Mail::pretend(true);
     Route::enableFilters();
     App::bind('Helpers\\JsonRPCClientInterface', 'Helpers\\DummyJsonRPCClient');
     App::bind('Helpers\\DataParserInterface', 'Helpers\\DummyDataParser');
 }
 public function setUp()
 {
     // calling parent setUp()
     parent::setUp();
     // we'll need a user for each view
     // we're not using the seeded one
     // creating a new with a valid stripe key
     User::create(array('id' => '42', 'email' => '*****@*****.**', 'password' => Hash::make('supersecret'), 'balance' => 4107088039.0, 'stripe_key' => 'sk_test_YOhLG7AgROpHWUyr62TlGXmg'));
     // creating a new without a valid stripe key
     User::create(array('id' => '12', 'email' => '*****@*****.**', 'password' => Hash::make('supersecret')));
     Route::enableFilters();
 }
Example #22
0
 /**
  * Define environment setup.
  *
  * @param  \Illuminate\Foundation\Application $app
  *
  * @return void
  */
 protected function getEnvironmentSetUp($app)
 {
     $app['config']->set('database.default', 'testbench');
     $app['config']->set('database.connections.testbench', array('driver' => 'sqlite', 'database' => ':memory:', 'prefix' => ''));
     $app['config']->set('app.key', md5_file(__FILE__));
     $token = App::make('token');
     Route::get('/token/auth', array('before' => 'token.auth', function () use($token) {
         return Response::json(array('token' => $token->getCurrentToken(), 'user' => \Auth::user()));
     }));
     Route::get('/token/simple', array('before' => 'token', function () use($token) {
         return Response::json(array('token' => $token->getCurrentToken()));
     }));
     Route::enableFilters();
 }
 /**
  * Initializes the test step
  *
  * @param  bool  $authenticate
  * @param  bool  $enableFilters
  * @param  bool  $flushCaches
  * @return void
  */
 protected function initTestStep($authenticate = TRUE, $enableFilters = TRUE, $flushCaches = TRUE)
 {
     if ($authenticate) {
         $this->be(User::first());
     } else {
         Auth::logout();
     }
     if ($enableFilters) {
         Route::enableFilters();
     }
     if ($flushCaches) {
         Config::flush();
         Session::flush();
     }
 }
 public function setUp()
 {
     parent::setUp();
     Route::enableFilters();
     // Authentication as super user.
     $user = User::firstOrCreate(['email' => '*****@*****.**']);
     Auth::login($user);
     $this->createLRS();
     $vs = array('actor' => array('objectType' => 'Agent', 'mbox' => 'mailto:duy.nguyen@go1.com.au', 'name' => 'quanvm'), 'verb' => array("id" => "http://adlnet.gov/expapi/verbs/experienced", "display" => array("und" => "experienced")), 'context' => array("contextActivities" => array("parent" => array("id" => "http://tincanapi.com/GolfExample_TCAPI", "objectType" => "Activity"), "grouping" => array("id" => "http://tincanapi.com/GolfExample_TCAPI", "objectType" => "Activity"))), "object" => array("id" => "http://tincanapi.com/GolfExample_TCAPI/Playing/Scoring.html", "objectType" => "Activity", "definition" => array("name" => array("en-US" => "Scoring"), "description" => array("en-US" => "An overview of how to score a round of golf."), 'type' => 'http://activitystrea.ms/schema/1.0/badge')), "authority" => array("name" => "", "mbox" => "mailto:quan@ll.com", "objectType" => "Agent"));
     $statement = App::make('Locker\\Repository\\Statement\\EloquentStatementRepository');
     $statement->create(array($vs), $this->lrs);
     $vs2 = $vs;
     $vs2['object']['definition']['type'] = 'http://activitystrea.ms/schema/2.0/badge';
     $statement2 = App::make('Locker\\Repository\\Statement\\EloquentStatementRepository');
     $statement2->create(array($vs2), $this->lrs);
 }
Example #25
0
 public function testPermissionsCanBeSetForRoutes()
 {
     $user = $this->createUserWithRoles();
     \ACL::setUser($user);
     $controller = Mockery::mock('\\ApiController');
     $controller->shouldReceive('tests')->once()->andReturn(\Response::json(['success' => 'great']));
     $controller->shouldReceive('getActionPermissions')->once()->andReturn(['tests' => 'job.apply']);
     \Route::enableFilters();
     \Route::filter('test.permissions.filter', function ($route) {
         require 'app/acl.php';
         $permissions = $route->getAction()['uses'][0]->getActionPermissions();
         $perm = $permissions[$route->getAction()['uses'][1]];
         $this->assertTrue(ACL::permits('job.apply', $route->parameters()));
     });
     \Route::get('/test/perms/{id}', [$controller, 'tests'])->after('test.permissions.filter');
     $this->call('GET', '/test/perms/3');
     $this->assertResponseOk();
 }
Example #26
0
 public function setUp()
 {
     parent::setUp();
     Session::start();
     Route::enableFilters();
 }
 public function setUp()
 {
     parent::setUp();
     Route::enableFilters();
 }
Example #28
0
 public function prepareTests()
 {
     Route::enableFilters();
 }
Example #29
0
<?php

/**
 * ------------------------------------
 *          Reply deletion
 * ------------------------------------
 */
$I = new FunctionalTester($scenario);
Route::enableFilters();
$I->wantTo('Delete a reply as a visitor, normal member and admin.');
$topic = $I->postATopic(['title' => 'My Awsome Topic.']);
$reply = $I->have('Reply', ['topic_id' => $topic->id]);
// Testing as a visitor
$I->am('as a visitor');
$I->amOnRoute('topics.show', $topic->id);
$I->dontSeeElement('#reply-delete-' . $reply->id);
$I->amOnRoute('topics.delete', $topic->id);
$I->seeCurrentRouteIs('login-required');
// Test as a normal member
$I->am('as a member');
$I->signIn();
$I->dontSeeElement('#reply-delete-' . $reply->id);
$I->amOnRoute('topics.delete', $topic->id);
$I->seeCurrentRouteIs('admin-required');
// Testing as a admin user
$I->am('a Phphub admin');
$I->signInAsAdmin();
$I->amOnRoute('topics.show', $topic->id);
$I->seeElement('#reply-delete-' . $reply->id);
$I->click('#reply-delete-' . $reply->id);
$I->dontSeeRecord('replies', ['id' => $reply->id]);
 public function testGuestRedirectedToLoginPage()
 {
     Route::enableFilters();
     $this->client->request('GET', '/admin');
     $this->assertRedirectedTo('admin/login');
 }