Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Jul 22, 2017
1 parent 0b41100 commit ae75e80
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 30 deletions.
7 changes: 4 additions & 3 deletions Classes/DataProvider/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use TYPO3\CMS\Core\Log\LogLevel;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Property\Exception as ExtbaseException;
Expand Down Expand Up @@ -97,9 +98,9 @@ public function getRepositoryForResourceType(ResourceType $resourceType)
$repositoryClass = $this->getRepositoryClassForResourceType($resourceType);
/** @var \TYPO3\CMS\Extbase\Persistence\RepositoryInterface $repository */
$repository = $this->objectManager->get($repositoryClass);
$repository->setDefaultQuerySettings(
$this->objectManager->get(RestQuerySettings::class)
);
/** @var QuerySettingsInterface $defaultQuerySettings */
$defaultQuerySettings = $this->objectManager->get(RestQuerySettings::class);
$repository->setDefaultQuerySettings($defaultQuerySettings);

return $repository;
}
Expand Down
10 changes: 9 additions & 1 deletion Classes/ObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,21 @@ public function getAuthenticationProvider()
$this->authenticationProvider = $this->get($authenticationProviderClass);
} else {
// Use the default Authentication Provider
$this->authenticationProvider = $this->get(
$this->authenticationProvider = call_user_func(
[$this, 'get'],
AuthenticationProviderCollection::class,
[
$this->get(BasicAuthenticationProvider::class),
$this->get(CredentialsAuthenticationProvider::class),
]
);
// $this->authenticationProvider = $this->get(
// AuthenticationProviderCollection::class,
// [
// $this->get(BasicAuthenticationProvider::class),
// $this->get(CredentialsAuthenticationProvider::class),
// ]
// );
}
}

Expand Down
10 changes: 6 additions & 4 deletions Classes/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Cundd\Rest\Http\Header;
use Cundd\Rest\Http\RestRequestInterface;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Http\Response as TYPO3Response;
use Zend\Diactoros\Response as ZendResponse;

