Restructure tests
This commit is contained in:
parent
0599153951
commit
2b58bb4dfa
@ -29,7 +29,7 @@ class ActivityPubTest extends SQLiteTestCase
|
||||
$this->assertTrue( file_exists( $this->getDbPath() ) );
|
||||
}
|
||||
|
||||
private function getDbPath() {
|
||||
protected function getDbPath() {
|
||||
return dirname( __FILE__ ) . '/db.sqlite';
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
namespace ActivityPub\Test\Config;
|
||||
|
||||
use ActivityPub\ActivityPub;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\DbUnit\TestCaseTrait;
|
||||
use PHPUnit\DbUnit\Operation\Composite;
|
||||
use PHPUnit\DbUnit\Operation\Factory;
|
||||
|
||||
abstract class SQLiteTestCase extends TestCase
|
||||
{
|
||||
use TestCaseTrait;
|
||||
|
||||
private $pdo = null;
|
||||
private $conn = null;
|
||||
private $dbPath = '';
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$dbPath = dirname( __FILE__ ) . '/../db.sqlite';
|
||||
if ( file_exists( $dbPath ) ) {
|
||||
unlink( $dbPath );
|
||||
}
|
||||
$activityPub = new ActivityPub( array(
|
||||
'dbOptions' => array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => $dbPath,
|
||||
),
|
||||
) );
|
||||
$activityPub->updateSchema();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
unlink( dirname( __FILE__ ) . '/../db.sqlite' );
|
||||
unset( $this->conn );
|
||||
unset( $this->pdo );
|
||||
}
|
||||
|
||||
final public function getConnection()
|
||||
{
|
||||
if ( $this->conn === null ) {
|
||||
if ( $this->pdo === null ) {
|
||||
$this->dbPath = dirname( __FILE__ ) . '/../db.sqlite';
|
||||
$this->pdo = new \PDO( "sqlite:{$this->dbPath}" );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection( $this->pdo, $this->dbPath );
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace ActivityPub\Test;
|
||||
namespace ActivityPub\Test\Crypto;
|
||||
|
||||
use BadMethodCallException;
|
||||
use ActivityPub\Crypto\RsaKeypair;
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace ActivityPub\Test;
|
||||
namespace ActivityPub\Test\Entities;
|
||||
|
||||
use DateTime;
|
||||
use ActivityPub\Crypto\RsaKeypair;
|
||||
@ -29,13 +29,13 @@ class EntityTest extends SQLiteTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
$dbConfig = Setup::createAnnotationMetadataConfiguration(
|
||||
array( __DIR__ . '/../src/Entities' ), true
|
||||
array( __DIR__ . '/../../src/Entities' ), true
|
||||
);
|
||||
$namingStrategy = new PrefixNamingStrategy( '' );
|
||||
$dbConfig->setNamingStrategy( $namingStrategy );
|
||||
$dbParams = array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => __DIR__ . '/db.sqlite',
|
||||
'path' => $this->getDbPath(),
|
||||
);
|
||||
$this->entityManager = EntityManager::create( $dbParams, $dbConfig );
|
||||
$this->dateTimeProvider = new TestDateTimeProvider(
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace ActivityPub\Test;
|
||||
namespace ActivityPub\Test\Objects;
|
||||
|
||||
use DateTime;
|
||||
use BadMethodCallException;
|
||||
@ -29,13 +29,13 @@ class ObjectsServiceTest extends SQLiteTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
$dbConfig = Setup::createAnnotationMetadataConfiguration(
|
||||
array( __DIR__ . '/../src/Entities' ), true
|
||||
array( __DIR__ . '/../../src/Entities' ), true
|
||||
);
|
||||
$namingStrategy = new PrefixNamingStrategy( '' );
|
||||
$dbConfig->setNamingStrategy( $namingStrategy );
|
||||
$dbParams = array(
|
||||
'driver' => 'pdo_sqlite',
|
||||
'path' => __DIR__ . '/db.sqlite',
|
||||
'path' => $this->getDbPath(),
|
||||
);
|
||||
$this->entityManager = EntityManager::create( $dbParams, $dbConfig );
|
||||
$this->dateTimeProvider = new TestDateTimeProvider(
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace ActivityPub\Test;
|
||||
namespace ActivityPub\Test\Utils;
|
||||
|
||||
use ActivityPub\Utils\Util;
|
||||
use PHPUnit\Framework\TestCase;
|
Loading…
Reference in New Issue
Block a user