public function testFindAllIDmByUserId() { $idms = array(); $idm = getIDmInstance(1); $idm2 = getIDmInstance(2, 67890); $idm3 = getIDmInstance(1, 98765); array_push($idms, $idm, $idm2, $idm3); $imapper = new IDmMapper(self::$pdo); $imapper->insert($idms); $newIdm = $imapper->findAllIDmByUserId(1); $this->assertEquals(2, count($newIdm)); }
<?php $rootPass = dirname(__FILE__) . '/../../'; require_once $rootPass . 'lib/db/dbfunctions.php'; require_once $rootPass . 'lib/db/Model/IDm.php'; require_once $rootPass . 'lib/db/Mapper/IDmMapper.php'; $pdo = getPDO($argv[2]); // $pdo = getPDO('test'); $imapper = new IDmMapper($pdo); $idmArray = $imapper->findAllIDmByUserId((int) $argv[1]); $results = array(); // var_dump($idmArray); foreach ($idmArray as $idm) { $results[] = (array) $idm; } header("Content-Type: application/json; charset=utf-8"); echo json_encode($results);