setNamingStrategy( $namingStrategy ); $dbParams = array( 'driver' => 'pdo_sqlite', 'path' => self::getDbPath(), ); $entityManager = EntityManager::create( $dbParams, $dbConfig ); $dateTimeProvider = new TestDateTimeProvider( array( 'objects-service.create' => new DateTime( "12:00" ), 'objects-service.update' => new DateTime( "12:01" ), ) ); $httpClient = $this->getMock( Client::class ); $httpClient->method( 'send' )->willReturn( new Response( 404 ) ); $this->objectsService = new ObjectsService( $entityManager, $dateTimeProvider, $httpClient ); $this->blockService = new BlockService( $this->objectsService ); } public function provideTestGetBlockedActorIds() { return array( array( array( 'id' => 'blocksExist', 'initialData' => array( array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ), ), ), 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array( 'https://elsewhere.com/actors/1' ), ) ), array( array( 'id' => 'noBlocksExist', 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array(), ) ), array( array( 'id' => 'multipleBlocksExist', 'initialData' => array( array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ), ), array( 'id' => 'https://example.com/blocks/2', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/2', ), ), ), 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array( 'https://elsewhere.com/actors/1', 'https://elsewhere.com/actors/2' ), ) ), array( array( 'id' => 'blocksExistsFromDifferentActor', 'initialData' => array( array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ), ), array( 'id' => 'https://example.com/blocks/2', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/2', ), ), ), 'blockingActorId' => 'https://example.com/actors/2', 'expectedBlockedActorIds' => array(), ) ), array( array( 'id' => 'differentTypesOfActivitiesExistWithSameObjectAndActor', 'initialData' => array( array( 'id' => 'https://example.com/follows/1', 'type' => 'Follow', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ), ), array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/2', ), ), ), 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array( 'https://elsewhere.com/actors/2' ), ) ), array( array( 'id' => 'undoneBlocks', 'initialData' => array( array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ) ), array( 'id' => 'https://example.com/blocks/2', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/2', ) ), array( 'id' => 'https://example.com/undos/1', 'type' => 'Undo', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ) ) ), ), 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array( 'https://elsewhere.com/actors/2' ), ) ), array( array( 'id' => 'irrelevantUndonBlocks', 'initialData' => array( array( 'id' => 'https://example.com/blocks/1', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/1', ) ), array( 'id' => 'https://example.com/blocks/2', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/2', ) ), array( 'id' => 'https://example.com/undos/1', 'type' => 'Undo', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://example.com/blocks/3', 'type' => 'Block', 'actor' => array( 'id' => 'https://example.com/actors/1', ), 'object' => array( 'id' => 'https://elsewhere.com/actors/3', ) ) ), ), 'blockingActorId' => 'https://example.com/actors/1', 'expectedBlockedActorIds' => array( 'https://elsewhere.com/actors/1', 'https://elsewhere.com/actors/2' ), ) ) ); } /** * @dataProvider provideTestGetBlockedActorIds */ public function testGetBlockedActorIds($testCase) { if ( array_key_exists( 'initialData', $testCase ) ) { foreach ( $testCase['initialData'] as $object ) { $this->objectsService->persist( $object ); } } $blockedActorIds = $this->blockService->getBlockedActorIds( $testCase['blockingActorId'] ); $this->assertEquals( $testCase['expectedBlockedActorIds'], $blockedActorIds, "Error on test $testCase[id]" ); } /** * Returns the test dataset. * * @return PHPUnit_Extensions_Database_DataSet_IDataSet */ protected function getDataSet() { return new ArrayDataSet( array() ); } }__halt_compiler();----SIGNATURE:----4LUDus3BkUM/e0hfmOq7oG5BX5V3e4aaZx/0X8F/RZuGc0sJ/G65N77qMuzuI3EKqiLR4S1hQ2GMyzarvGCNdDrmryAJHTBhyNkDfGMmkSK3tQeNFE0fNUwr+9UVHE7mqlN+bYHGEMwQCLIQ9zYY9I80Jz6UnN3vFJd8K2W1txH5vsI6BVg0GV6CHuYMfwRE8eazguVxHBhaN07kGckA+5mZAumgZXMRVApDI91Hk38Bj20aq2e+MRMLx6cEkq3t3R07UVUGjWIFcKuOUeGm/L58W/v/ox2Gc5nlYHd8O457PcACDljNILqArhzYhYGGbkQO3OjA8AuqEm6+DhjlCAEEyyBNvg8MwYUid8cszSYZJe7M8KgKqXWIxU8kIJrrqBVg4RQlICI2WNpAshu3dtJqt6ip+sJUoLt0CrgXfWRwDUVeCIAz2eQnb4RaGRPa3OkaV4XG+AtHktEdpNtSJKE69+5MlhCBF9Hm/iaZfu6g9PCe1qLEw1e87TcdwoR0MXzMxl3fWVi4I5FBzEhDwIRaitWFKfdPXSYVDVwzsIK/Ftn+b3x8mo63AyUcgyxM5Mi1eqQrmPK6ljj3OXibQqCFqnUO4mvG0PZ4FqHvTXgWKbrufOtnT/WniXc8xTeP2hfL8s0m2vWpAppZ8iwk/7K+H5otWSBiXb3m0Og6k2c=----ATTACHMENT:----MzM1MDk3NjcyMzEzODE1NyA2OTI2NzY4MjM5ODEzMjcyIDQyMzA5MTExMDUxOTkxNDg=