Ejemplo n.º 1
0
 /**
  * @covers ::getAsserts
  * @covers ::addAssert
  */
 public function testConstruct()
 {
     $config = new TestConfig();
     $asserts = $config->getAsserts();
     $this->assertInstanceOf('Harp\\Validate\\Asserts', $asserts);
     $this->assertCount(0, $asserts);
     $present = new Assert\Present('test');
     $config->addAssert($present);
     $this->assertCount(1, $config->getAsserts());
     $this->assertContains($present, $config->getAsserts()->all());
 }
Ejemplo n.º 2
0
 /**
  * @covers ::getSerializers
  * @covers ::addSerializer
  */
 public function testConstruct()
 {
     $config = new TestConfig();
     $serializers = $config->getSerializers();
     $this->assertInstanceOf('Harp\\Serializer\\Serializers', $serializers);
     $this->assertCount(0, $serializers);
     $csv = new Csv('test');
     $config->addSerializer($csv);
     $this->assertCount(1, $config->getSerializers());
     $this->assertContains($csv, $config->getSerializers()->all());
 }
Ejemplo n.º 3
0
 public function testSimple()
 {
     $config = TestConfig::getConfig();
     $service_url = $config['server']['baseurl'] . '/version';
     $curl = curl_init($service_url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/xml"));
     $curl_response = curl_exec($curl);
     $headers = curl_getinfo($curl);
     curl_close($curl);
     // check if http code fits
     if ($headers["http_code"] != 200) {
         $this->fail("Response has the wrong http code : " . $headers["http_code"] . "\n\n" . print_r($headers, true) . "\n\n" . $curl_response);
     }
     // parse xml result
     try {
         $xml = new SimpleXMLElement($curl_response);
     } catch (Exception $e) {
         $this->fail("An exception has been raised: " . $e->getMessage() . "\n\n" . $e->getTraceAsString());
     }
     $versionAttributes = array();
     foreach ($xml->version[0]->attributes() as $name => $value) {
         $versionAttributes[$name] = $value;
         // test if all values are numbers
         $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_NUMERIC, (string) $value, "Type of Attribute is wrong.");
     }
     $mandatoryAttributes = array("major", "minor", "revision");
     foreach ($mandatoryAttributes as $key => $value) {
         // test if all attributes are included
         $this->assertArrayHasKey($value, $versionAttributes, "Attribute missing in result: \n\n" . $curl_response);
     }
 }
Ejemplo n.º 4
0
 private function tryToTest(AcceptanceGuy $I)
 {
     // need a copy of test folder
     FileSystemTools::copyRecursive(TestConfig::getConfig('testPath'), $this->tmpStaging);
     $I->runShellCommand(TestConfig::getConfig('testRunnerPath') . DS . 'runtests.bat testStagingPath:' . $this->tmpStaging);
     $I->seeInShellOutput('Codeception PHP Testing Framework');
     //$I->seeInShellOutput('PhantomJS server stopped');
 }
Ejemplo n.º 5
0
 public static function getRemoteTestFiles()
 {
     $config = TestConfig::getConfig();
     $file_urls = $config['testaddurl'];
     $testfilesremote = array();
     foreach ($file_urls as $ext_key => $url) {
         $testfilesremote[] = array($url, $ext_key, "");
         $testfilesremote[] = array($url, $ext_key . "-C", "C");
     }
     return $testfilesremote;
 }
Ejemplo n.º 6
0
 protected function getConnection()
 {
     $testconfig = TestConfig::getConfig();
     $dbname = $testconfig["database"]["dbname"];
     $dbhost = $testconfig["database"]["dbhost"];
     $dbport = $testconfig["database"]["dbport"];
     $dbuser = $testconfig["database"]["dbuser"];
     $dbpassword = $testconfig["database"]["dbpassword"];
     $pdo = new PDO("pgsql:dbname={$dbname};host={$dbhost};port={$dbport}", $dbuser, $dbpassword, array(PDO::ATTR_PERSISTENT => true));
     return $this->createDefaultDBConnection($pdo, $dbname);
 }
Ejemplo n.º 7
0
 protected function loadHtml($uri)
 {
     if (preg_match('/^https?:/i', $uri) === 0) {
         $uri = $this->config->getBaseHref() . $uri;
     }
     $curl = curl_init($uri);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $html = curl_exec($curl);
     $this->request_info = curl_getinfo($curl);
     curl_close($curl);
     $this->location = $uri;
     $tidy = new Tidy();
     $tidy->parseString($html, array('output-xhtml' => true, 'char-encoding' => 'utf8', 'numeric-entities' => true), 'utf8');
     $tidy->cleanRepair();
     $this->document = new DOMDocument();
     $this->document->resolveExternals = true;
     $this->document->loadXml($tidy);
     $this->xpath = new DOMXPath($this->document);
     $this->xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
     $this->xpath->registerNamespace('html', 'http://www.w3.org/1999/xhtml');
 }
