/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $searchTerms = $input->getArgument('searchTerms'); $userRecords = $this->directory->find($searchTerms); if (!$userRecords) { $output->writeln('<error>Unable to find anyone matching those terms in the directory.</error>'); return; } $rows = array_map(function ($arr) { return [$arr['campusId'], $arr['firstName'], $arr['lastName'], $arr['email'], $arr['telephoneNumber']]; }, $userRecords); $table = new Table($output); $table->setHeaders(array('Campus ID', 'First', 'Last', 'Email', 'Phone Number'))->setRows($rows); $table->render(); }
/** * @covers Ilios\CoreBundle\Service\Directory::find */ public function testFind() { $ldapManager = m::mock('Ilios\\CoreBundle\\Service\\LdapManager'); $obj = new Directory($ldapManager, 'campusId'); $filter = '(&(|(sn=a*)(givenname=a*)(mail=a*))(|(sn=b*)(givenname=b*)(mail=b*)))'; $ldapManager->shouldReceive('search')->with($filter)->andReturn(array(1, 2)); $result = $obj->find(array('a', 'b')); $this->assertSame($result, array(1, 2)); }