Fix all tests

This commit is contained in:
Jeremy Dormitzer 2019-01-17 17:14:11 -05:00
parent a302fa8708
commit 4a1d2f7c08
2 changed files with 14 additions and 13 deletions

View File

@ -29,7 +29,7 @@ class ObjectsService
{
$this->entityManager = $entityManager;
$this->dateTimeProvider = $dateTimeProvider;
$this->httpClient = new Client();
$this->httpClient = new Client( array( 'http_errors' => false ) );
}
/**
@ -83,7 +83,8 @@ class ObjectsService
);
$this->entityManager->persist( $fieldEntity );
} else {
if ( filter_var( $fieldValue, FILTER_VALIDATE_URL ) !== false ) {
if ( $fieldName !== 'id' &&
filter_var( $fieldValue, FILTER_VALIDATE_URL ) !== false ) {
$dereferenced = $this->dereference( $fieldValue );
if ( $dereferenced ) {
$fieldEntity = Field::withObject(
@ -116,7 +117,7 @@ class ObjectsService
{
$object = $this->getObject( $id );
if ( $object ) {
return $this->collapseObjectToDepth( $object, $depth );
return $object;
}
// TODO sign this request?
$request = new Request( 'GET', $id, array(
@ -237,7 +238,7 @@ class ObjectsService
* @return ActivityPubObject|null The updated object,
* or null if an object with that id isn't in the DB
*/
public function updateObject( $id, $updatedFields )
public function update( $id, $updatedFields )
{
$object = $this->getObject( $id );
if ( ! $object ) {

View File

@ -500,7 +500,7 @@ class ObjectsServiceTest extends SQLiteTestCase
),
);
$object = $this->objectsService->persist( $fields );
$arr = $object->asArray();
$arr = $object->asArray( 3 );
$this->assertEquals( $fields, $arr );
}
@ -640,7 +640,7 @@ class ObjectsServiceTest extends SQLiteTestCase
$this->assertCount( 1, $results );
$this->assertContainsOnlyInstancesOf( ActivityPubObject::class, $results );
$this->assertEquals( $objectOne, $results[0] );
$this->assertEquals( $fieldsOne, $results[0]->asArray() );
$this->assertEquals( $fieldsOne, $results[0]->asArray( 3 ) );
$this->assertNotContains( $objectTwo, $results );
}
@ -676,7 +676,7 @@ class ObjectsServiceTest extends SQLiteTestCase
$this->assertCount( 1, $results );
$this->assertContainsOnlyInstancesOf( ActivityPubObject::class, $results );
$this->assertEquals( $object, $results[0] );
$this->assertEquals( $fields, $results[0]->asArray() );
$this->assertEquals( $fields, $results[0]->asArray( 5 ) );
}
public function testItReturnsEmptyArrayForNoMatches()
@ -763,7 +763,7 @@ class ObjectsServiceTest extends SQLiteTestCase
'content' => 'This is a note'
);
$object = $this->objectsService->persist( $fields );
$found = $this->objectsService->getObject( 'https://example.com/note/1' );
$found = $this->objectsService->dereference( 'https://example.com/note/1' );
$this->assertNotNull( $found );
$this->assertEquals( $object, $found );
}
@ -776,7 +776,7 @@ class ObjectsServiceTest extends SQLiteTestCase
'content' => 'This is a note'
);
$object = $this->objectsService->persist( $fields );
$found = $this->objectsService->getObject( 'https://example.com/note/2' );
$found = $this->objectsService->dereference( 'https://example.com/note/2' );
$this->assertNull( $found );
}
@ -791,7 +791,7 @@ class ObjectsServiceTest extends SQLiteTestCase
$object = $this->objectsService->persist( $fields );
$update = array( 'content' => 'This note has been updated' );
$updateTime = $this->getTime( 'update' );
$this->objectsService->updateObject( 'https://example.com/notes/1', $update );
$this->objectsService->update( 'https://example.com/notes/1', $update );
$expected = new ArrayDataSet( array(
'objects' => array(
array(
@ -858,7 +858,7 @@ class ObjectsServiceTest extends SQLiteTestCase
'id' => 'https://example.com/actors/2',
) );
$updateTime = $this->getTime( 'update' );
$this->objectsService->updateObject( 'https://example.com/notes/1', $update );
$this->objectsService->update( 'https://example.com/notes/1', $update );
$expected = new ArrayDataSet( array(
'objects' => array(
array(
@ -964,7 +964,7 @@ class ObjectsServiceTest extends SQLiteTestCase
'https://example.com/likes/4',
) );
$updateTime = $this->getTime( 'update' );
$this->objectsService->updateObject( 'https://example.com/notes/1', $update );
$this->objectsService->update( 'https://example.com/notes/1', $update );
$expected = new ArrayDataSet( array(
'objects' => array(
array(
@ -1058,7 +1058,7 @@ class ObjectsServiceTest extends SQLiteTestCase
$object = $this->objectsService->persist( $fields );
$update = array( 'content' => null );
$updateTime = $this->getTime( 'update' );
$this->objectsService->updateObject( 'https://example.com/notes/1', $update );
$this->objectsService->update( 'https://example.com/notes/1', $update );
$expected = new ArrayDataSet( array(
'objects' => array(
array(