db = new TestDb(); $this->db->exec('CREATE TABLE streams (id INTEGER PRIMARY KEY, stream_display_name TEXT, stream_icon TEXT);'); $this->db->query('INSERT INTO streams (id, stream_display_name, stream_icon) VALUES (5, "old", "");'); // Resolve every DatabaseAware class (RadioService, StreamRepository, ...) to the test db. DatabaseFactory::set($this->db); // Authorization::check() reads these globals + global $db. $GLOBALS['db'] = $this->db; $GLOBALS['rUserInfo'] = ['id' => 1, 'member_group_id' => 1]; $GLOBALS['rPermissions'] = ['is_admin' => 1, 'advanced' => []]; } protected function tearDown(): void { unset($GLOBALS['db'], $GLOBALS['rUserInfo'], $GLOBALS['rPermissions']); } public function testInvalidInputWhenValidationFails(): void { // Empty display name, no review, no upload → processRadio validation fails. $rResult = RadioService::process(['stream_display_name' => '']); $this->assertSame(STATUS_INVALID_INPUT, $rResult['status']); } public function testNoSourcesWhenStreamSourceEmpty(): void { // Edit path (avoids verifyPostTable): valid + authorized, but no source. $rResult = RadioService::process([ 'edit' => 5, 'stream_display_name' => 'My Radio', 'stream_source' => [''], ]); $this->assertSame(STATUS_NO_SOURCES, $rResult['status']); } }