Ejemplo n.º 8
0
 public function testSimple()
 {
     $config = TestConfig::getConfig();
     $service_url = $config['server']['baseurl'] . '/version';
     $curl = curl_init($service_url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/xmlx"));
     $curl_response = curl_exec($curl);
     $headers = curl_getinfo($curl);
     curl_close($curl);
     $xml = SmintTestUtils::validateXMLResponse($headers, $curl_response, "406", array("error"), array("code"), $this);
     $errorAttributes = array();
     foreach ($xml->error[0]->attributes() as $name => $value) {
         $versionAttributes[$name] = $value;
         // test if all values are numbers
         $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_NUMERIC, (string) $value, "Type of ErrorCode is wrong.");
     }
 }
Ejemplo n.º 9
0
 private function myQueryTest($trackid)
 {
     $config = TestConfig::getConfig();
     $service_url = $config['server']['baseurl'] . '/track_external_key/';
     $curl = curl_init($service_url . $trackid);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/xml"));
     $curl_response = curl_exec($curl);
     $headers = curl_getinfo($curl);
     curl_close($curl);
     if ($curl_response == true) {
         $xml = SmintTestUtils::validateXMLResponse($headers, $curl_response, "404", array("error", "errorDetail"), array("code"), $this);
     } else {
         echo __METHOD__ . "\n";
         echo "curl_response:" . $curl_response . "\n";
         print_r($headers);
         $this->fail("There was a problem accessing the api! \n\n");
     }
 }
Ejemplo n.º 10
0
 private function myQueryTest($trackextkey, $collectionname = null, $expectedHTTPStatus = "200", $expectedXMLElements, $expectedXMLAttributes)
 {
     $config = TestConfig::getConfig();
     $service_url = $config['server']['baseurl'] . '/track_external_key/';
     $url = $service_url . $trackextkey;
     if (!is_null($collectionname)) {
         $url = $url . "?collection=" . urlencode($collectionname);
     }
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/xml"));
     $curl_response = curl_exec($curl);
     $headers = curl_getinfo($curl);
     curl_close($curl);
     if ($curl_response == true) {
         $xml = SmintTestUtils::validateXMLResponse($headers, $curl_response, $expectedHTTPStatus, $expectedXMLElements, $expectedXMLAttributes, $this);
     } else {
         echo __METHOD__ . "\n";
         echo "curl_response:" . $curl_response . "\n";
         print_r($headers);
         $this->fail("There was a problem accessing the api! \n\n");
     }
 }
 /**
  * @covers ::getEventListeners
  * @covers ::addEventBefore
  * @covers ::addEventAfter
  */
 public function testConstruct()
 {
     $config = new TestConfig();
     $event1 = function ($object) {
         return true;
     };
     $event2 = function ($object) {
         return true;
     };
     $listeners = $config->getEventListeners();
     $this->assertInstanceOf('Harp\\EventListeners\\EventListeners', $listeners);
     $this->assertCount(0, $listeners->getBefore());
     $this->assertCount(0, $listeners->getAfter());
     $config->addEventBefore('insert', $event1);
     $config->addEventAfter('delete', $event2);
     $this->assertSame(['insert' => [$event1]], $config->getEventListeners()->getBefore());
     $this->assertSame(['delete' => [$event2]], $config->getEventListeners()->getAfter());
 }
Ejemplo n.º 12
0
 public function tearDown()
 {
     //		$this->stop();
     parent::tearDown();
     $this->config->tearDown();
 }
Ejemplo n.º 13
0
        //        $server_ip = Com_System::get_client_ip();
        //
        //        $url = "http://{$server_ip}/nginx2cppsvr.do";
        //        $header = "Content-type: application/octet-stream";
        //        $ch = curl_init(); //初始化curl
        //        curl_setopt($ch, CURLOPT_URL, $url);//设置链接
        //        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息
        //        curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));//设置HTTP头
        //        curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
        //        curl_setopt($ch, CURLOPT_POSTFIELDS, $raw_data);//POST数据
        //        curl_setopt($ch, CURLOPT_TIMEOUT,1);
        //        curl_exec($ch);
        //        curl_close($ch);
    }
}
$objTestConfig = new TestConfig();
$table_list = $objTestConfig->get_table_list();
$table_list = json_encode($table_list);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
	var table_list = <?php 
