diff --git a/fuel/app/classes/materia/api/v1.php b/fuel/app/classes/materia/api/v1.php index 360b7164d..d9e95b95d 100644 --- a/fuel/app/classes/materia/api/v1.php +++ b/fuel/app/classes/materia/api/v1.php @@ -896,7 +896,7 @@ static public function question_set_generate($inst_id, $widget_id, $topic, $incl static public function widget_prompt_generate($prompt) { - if ( ! Widget_Question_Generator::is_enabled()) throw new \HttpNotFoundException; + if ( ! Widget_Question_Generator::is_enabled()) return Msg::failure(); if (\Service_User::verify_session() !== true) return Msg::no_login(); $result = Widget_Question_Generator::generate_from_prompt($prompt); diff --git a/fuel/app/tests/api/v1.php b/fuel/app/tests/api/v1.php index 991a9d9db..05c53bd35 100644 --- a/fuel/app/tests/api/v1.php +++ b/fuel/app/tests/api/v1.php @@ -1174,28 +1174,14 @@ public function test_widget_prompt_generate() { if ( ! \Materia\Widget_Question_Generator::is_enabled()) { - try - { - $output = Api_V1::widget_prompt_generate('Provide a background story for Kogneato, the robot mascot of Materia, a platform for educational tools and games.'); - $this->fail('Expected exception HttpNotFoundException not thrown'); - } - catch (\Exception $e) - { - $this->assertInstanceOf('HttpNotFoundException', $e); - } + $output = Api_V1::widget_prompt_generate('Provide a background story for Kogneato, the robot mascot of Materia, a platform for educational tools and games.'); + $this->assert_failure_message($output); } else { // ======= AS NO ONE ======== - try - { - $output = Api_V1::widget_prompt_generate('Provide a background story for Kogneato, the robot mascot of Materia, a platform for educational tools and games.'); - $this->fail('Expected exception HttpNotFoundException not thrown'); - } - catch (\Exception $e) - { - $this->assertInstanceOf('HttpNotFoundException', $e); - } + $output = Api_V1::widget_prompt_generate('Provide a background story for Kogneato, the robot mascot of Materia, a platform for educational tools and games.'); + $this->assert_invalid_login_message($output); } }