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:----1ddPHxN7o0HDOmN1mDebjhX0tQMizNg5CmP0gLk9hk0rOunQauR7yi/XWyAK/VWtF9eFbgwvMLhRhOL4RC57MHumh0/yvw0MY5MnekkLItVvJmArTflqi1iLDp0NrbRoEB5zrT0xEE+QNNUR7tAGD2FP3ACuiQ+2mUmRxcC+GU5am0mUOSfiVKypduwbhfy62EONM07n5gsAoRJSqKIXj93OglnHmGSMEobR68CcuXLaQj2C5Lhtz+5f8qtbq8vRupCXcOIrQX1UbJkGdgmfKZry9FrFkeLb97K3+MruKe/ix+VB+vvZD9GlpZa9006cl1fkheHTgph9Eln3ugEcG0tDDto0vSghWwML+4qFZx8Ydt50b9GpbY+u65Tu2mro7TZe/EgWltdX6gyE2SCvbPvv8VVis0POvnYkMVt8kulRg4zQ6C5ofLf9uznHTfbONVkoixMeOPdRyM+8BNyLtvhBBWMfodtPq8aOKVYAUFFBTTEctfuttVB8zxq0jDo52kfyJRvXI1m1LEJdos1RN7jdSuMA7Nv2KK7qf8U4HIk1eqDXM9fwuEjCw4liecJwgrdQWoy0V9/aJgPLw6+tCp92ih+FUUkqnXu7Q/IBUhvCIdb+ZS5kO1GZzbaz4h67J6jdAqY0ydxkMbRIG6BJBXRDfOHTJPArVvOlRJUhmxQ=----ATTACHMENT:----NDQzMTQyMjE3MTI4MDMwIDg5NzIwMDg5NzQ1MTQ2NjAgNTgyNzM1MTIzMTA1MjI2MQ==