public static function setUpBeforeClass() { if (defined('SKIPPING')) { return; } $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT); if (DB_TYPE == 'sqlite') { $db->execute(file_get_contents(DB_SETUP_FILE)); $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE)); } $db->execute(file_get_contents(DB_POPULATE_FILE)); $db->execute(file_get_contents(DB_EXTENDED_POPULATE_FILE)); self::$db = $db; self::$schema = new fSchema($db); fORMDatabase::attach(self::$db); fORMSchema::attach(self::$schema); fORMOrdering::configureOrderingColumn('TopAlbum', 'position'); fORMOrdering::configureOrderingColumn('FavoriteAlbum', 'position'); fORMOrdering::configureOrderingColumn('YearFavoriteAlbum', 'position'); if (defined('MAP_TABLES')) { fORM::mapClassToTable('User', 'user'); fORM::mapClassToTable('Group', 'group'); fORM::mapClassToTable('Artist', 'popular_artists'); fORM::mapClassToTable('Album', 'records'); } }
public function setUp() { if (defined('SKIPPING')) { $this->markTestSkipped(); } $db = $this->sharedFixture['db']; $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE)); $db->clearCache(); fORMDatabase::attach($db); fORMSchema::attach($this->sharedFixture['schema']); fORMOrdering::configureOrderingColumn('TopAlbum', 'position'); fORMOrdering::configureOrderingColumn('FavoriteAlbum', 'position'); fORMOrdering::configureOrderingColumn('YearFavoriteAlbum', 'position'); if (defined('MAP_TABLES')) { fORM::mapClassToTable('User', 'user'); fORM::mapClassToTable('Group', 'group'); fORM::mapClassToTable('Artist', 'popular_artists'); fORM::mapClassToTable('Album', 'records'); } }
public function testChildValidationName() { try { fORMOrdering::configureOrderingColumn('FavoriteAlbum', 'position'); fORMRelated::registerValidationNameMethod('User', 'FavoriteAlbum', 'makeName'); $user = $this->createUser(); $favorite_album_1 = new FavoriteAlbum(); $favorite_album_2 = new FavoriteAlbum(); $user->associateFavoriteAlbums(array($favorite_album_1, $favorite_album_2)); $user->validate(); } catch (fValidationException $e) { $message = preg_replace('#\\s+#', ' ', strip_tags($e->getMessage())); $this->assertContains('The following problems were found: Album 1 Album ID: Please enter a value Album 2 Album ID: Please enter a value', $message); } }
/** * Resets the configuration of the class * * @internal * * @return void */ public static function reset() { self::$ordering_columns = array(); }