Ejemplo n.º 1
0
 public function setup()
 {
     $bs = new OpenCFP\Bootstrap();
     $this->app = $bs->getApp();
     // Override things so that Spot2 is using in-memory tables
     $cfg = new \Spot\Config();
     $cfg->addConnection('sqlite', ['dbname' => 'sqlite::memory', 'driver' => 'pdo_sqlite']);
     $this->app['spot'] = new \Spot\Locator($cfg);
     // Initialize the talk table in the sqlite database
     $talk_mapper = $this->app['spot']->mapper('OpenCFP\\Entity\\Talk');
     $talk_mapper->migrate();
     // Set things up so Sentry believes we're logged in
     $user = m::mock('StdClass');
     $user->shouldReceive('getId')->andReturn(uniqid());
     $user->shouldReceive('getLogin')->andReturn(uniqid() . '@grumpy-learning.com');
     // Create a test double for Sentry
     $sentry = m::mock('StdClass');
     $sentry->shouldReceive('check')->andReturn(true);
     $sentry->shouldReceive('getUser')->andReturn($user);
     $this->app['sentry'] = $sentry;
     // Create a test double for sessions so we can control what happens
     $this->app['session'] = new SessionDouble();
     // Create our test double for the request object
     $this->req = m::mock('Symfony\\Component\\HttpFoundation\\Request');
 }
Ejemplo n.º 2
0
 /**
  * Test that the index page grabs a collection of talks
  * and successfully displays them
  *
  * @test
  */
 public function indexPageDisplaysTalksCorrectly()
 {
     $bootstrap = new \OpenCFP\Bootstrap();
     $app = $bootstrap->getApp();
     // Create a pretend user
     $user = m::mock('StdClass');
     $user->shouldReceive('hasPermission')->with('admin')->andReturn(true);
     $user->shouldReceive('getId')->andReturn(1);
     // Create a test double for Sentry
     $sentry = m::mock('StdClass');
     $sentry->shouldReceive('check')->andReturn(true);
     $sentry->shouldReceive('getUser')->andReturn($user);
     $app['sentry'] = $sentry;
     // Create an in-memory database
     $cfg = new \Spot\Config();
     $cfg->addConnection('sqlite', ['dbname' => 'sqlite::memory', 'driver' => 'pdo_sqlite']);
     $app['spot'] = new \Spot\Locator($cfg);
     // Create a fake request
     $req = m::mock('Symfony\\Component\\HttpFoundation\\Request');
     $req->shouldReceive('get')->with('page')->andReturn(1);
     $req->shouldReceive('getRequestUri')->andReturn('foo');
     $this->createTestData($app['spot']);
     $controller = new \OpenCFP\Controller\Admin\TalksController();
     $response = $controller->indexAction($req, $app);
     $this->assertContains('Test Title', $response);
     $this->assertContains('Test User', $response);
 }
Ejemplo n.º 3
0
 public function setup()
 {
     $bootstrap = new OpenCFP\Bootstrap();
     $this->app = $bootstrap->getApp();
     $session = m::mock('Symfony\\Component\\HttpFoundation\\Session\\Session');
     $session->shouldReceive('start')->andReturn(true);
     $session->shouldReceive('getId')->andReturn(uniqid());
     $this->app['session'] = $session;
     $this->req = m::mock('Symfony\\Component\\HttpFoundation\\Request');
 }
 /**
  * Test that the index page returns a list of talks associated
  * with a specific user and information about that user as well
  *
  * @test
  */
 public function indexDisplaysUserAndTalks()
 {
     $bootstrap = new \OpenCFP\Bootstrap();
     $app = $bootstrap->getApp();
     // Create an in-memory database for the test
     $cfg = new \Spot\Config();
     $cfg->addConnection('sqlite', ['dbname' => 'sqlite::memory', 'driver' => 'pdo_sqlite']);
     $app['spot'] = new \Spot\Locator($cfg);
     // Create a test user
     $user_mapper = $app['spot']->mapper('OpenCFP\\Entity\\User');
     $user_mapper->migrate();
     $user = $user_mapper->build(['email' => '*****@*****.**', 'password' => 'randompasswordhashed', 'first_name' => 'Test', 'last_name' => 'User', 'activated' => 1, 'transportation' => 0, 'hotel' => 0]);
     $user_mapper->save($user);
     $speaker_mapper = $app['spot']->mapper('OpenCFP\\Entity\\Speaker');
     $speaker_mapper->migrate();
     $speaker = $speaker_mapper->build(['user_id' => $user->id, 'photo_path' => '/path/to/photo', 'bio' => "This is speaker bio information", 'info' => "This is additional speaker infi"]);
     $speaker_mapper->save($speaker);
     // Create the favorite table
     $favorite_mapper = $app['spot']->mapper('OpenCFP\\Entity\\Favorite');
     $favorite_mapper->migrate();
     // Create a talk to display
     $talk_mapper = $app['spot']->mapper('OpenCFP\\Entity\\Talk');
     $talk_mapper->migrate();
     $talk = $talk_mapper->build(['title' => 'Test Title', 'description' => 'Test title description', 'user_id' => 1, 'type' => 'regular', 'category' => 'testing', 'level' => 'beginner', 'desired' => 1, 'slides' => 'slides', 'other' => 'other', 'sponsor' => 1, 'favorite' => 0, 'selected' => 0]);
     $talk_mapper->save($talk);
     // Set things up so Sentry believes we're logged in
     $user_mock = m::mock('StdClass');
     $user_mock->shouldReceive('hasPermission')->with('admin')->andReturn(true);
     $user_mock->shouldReceive('getId')->andReturn(1);
     // Create a test double for Sentry
     $sentry = m::mock('StdClass');
     $sentry->shouldReceive('check')->andReturn(true);
     $sentry->shouldReceive('getUser')->andReturn($user_mock);
     $app['sentry'] = $sentry;
     // Create a fake request object
     $req = m::mock('Symfony\\Component\\HttpFoundation\\Request');
     $req->shouldReceive('get')->with('page')->andReturn($user->id);
     // Instantiate the controller and run the indexAction
     $controller = new \OpenCFP\Controller\DashboardController();
     $response = $controller->indexAction($req, $app);
     $this->assertContains('Test Title', $response);
     $this->assertContains('Test User', $response);
 }
Ejemplo n.º 5
0
<?php

require_once '../classes/OpenCFP/Bootstrap.php';
// define('APP_DIR', dirname(dirname(__DIR__)));
//define('APP_DIR', dirname(__DIR__));
$bootstrap = new \OpenCFP\Bootstrap();
$app = $bootstrap->getApp();
define('UPLOAD_PATH', $app['uploadPath']);
$app->run();