public function testCreateMap() { $p = new RingsidePrincipal(); $p->id = -1; //strange but it works! $this->assertTrue($p->trySave()); $pid = $p->getIncremented(); $map = new RingsidePrincipalMap(); $map->principal_id = $pid; $map->app_id = 123; $map->network_id = 'abcd'; $map->uid = 1234; $map->save(); $subject_map = Doctrine::getTable('RingsidePrincipalMap')->findOneBySubject(123, 'abcd', 1234); $this->assertNotNull($subject_map); $this->assertEquals($p->id, $subject_map->principal_id); }
/** * Creates a principal without managing database transactions. For internal use only. This method * is called from both the primary {@link #createPrincipal} method and from the {@link #link} method * if there is no existing principal to use. * * @param string $app_id the application creating the principal. * @param string $network_id the network associated with the user ID. * @param string $uid the subject's user ID on the given network. * @return string the created principal's ID. */ private function _createPrincipal($app_id, $network_id, $uid) { $principal = new RingsidePrincipal(); // TODO: Exception: Throw a meaningful service-level exception $principal->state('TDIRTY'); $principal->save(); $pid = $principal->id; $principal_map = new RingsidePrincipalMap(); $principal_map->principal_id = $pid; $principal_map->app_id = $app_id; $principal_map->network_id = $network_id; $principal_map->uid = $uid; $principal_map->save(); return $pid; }