Test DB schema update

This commit is contained in:
Jeremy Dormitzer 2018-11-20 06:29:09 -05:00
parent 484d35d3ce
commit eb1b8dd833
9 changed files with 32 additions and 9 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
vendor/
vendor/
test/db.sqlite

View File

@ -11,7 +11,7 @@
}
],
"scripts": {
"test": "phpunit --bootstrap ./test/Config/bootstrap.php test"
"test": "phpunit -c ./test/config/config.xml test"
},
"repositories": [
{

View File

@ -16,7 +16,7 @@ class ActivityPub
* Constructs a new ActivityPub instance
*
* @param array $opts Array of options. Valid keys are
* 'dbuser', 'dbpass', 'dbname', 'dbprefix', and 'isDevMode'.
* 'dbOptions', 'dbprefix', and 'isDevMode'.
*/
public function __construct( $opts )
{

View File

@ -12,11 +12,12 @@ namespace ActivityPub\Entities;
* is a static value, like { "url": "https://example.com" }. An object is another foreign
* key into the objects table that represents the value of the JSON-LD field if the
* field is another JSON-LD object, like { "inReplyTo": { <another object } }.
* A subject can have multiple values for the same predicate - this represents a JSON-LD
* array.
*/
class IndexEntity
{
// subject and predicate form a composite primary key (https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/composite-primary-keys.html)
// value and object are mutually exclusive, but for portability's sake this should be implmeneted in code
// TODO what should the primary key be?
protected $subject;
protected $predicate;
protected $value;

View File

@ -1,7 +1,8 @@
<?php
require_once dirname( __FILE__ ) . '/Config/APTestCase.php';
require_once dirname( __FILE__ ) . '/Config/ArrayDataSet.php';
require_once dirname( __FILE__ ) . '/config/APTestCase.php';
require_once dirname( __FILE__ ) . '/config/ArrayDataSet.php';
use ActivityPub\ActivityPub;
use ActivityPub\Config\APTestCase;
use ActivityPub\Config\ArrayDataSet;
@ -12,7 +13,25 @@ class ActivityPubTest extends APTestCase
}
public function testItCreatesSchema() {
$this->assertTrue( file_exists( $this->dbPath ) );
$this->assertTrue( file_exists( $this->getDbPath() ) );
}
/**
* @depends testItCreatesSchema
*/
public function testItUpdatesSchema() {
$activityPub = new ActivityPub(array(
'dbOptions' => array(
'driver' => 'pdo_sqlite',
'path' => $this->getDbPath(),
),
) );
$activityPub->updateSchema();
$this->assertTrue( file_exists( $this->getDbPath() ) );
}
private function getDbPath() {
return dirname( __FILE__ ) . '/db.sqlite';
}
}
?>

View File

@ -10,7 +10,7 @@ abstract class APTestCase extends TestCase
private static $pdo = null;
private $conn = null;
protected $dbPath = '';
private $dbPath = '';
final public function getConnection() {
if ( $this->conn === null ) {

2
test/config/config.xml Normal file
View File

@ -0,0 +1,2 @@
<phpunit bootstrap="./bootstrap.php">
</phpunit>