Http::response([ 'researchCenters' => [ [ 'id' => 3, 'name' => '数学基础研究中心', 'teams' => [ [ 'id' => 0, 'name' => '范金燕', 'email' => 'jyfan@sjtu.edu.cn', 'phone' => '54740206', 'title' => '教授', 'direction' => '最优化理论与方法、多项式优化', ], ], ], ], ], 200), ]); $adapter = new AiSjtuResearchCenterAdapter; $source = new CrawlSource([ 'adapter_code' => 'ai_sjtu_research_center_api', 'target_type' => 'teacher', ]); $items = $adapter->fetch('https://ai.sjtu.edu.cn/center', $source, [ 'max_results' => 10, ]); $this->assertCount(1, $items); $this->assertSame('范金燕', $items[0]->title); $this->assertSame('jyfan@sjtu.edu.cn', $items[0]->extra['lead_author']['email']); $this->assertSame('54740206', $items[0]->extra['phone']); $this->assertSame(['最优化理论与方法', '多项式优化'], $items[0]->extra['research_direction_names']); $this->assertSame('数学基础研究中心', $items[0]->extra['college_name']); } public function test_parse_research_direction_names(): void { $adapter = new AiSjtuResearchCenterAdapter; $method = new \ReflectionMethod($adapter, 'parseResearchDirectionNames'); $method->setAccessible(true); $this->assertSame( ['图像与信号处理', '数据科学', '最优化方法'], $method->invoke($adapter, '图像与信号处理,数据科学,最优化方法'), ); } }