protected function setUp() { $this->app = new Application(BASE_PATH, Environment::testing()); // Create an in-memory database $cfg = new \Spot\Config(); $cfg->addConnection('sqlite', ['dbname' => 'sqlite::memory', 'driver' => 'pdo_sqlite']); $spot = new \Spot\Locator($cfg); $this->app['spot'] = $spot; $this->mapper = $spot->mapper(\OpenCFP\Domain\Entity\Favorite::class); $this->mapper->migrate(); // Create a talk $talk_mapper = $spot->mapper(\OpenCFP\Domain\Entity\Talk::class); $data = ['title' => 'Favorite Entity Test', 'description' => 'This is a stubbed talk for a Favorite Entity Test', 'user_id' => 1]; $talk_mapper->migrate(); $this->talk = $talk_mapper->create($data); }
protected function setUp() { $this->app = new Application(BASE_PATH, Environment::testing()); ob_start(); $this->app->run(); ob_end_clean(); // Override things so that Spot2 is using in-memory tables $cfg = new \Spot\Config(); $cfg->addConnection('sqlite', ['dbname' => 'sqlite::memory', 'driver' => 'pdo_sqlite']); $spot = new \Spot\Locator($cfg); $this->app['spot'] = $spot; // Initialize the talk table in the sqlite database $talk_mapper = $spot->mapper(\OpenCFP\Domain\Entity\Talk::class); $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(Sentry::class); $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'); }
public static function getInstace($config) { $impl = '\\Impl\\' . $config["app"]["implementation"]; $implementation = new $impl(); $cfg = new \Spot\Config(); $cfg->addConnection($config["rds"]["driver"], $config["rds"]["connectionString"]); $spot = new \Spot\Locator($cfg); return new EntitySyncronizer($spot->mapper($implementation->entity()), $implementation); }
public static function setUpBeforeClass() { if (class_exists("Spot\\Mapper")) { @unlink("/tmp/test.sqlite"); $config = new \Spot\Config(); $config->addConnection("sqlite", ["path" => "/tmp/test.sqlite", "driver" => "pdo_sqlite"]); $spot = new \Spot\Locator($config); $mapper = $spot->mapper("Beeper\\Test\\Dragon"); var_dump($mapper->migrate()); for ($i = 1; $i <= 55; ++$i) { $color = $i % 2 ? "black" : "red"; $dragon = $mapper->create(["name" => "Dragon " . $i, "color" => $color]); } } }
public function testGetMapper() { $cfg = new \Spot\Config(); $spot = new \Spot\Locator($cfg); $this->assertInstanceOf('Spot\\Mapper', $spot->mapper('SpotTest\\Entity\\Post')); }
<?php /** * BobbaJuice - Badge Scanner * Scott Stamp <*****@*****.**> */ require "vendor/autoload.php"; use BobbaJuice\BadgeScanner\Scanner; $cfg = new \Spot\Config(); $cfg->addConnection('mysql', 'mysql://*****:*****@localhost/badges'); $spot = new \Spot\Locator($cfg); $badgeMapper = $spot->mapper('BobbaJuice\\BadgeScanner\\Entity\\Badge'); $badges = Scanner::Scan("de"); foreach ($badges as $badge) { try { $badgeMapper->create(['code' => $badge->code, 'name' => $badge->name, 'description' => $badge->description]); } catch (Exception $exception) { } }