This repository has been archived by the owner on May 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore (php7): Update all phpunit tests, refactor psr-0 for test
Update all phpunit test according to phpunit update. Add phpunit config file allowing to overload default config. Update autoload
- Loading branch information
Wilfried
committed
Oct 29, 2019
1 parent
544cd6c
commit 41dfc94
Showing
21 changed files
with
182 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
nbproject/ | ||
sftp-* | ||
/vendor | ||
phpunit.xml | ||
|
||
# many file generated by IDE | ||
.buildpath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
bootstrap="./tests/lib/Autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
> | ||
<php> | ||
<ini name="memory_limit" value="-1"/> | ||
<env name="host" value="127.0.0.1" force="true" /> | ||
<env name="port" value="9200" force="true" /> | ||
<env name="protocol" value="http" force="true" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="AllTests"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
if (!defined('SIMPLES_TESTS_ROOT')) { | ||
define('SIMPLES_TESTS_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR); | ||
} | ||
|
||
/** | ||
* Simples autoload method for tests. | ||
* | ||
* @param string $class Class name to load | ||
*/ | ||
function autoload_simples_tests ($class) { | ||
$path = str_replace('_', DIRECTORY_SEPARATOR , $class); | ||
if (file_exists(SIMPLES_TESTS_ROOT . $path . '.php')) { | ||
require_once(SIMPLES_TESTS_ROOT . $path . '.php'); | ||
} | ||
} | ||
|
||
// Register our custom autoload method | ||
spl_autoload_register('autoload_simples_tests'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class Simples_HttpTestCase extends TestCase { | ||
|
||
/** | ||
* @var Simples_Transport_Http|null | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $defaultHttpConfig = [ | ||
'host' => '127.0.0.1', | ||
'port' => 9200, | ||
'protocol' => 'http', | ||
'timeout' => 1000, | ||
'check' => true, | ||
'index' => null, | ||
'type' => null | ||
]; | ||
|
||
/** | ||
* Redefine http config from env var | ||
* given by phpunit.xml | ||
*/ | ||
protected function setUp() : void { | ||
foreach ($this->defaultHttpConfig as $key => $value) { | ||
if (getenv($key)) { | ||
$this->defaultHttpConfig[$key] = getenv($key); | ||
} | ||
} | ||
parent::setUp(); | ||
$this->client = new Simples_Transport_Http($this->getTransportHttpConfig()); | ||
} | ||
|
||
/** | ||
* @return [] | ||
*/ | ||
protected function getTransportHttpConfig() | ||
{ | ||
return $this->defaultHttpConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.