Test DB schema update
This commit is contained in:
parent
484d35d3ce
commit
eb1b8dd833
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
vendor/
|
||||
vendor/
|
||||
test/db.sqlite
|
@ -11,7 +11,7 @@
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": "phpunit --bootstrap ./test/Config/bootstrap.php test"
|
||||
"test": "phpunit -c ./test/config/config.xml test"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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
2
test/config/config.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<phpunit bootstrap="./bootstrap.php">
|
||||
</phpunit>
|
Loading…
Reference in New Issue
Block a user