/**
* Factory class to create Response objects
Expand Down Expand Up @@ -136,11 +138,11 @@ private function createFormattedResponse($data, $status, $forceError, RestReques
*/
private function getResponseImplementationClass()
{
if (class_exists(\TYPO3\CMS\Core\Http\Response::class)) {
return \TYPO3\CMS\Core\Http\Response::class;
if (class_exists(TYPO3Response::class)) {
return TYPO3Response::class;
}
if (class_exists(\Zend\Diactoros\Response::class)) {
return \Zend\Diactoros\Response::class;
if (class_exists(ZendResponse::class)) {
return ZendResponse::class;
}
throw new \LogicException('No response implementation found');
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Profiler
protected $outputHandler;

/**
* @param resource|object $outputHandler Output handler to use
* @param resource|object|bool $outputHandler Output handler to use
*/
public function __construct($outputHandler = STDOUT)
{
Expand Down
10 changes: 6 additions & 4 deletions Tests/Functional/AbstractCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
use Cundd\Rest\Tests\ClassBuilderTrait;
use Cundd\Rest\Tests\RequestBuilderTrait;
use Cundd\Rest\Tests\ResponseBuilderTrait;
use TYPO3\CMS\Core\Tests\FunctionalTestCase;
use TYPO3\CMS\Extbase\Object\ObjectManager;

class AbstractCase extends \TYPO3\CMS\Core\Tests\FunctionalTestCase
class AbstractCase extends FunctionalTestCase
{
use ResponseBuilderTrait;
use RequestBuilderTrait;
use ClassBuilderTrait;

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
* @var ObjectManager
*/
protected $objectManager;

Expand All @@ -24,7 +26,7 @@ public function setUp()

$_SERVER['HTTP_HOST'] = 'rest.cundd.net';

$this->objectManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
$this->objectManager = new ObjectManager();
}

/**
Expand All @@ -36,7 +38,7 @@ public function setUp()
*/
public function buildRequestWithUri($uri, $format = null)
{
return \Cundd\Rest\Tests\RequestBuilderTrait::buildTestRequest(
return RequestBuilderTrait::buildTestRequest(
$uri,
null, // $method
[], // $params
Expand Down
3 changes: 2 additions & 1 deletion Tests/Functional/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Cundd\Rest\Http\Header;
use Cundd\Rest\Http\RestRequestInterface;
use Cundd\Rest\Tests\Functional\AbstractCase;
use Cundd\Rest\Tests\RequestBuilderTrait;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down Expand Up @@ -205,7 +206,7 @@ public function canBeCachedTest(array $header, $expected)
*/
public function postRequestCanNotBeCachedTest()
{
$request = \Cundd\Rest\Tests\RequestBuilderTrait::buildTestRequest('MyAliasedModel', 'POST');
$request = RequestBuilderTrait::buildTestRequest('MyAliasedModel', 'POST');
$response = $this->buildTestResponse(200, [], 'Test content');

$this->assertFalse($this->fixture->canBeCached($request, $response));
Expand Down
5 changes: 3 additions & 2 deletions Tests/Functional/Core/ObjectManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@

namespace Cundd\Rest\Tests\Functional\Core;

use Cundd\Rest\ObjectManager;
use Cundd\Rest\Tests\Functional\AbstractCase;

class ObjectManagerTest extends AbstractCase
{
/**
* @var \Cundd\Rest\ObjectManager
* @var ObjectManager
*/
protected $fixture;

public function setUp()
{
parent::setUp();
require_once __DIR__ . '/../../FixtureClasses.php';
$this->fixture = new \Cundd\Rest\ObjectManager();
$this->fixture = new ObjectManager();
}

public function tearDown()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/VirtualObject/AbstractDatabaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function getTestConfiguration()
{
$testConfiguration = $this->getTestConfigurationData();

return new \Cundd\Rest\VirtualObject\Configuration($testConfiguration['ResourceType']['mapping']);
return new Configuration($testConfiguration['ResourceType']['mapping']);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Tests/Functional/VirtualObject/AbstractVirtualObjectCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Cundd\Rest\Tests\Functional\AbstractCase;
use Cundd\Rest\VirtualObject\Configuration;
use Cundd\Rest\VirtualObject\ConfigurationFactory;


/**
Expand All @@ -26,8 +27,8 @@ protected function getTestConfiguration()
{
$testConfiguration = $this->getTestConfigurationData();

return new \Cundd\Rest\VirtualObject\Configuration(
\Cundd\Rest\VirtualObject\ConfigurationFactory::preparePropertyMapping(
return new Configuration(
ConfigurationFactory::preparePropertyMapping(
$testConfiguration['resource_type']['mapping']
)
);
Expand Down
11 changes: 7 additions & 4 deletions Tests/Functional/VirtualObject/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Cundd\Rest\Tests\Functional\VirtualObject;

use Cundd\Rest\VirtualObject\Configuration;
use Cundd\Rest\VirtualObject\ConfigurationFactory;

require_once __DIR__ . '/AbstractVirtualObjectCase.php';

/**
Expand All @@ -11,7 +14,7 @@
class ConfigurationTest extends AbstractVirtualObjectCase
{
/**
* @var \Cundd\Rest\VirtualObject\Configuration
* @var Configuration
*/
protected $fixture;

Expand All @@ -20,8 +23,8 @@ public function setUp()
parent::setUp();

$testConfiguration = $this->getTestConfigurationData();
$this->fixture = new \Cundd\Rest\VirtualObject\Configuration(
\Cundd\Rest\VirtualObject\ConfigurationFactory::preparePropertyMapping(
$this->fixture = new Configuration(
ConfigurationFactory::preparePropertyMapping(
$testConfiguration['resource_type']['mapping']
)
);
Expand Down Expand Up @@ -111,7 +114,7 @@ public function hasSourceKeyTest()
public function getConfigurationForPropertyTest()
{
$testPropertyConfiguration = [
'type' => 'string',
'type' => 'string',
'column' => 'property_one',
];
$propertyConfiguration = $this->fixture->getConfigurationForProperty('property1');
Expand Down
11 changes: 6 additions & 5 deletions Tests/Unit/Core/RequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Cundd\Rest\RequestFactoryInterface;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Zend\Diactoros\ServerRequestFactory;


/**
Expand Down Expand Up @@ -369,6 +370,10 @@ public function urlAndPathShouldNotIncludeQueryDataFromRequestUriTest()
/**
* @test
* @dataProvider createRequestTestDataProvider
* @param $input
* @param $resourceType
* @param $path
* @param $format
*/
public function createRequestTest($input, $resourceType, $path, $format)
{
Expand Down Expand Up @@ -415,10 +420,6 @@ function ($args) use ($configurationProviderSetting) {
if (isset($args[0])) {
$key = $args[0];

// echo __LINE__.' ';var_dump($key);
// echo __LINE__.' ';var_dump($configurationProviderSetting);
// echo __LINE__.' ';var_dump(isset($configurationProviderSetting[$key]));

return isset($configurationProviderSetting[$key]) ? $configurationProviderSetting[$key] : null;
}

Expand All @@ -428,6 +429,6 @@ function ($args) use ($configurationProviderSetting) {

$_SERVER['SERVER_NAME'] = 'rest.cundd.net';

return new RequestFactory($configurationProviderMock->reveal(), \Zend\Diactoros\ServerRequestFactory::class);
return new RequestFactory($configurationProviderMock->reveal(), ServerRequestFactory::class);
}
}
3 changes: 1 addition & 2 deletions Tests/Unit/Router/ResultConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Cundd\Rest\Tests\Unit\Router;


use Cundd\Rest\RequestFactoryInterface;
use Cundd\Rest\ResponseFactory;
use Cundd\Rest\ResponseFactoryInterface;
use Cundd\Rest\Router\Exception\NotFoundException;
Expand Down Expand Up @@ -41,7 +40,7 @@ class ResultConverterTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
parent::setUp();
$this->responseFactory = new ResponseFactory($this->prophesize(RequestFactoryInterface::class)->reveal());
$this->responseFactory = new ResponseFactory();
$this->exceptionHandler = function () {
};
}
Expand Down

0 comments on commit ae75e80

Please sign in to comment.