echo $table_list;
?>
;
</script>
<title>C++配置库导入导出管理</title>
<style type="text/css">
Ejemplo n.º 14
0
 echo 'RUN TESTS ' . $folder;
 ob_start();
 $testResult = TestRunner::runTests($folder);
 $testOutput = ob_get_contents();
 ob_end_clean();
 if (!$testResult['result']) {
     $passedAllTests = false;
     $output[] = "TEST FAILED";
 } else {
     $output[] = "TEST PASSED";
 }
 $output[] = $testOutput;
 //$output=array_merge($output,$testResult['output']);
 // CHECK PHP LOG FILE
 if (!empty(TestConfig::getConfig('testLogFiles'))) {
     foreach (explode(",", TestConfig::getConfig('testLogFiles')) as $k => $logFile) {
         $lines = FileSystemTools::checkChangesToFile($snapshots[$logFile], $logFile);
         if (count($lines) > 0) {
             $output[] = "-------------------------------------------------";
             $output[] = 'LOG FILE ' . $logFile;
             $output[] = "-------------------------------------------------";
             $output = array_merge($output, $lines);
             $output[] = "-------------------------------------------------";
         }
     }
 }
 if (php_sapi_name() == 'cli') {
     echo "\n" . implode("\n", $output) . "\n";
     $output = array();
 }
 // $output=array_merge($output,
