Merge pull request #10317 from nupplaphil/bug/codecov_fix

Re-activate API tests
This commit is contained in:
Hypolite Petovan 2021-05-25 06:06:15 -04:00 committed by GitHub
commit 5b2a006c70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 46 deletions

View file

@ -8,7 +8,7 @@ coverage:
round: down
range: "70...100"
status:
project: off
patch: off
project: false
patch: false
comment: off
comment: false

View file

@ -67,6 +67,11 @@ type: docker
name: php7.3-mariadb
steps:
- name: Composer install
image: friendicaci/php7.4:php7.4.18
commands:
- composer validate
- composer install --prefer-dist
- name: Test Friendica
image: friendicaci/php7.3:php7.3.28
environment:
@ -79,8 +84,6 @@ steps:
MEMCACHED_HOST: "memcached"
MEMCACHE_HOST: "memcached"
commands:
- composer validate
- composer install --prefer-dist
- cp config/local-sample.config.php config/local.config.php
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
@ -108,6 +111,11 @@ type: docker
name: php7.4-mariadb
steps:
- name: Composer install
image: friendicaci/php7.4:php7.4.18
commands:
- composer validate
- composer install --prefer-dist
- name: Test Friendica
image: friendicaci/php7.4:php7.4.18
environment:
@ -122,8 +130,6 @@ steps:
XDEBUG_MODE: "coverage"
commands:
- phpenmod xdebug
- composer validate
- composer install --prefer-dist
- cp config/local-sample.config.php config/local.config.php
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
@ -161,6 +167,11 @@ type: docker
name: php8.0-mariadb
steps:
- name: Composer install
image: friendicaci/php7.4:php7.4.18
commands:
- composer validate
- composer install --prefer-dist
- name: Test Friendica
image: friendicaci/php8.0:php8.0.5
environment:
@ -173,8 +184,6 @@ steps:
MEMCACHED_HOST: "memcached"
MEMCACHE_HOST: "memcached"
commands:
- composer validate
- composer install --prefer-dist
- cp config/local-sample.config.php config/local.config.php
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql

View file

@ -34,6 +34,8 @@ trait DatabaseTestTrait
StaticDatabase::statConnect($_SERVER);
// Rollbacks every DB usage (in case the test couldn't call tearDown)
StaticDatabase::statRollback();
// Rollback the first, outer transaction just 2 be sure
StaticDatabase::getGlobConnection()->rollBack();
// Start the first, outer transaction
StaticDatabase::getGlobConnection()->beginTransaction();
}

View file

@ -69,7 +69,7 @@ class ExtendedPDO extends PDO
{
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
parent::beginTransaction();
$this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth;
$this->_transactionDepth = 0;
} else {
$this->exec("SAVEPOINT LEVEL{$this->_transactionDepth}");
}
@ -84,15 +84,16 @@ class ExtendedPDO extends PDO
*/
public function commit()
{
// We don't want to "really" commit something, so skip the most outer hierarchy
if ($this->_transactionDepth <= 1 && $this->hasSavepoint()) {
$this->_transactionDepth = $this->_transactionDepth <= 0 ? 0 : 1;
return true;
}
$this->_transactionDepth--;
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
parent::commit();
$this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth;
} else {
$this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
}
}
/**
* Rollback current transaction,
@ -102,14 +103,15 @@ class ExtendedPDO extends PDO
*/
public function rollBack()
{
if ($this->_transactionDepth <= 0) {
throw new PDOException('Rollback error : There is no transaction started');
}
$this->_transactionDepth--;
if($this->_transactionDepth == 0 || !$this->hasSavepoint()) {
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
$this->_transactionDepth = 0;
try {
parent::rollBack();
} catch (PDOException $e) {
// this shouldn't happen, but it does ...
}
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
}

View file

@ -39,6 +39,9 @@ class StaticDatabase extends Database
*/
private static $staticConnection;
/** @var bool */
private $_locked = false;
/**
* Override the behaviour of connect, due there is just one, static connection at all
*
@ -77,6 +80,31 @@ class StaticDatabase extends Database
return true;
}
/** Mock for locking tables */
public function lock($table)
{
if ($this->_locked) {
return false;
}
$this->in_transaction = true;
$this->_locked = true;
return true;
}
/** Mock for unlocking tables */
public function unlock()
{
// See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
$this->performCommit();
$this->in_transaction = false;
$this->_locked = false;
return true;
}
/**
* Does a commit
*
@ -163,18 +191,6 @@ class StaticDatabase extends Database
return self::$staticConnection;
}
/**
* Perform a global commit for every nested transaction of the static connection
*/
public static function statCommit()
{
if (isset(self::$staticConnection)) {
while (self::$staticConnection->getTransactionDepth() > 0) {
self::$staticConnection->commit();
}
}
}
/**
* Perform a global rollback for every nested transaction of the static connection
*/

View file

@ -2266,6 +2266,7 @@ class ApiTest extends FixtureTest
[
'network' => 'feed',
'title' => 'item_title',
'uri-id' => 1,
// We need a long string to test that it is correctly cut
'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
@ -2308,11 +2309,12 @@ class ApiTest extends FixtureTest
[
'network' => 'feed',
'title' => 'item_title',
'uri-id' => -1,
'body' => '',
'plink' => 'item_plink'
]
);
self::assertEquals('item_title', $result['text']);
self::assertEquals("item_title", $result['text']);
self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
}
@ -2326,7 +2328,8 @@ class ApiTest extends FixtureTest
$result = api_convert_item(
[
'title' => 'item_title',
'body' => 'item_title item_body'
'body' => 'item_title item_body',
'uri-id' => 1,
]
);
self::assertEquals('item_title item_body', $result['text']);

View file

@ -8,7 +8,7 @@
timeoutForLargeTests="900">
<testsuite name='friendica'>
<directory suffix='.php'>functional/</directory>
<directory suffix='.php'>include/</directory>
<directory suffix='.php'>legacy/</directory>
<directory suffix='.php'>src/</directory>
</testsuite>
<!-- Filters for Code Coverage -->
@ -16,14 +16,14 @@
<whitelist>
<directory suffix=".php">..</directory>
<exclude>
<directory suffix=".php">config/</directory>
<directory suffix=".php">doc/</directory>
<directory suffix=".php">images/</directory>
<directory suffix=".php">library/</directory>
<directory suffix=".php">spec/</directory>
<directory suffix=".php">tests/</directory>
<directory suffix=".php">view/</directory>
<directory suffix=".php">vendor/</directory>
<directory suffix=".php">../config/</directory>
<directory suffix=".php">../doc/</directory>
<directory suffix=".php">../images/</directory>
<directory suffix=".php">../library/</directory>
<directory suffix=".php">../spec/</directory>
<directory suffix=".php">../tests/</directory>
<directory suffix=".php">../view/</directory>
<directory suffix=".php">../vendor/</directory>
</exclude>
</whitelist>
</filter>