/** * The driver mapper's instance needs to be accessible from anywhere in the application, * for registering new mapping configurations or other storage libraries. */ private function registerConfigurationMapper() { $this->app->bind('Mitch\\LaravelDoctrine\\Configuration\\DriverMapper', function () { $mapper = new DriverMapper(); $mapper->registerMapper(new SqlMapper()); $mapper->registerMapper(new SqliteMapper()); return $mapper; }); }
/** * The driver mapper's instance needs to be accessible from anywhere in the application, * for registering new mapping configurations or other storage libraries. */ private function registerConfigurationMapper() { $this->app->bind(DriverMapper::class, function () { $mapper = new DriverMapper(); $mapper->registerMapper(new SqlMapper()); $mapper->registerMapper(new SqliteMapper()); return $mapper; }); }
public function testUsageOfCorrectConfigurationMapper() { $mockMapper1 = m::mock('Mitch\\LaravelDoctrine\\Configuration\\Mapper'); $mockMapper2 = m::mock('Mitch\\LaravelDoctrine\\Configuration\\Mapper'); $driverMapper = new DriverMapper('some driver'); $driverMapper->registerMapper($mockMapper1); $driverMapper->registerMapper($mockMapper2); $mockMapper1->shouldReceive('appropriate')->once()->andReturn(false); $mockMapper2->shouldReceive('appropriate')->once()->andReturn(true); $mockMapper2->shouldReceive('map')->once()->andReturn('mapped array'); $this->assertEquals('mapped array', $driverMapper->map([])); }