コード例 #1
0
 public function testQueryLicenseCandidate()
 {
     $groupId = 123;
     $licenseViewProxy = new LicenseViewProxy($groupId);
     $reflection = new \ReflectionClass($licenseViewProxy->classname());
     $method = $reflection->getMethod('queryLicenseCandidate');
     $method->setAccessible(true);
     $options1 = array('columns' => array('rf_pk', 'rf_shortname'));
     $query1 = $method->invoke($licenseViewProxy, $options1);
     assertThat($query1, is("SELECT rf_pk,rf_shortname FROM license_candidate WHERE group_fk={$groupId}"));
     $options2 = array('extraCondition' => 'rf_pk<100');
     $query2 = $method->invoke($licenseViewProxy, $options2);
     assertThat($query2, is("SELECT {$this->almostAllColumns},group_fk FROM license_candidate WHERE group_fk={$groupId} AND rf_pk<100"));
     $prefix = '#';
     $options3 = array(LicenseViewProxy::CANDIDATE_PREFIX => $prefix, 'columns' => array('rf_shortname'));
     $query3 = $method->invoke($licenseViewProxy, $options3);
     assertThat($query3, is("SELECT '" . pg_escape_string($prefix) . "'||rf_shortname AS rf_shortname FROM license_candidate WHERE group_fk={$groupId}"));
 }