* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development */ namespace VuFindTest; /** * Proxy service unit test. * * PHP version 5 * * Copyright (C) Villanova University 2010. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category VuFind * @package Tests * @author David Maus * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development */ class HttpServiceAwareTraitTest extends \PHPUnit\Framework\TestCase { /** * Test setter * * @return void */ public function testSetHttpService() { $mock = $this->getMockBuilder('VuFindHttp\HttpService')->getMock(); $test = new class () { use \VuFindHttp\HttpServiceAwareTrait; }; $test->setHttpService($mock); $this->assertEquals($mock, $this->getProperty($test, 'httpService')); } /** * Return protected or private property. * * Uses PHP's reflection API in order to modify property accessibility. * * @param object|string $object Object or class name * @param string $property Property name * * @throws \ReflectionException Property does not exist * * @return mixed */ protected function getProperty($object, $property) { $reflectionProperty = new \ReflectionProperty($object, $property); $reflectionProperty->setAccessible(true); return $reflectionProperty->getValue($object); } }