Ejemplo n.º 15
0
 static function runTests($testFolder)
 {
     $output = [];
     // clean staging
     $cmds = array();
     $staging = TestConfig::getConfig('testStagingPath');
     //FileSystemTools::setPermissionsAllowEveryone($staging);
     //FileSystemTools::setPermissionsAllowEveryone(TestConfig::getConfig('testOutputPath'));
     $passedAllTests = true;
     // some sanity checking before pruning
     if (strlen(trim($staging)) > 0) {
         // clean up staging
         FileSystemTools::prune($staging);
         //return array();
         // create staging location
         @mkdir($staging . DS . 'tests', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_support', 0777, true);
         // copy shared test support files
         FileSystemTools::copyRecursive(TestConfig::getConfig('testSharedSupportPath'), $staging . DS . 'tests' . DS . '_support');
         //return array();
         // then copy over the top, test suites etc to staging
         FileSystemTools::copyRecursive($testFolder, $staging . DS . 'tests');
         // ensure required test directories
         @mkdir($staging . DS . 'tests' . DS . '_support', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_output', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_data', 0777, true);
         @mkdir($staging . DS . 'tests' . DS . '_support' . DS . 'Helper', 0777, true);
         TestConfig::writeCodeceptionConfig();
         $objects = glob($staging . DS . 'tests' . DS . '*.suite.yml');
         if (sizeof($objects) > 0) {
             foreach ($objects as $file) {
                 if ($file == "." || $file == "..") {
                     continue;
                 }
                 TestConfig::writeWebDriverConfig($file);
             }
         }
         // cm5?
         if (strlen(trim(TestConfig::getConfig('cmFivePath'))) > 0) {
             // copy installer sql to test data directory
             copy(TestConfig::getConfig('cmFivePath') . DS . 'cache' . DS . 'install.sql', $staging . DS . 'tests' . DS . '_data' . DS . 'dump.sql');
             // copy c3.php for accptance test coverage
             if (TestConfig::getConfig('coverage')) {
                 copy(TestConfig::getConfig('testRunnerPath') . DS . 'src' . DS . 'lib' . DS . 'c3.php', TestConfig::getConfig('testRunnerPath') . DS . 'staging' . DS . 'c3.php');
             }
         }
         // build and run
         array_push($cmds, array('CODECEPTION BUILD', TestConfig::getConfig('codeception') . ' build ' . ' -c ' . $staging));
         $testParam = TestConfig::getConfig('testSuite');
         $testParam .= strlen(trim(TestConfig::getConfig('testSuite'))) > 0 ? ' ' . TestConfig::getConfig('test') : '';
         // these options conflict with coverage options below so only one set
         $coverage = ' -d --no-colors --steps ';
         if (TestConfig::getConfig('coverage')) {
             //--coverage-xml
             $coverage = ' --coverage --xml --html --coverage-html   --report ';
         }
         array_push($cmds, array('CODECEPTION RUN', TestConfig::getConfig('codeception') . ' run ' . $coverage . ' -c ' . $staging . ' ' . $testParam));
         foreach ($cmds as $cmd) {
             if (php_sapi_name() == 'cli') {
                 echo "-------------------------------------------------\n";
                 echo $cmd[0] . "\n";
                 echo $cmd[1] . "\n";
                 echo "-------------------------------------------------\n";
             } else {
                 $output[] = "-------------------------------------------------";
                 $output[] = $cmd[0];
                 $output[] = $cmd[1];
                 $output[] = "-------------------------------------------------";
             }
             $handle = popen($cmd[1], "r");
             $detailsTest = '';
             $errorActive = false;
             $testType = '';
             while (!feof($handle)) {
                 $buffer = fgets($handle);
                 //$buffer = trim(htmlspecialchars($buffer));
                 if (php_sapi_name() == 'cli') {
                     echo $buffer;
                 } else {
                     $output[] = trim($buffer);
                 }
             }
             $exitCode = pclose($handle);
             if ($exitCode > 0) {
                 $passedAllTests = false;
             }
         }
         // save output files
         $testSuiteName = str_replace(':', '_', str_replace(DS, '_', $testFolder));
         @mkdir(TestConfig::getConfig('testOutputPath') . DS . $testSuiteName);
         $output[] = "COPY test results from " . $staging . DS . 'tests' . DS . '_output' . " to " . TestConfig::getConfig('testOutputPath') . DS . $testSuiteName;
         FileSystemTools::copyRecursive($staging . DS . 'tests' . DS . '_output', TestConfig::getConfig('testOutputPath') . DS . $testSuiteName);
     }
     // clean up
     if (strlen(trim(TestConfig::getConfig('testRunnerPath'))) > 0 && file_exists(TestConfig::getConfig("testRunnerPath") . "/staging/c3.php")) {
         //unlink(TestConfig::getConfig("testRunnerPath")."/staging/c3.php");
     }
     //FileSystemTools::setPermissionsAllowEveryone($staging);
     //FileSystemTools::setPermissionsAllowEveryone(TestConfig::getConfig('testOutputPath'));
     return array('output' => $output, 'result' => $passedAllTests);
 }
Ejemplo n.º 16
0
 static function writeWebDriverConfig($configFile)
 {
     // write webdriver parameters
     $data = Yaml::parse(file_get_contents($configFile));
     // PROBLEM IN IF STATEMENT BELOW CHECKING FOR WEBDRIVER WHICH IS ACTUALLY A KEY ONE LEVEL DEEPER INSIDE ONE OF?? NUMERIC KEYS
     if (is_array($data) && array_key_exists('modules', $data) && array_key_exists('enabled', $data['modules'])) {
         // && is_array($data['modules']['enabled']['WebDriver']
         foreach ($data['modules']['enabled'] as $k => $moduleName) {
             if (is_array($moduleName) && array_key_exists('WebDriver', $moduleName)) {
                 $data['modules']['enabled'][$k]['WebDriver']['url'] = strlen(trim(TestConfig::getConfig('testUrl'))) > 0 ? TestConfig::getConfig('testUrl') : 'http://localhost';
                 $data['modules']['enabled'][$k]['WebDriver']['browser'] = 'firefox';
                 $data['modules']['enabled'][$k]['WebDriver']['host'] = 'localhost';
                 $data['modules']['enabled'][$k]['WebDriver']['wait'] = '1';
                 $yaml = Yaml::dump($data);
                 file_put_contents($configFile, $yaml);
                 break;
             }
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Get current browser string
  *
  * @return string Browser String
  */
 public function getBrowserString()
 {
     $browserString = $this->_config->getCurrentBrowser();
     return $browserString;
 }
Ejemplo n.º 18
0
<?php

// Advertiser Console specific config file
require_once dirname(__FILE__) . '/../TestFramework/classes/TestEnvFactory.php';
require_once dirname(__FILE__) . '/../TestFramework/classes/TestConfig.php';
require_once dirname(__FILE__) . '/classes/PiwikTestEnv.php';
define('PEAR_LIBRARY_PATH', dirname(__FILE__) . '/../pear/');
define('PROJECT_PATH', dirname(__FILE__) . '/../../');
define('SIMPLETEST_PATH', dirname(__FILE__) . '/../simpletest/');
TestEnvFactory::setTestEnv(new PiwikTestEnv());
TestConfig::getInstance()->addDirectory('tests');
TestConfig::getInstance()->addTestType('unit', 'core');
TestConfig::getInstance()->addLayer('unit', 'core', 'core unit tests', EnvType::NO_DB);
Ejemplo n.º 19
0
 protected function setUp()
 {
     $this->config = TestConfig::getConfig();
     $this->testfilesremote = TestConfig::getRemoteTestFiles();
     $this->testfileslocal = TestConfig::getLocalTestFiles();
 }
Ejemplo n.º 20
0
 protected function setUp()
 {
     $this->config = TestConfig::getConfig();
     $this->service_url = $this->config['server']['baseurl'] . '/track/delete/';
 }