[TESTS] Raise test coverage for App\Controller\Network to 100% and fixup related code

This commit is contained in:
2021-05-23 19:56:45 +00:00
parent c5d4b7ecac
commit 74f477489b
5 changed files with 108 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ use App\Core\VisibilityScope;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exception\NotFoundException;
use Symfony\Component\HttpFoundation\Request;
class Network extends Controller
@@ -65,8 +66,9 @@ class Network extends Controller
public function home(Request $request, string $nickname)
{
$target = DB::findOneBy('gsactor', ['nickname' => $nickname]);
if ($target == null) {
try {
$target = DB::findOneBy('gsactor', ['nickname' => $nickname]);
} catch (NotFoundException) {
throw new ClientException(_m('User {nickname} doesn\'t exist', ['{nickname}' => $nickname]));
}
@@ -106,7 +108,7 @@ END;
public function network(Request $request)
{
$notes = Note::getAllNotes($this->instance_scope);
$notes = Note::getAllNotes($this->public_scope);
Event::handle('FormatNoteList', [&$notes]);