Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corona: Add camelCaps methods to the Request class #35

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 224 additions & 10 deletions src/Lunr/Corona/Request.php

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/Lunr/Corona/Tests/RequestAddMockValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@
namespace Lunr\Corona\Tests;

/**
* Tests for the add_mock_values function.
* Tests for the addMockValues function.
*
* @covers Lunr\Corona\Request
*/
class RequestAddMockValuesTest extends RequestTestCase
{

/**
* Test add_mock_values() adds values correctly when current mock values are empty.
* Test addMockValues() adds values correctly when current mock values are empty.
*
* @covers Lunr\Corona\Request::add_mock_values
* @covers Lunr\Corona\Request::addMockValues
*/
public function testAddMockValuesWithCurrentEmpty(): void
{
$mock = [ 'controller' => 'new_controller' ];

$this->setReflectionPropertyValue('mock', []);

$this->class->add_mock_values($mock);
$this->class->addMockValues($mock);

$mockResult = $this->getReflectionPropertyValue('mock');

$this->assertEquals($mock, $mockResult);
}

/**
* Test add_mock_values() adds values correctly when current mock values are set.
* Test addMockValues() adds values correctly when current mock values are set.
*
* @covers Lunr\Corona\Request::add_mock_values
* @covers Lunr\Corona\Request::addMockValues
*/
public function testAddMockValuesWithCurrentSet(): void
{
Expand All @@ -57,7 +57,7 @@ public function testAddMockValuesWithCurrentSet(): void

$this->setReflectionPropertyValue('mock', $currentMock);

$this->class->add_mock_values($mock);
$this->class->addMockValues($mock);

$mockResult = $this->getReflectionPropertyValue('mock');

Expand Down
6 changes: 3 additions & 3 deletions src/Lunr/Corona/Tests/RequestBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public function testRequestDefaultValues($key, $value): void
}

/**
* Test that register_parser() registers a parser.
* Test that registerParser() registers a parser.
*
* @covers Lunr\Corona\Request::register_parser
* @covers Lunr\Corona\Request::registerParser
*/
public function testRegisterParser(): void
{
Expand All @@ -111,7 +111,7 @@ public function testRegisterParser(): void
->method('get_request_value_type')
->willReturn('Lunr\Corona\Parser\Foo\Foo');

$this->class->register_parser($parser);
$this->class->registerParser($parser);

$parsers = $this->getReflectionPropertyValue('parsers');

Expand Down
69 changes: 69 additions & 0 deletions src/Lunr/Corona/Tests/RequestDeprecatedAddMockValuesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/**
* This file contains the RequestDeprecatedAddMockValuesTest class.
*
* SPDX-FileCopyrightText: Copyright 2014 M2mobi B.V., Amsterdam, The Netherlands
* SPDX-FileCopyrightText: Copyright 2022 Move Agency Group B.V., Zwolle, The Netherlands
* SPDX-License-Identifier: MIT
*/

namespace Lunr\Corona\Tests;

/**
* Tests for the add_mock_values function.
*
* @covers Lunr\Corona\Request
*/
class RequestDeprecatedAddMockValuesTest extends RequestTestCase
{

/**
* Test add_mock_values() adds values correctly when current mock values are empty.
*
* @covers Lunr\Corona\Request::add_mock_values
*/
public function testAddMockValuesWithCurrentEmpty(): void
{
$mock = [ 'controller' => 'new_controller' ];

$this->setReflectionPropertyValue('mock', []);

$this->class->add_mock_values($mock);

$mockResult = $this->getReflectionPropertyValue('mock');

$this->assertEquals($mock, $mockResult);
}

/**
* Test add_mock_values() adds values correctly when current mock values are set.
*
* @covers Lunr\Corona\Request::add_mock_values
*/
public function testAddMockValuesWithCurrentSet(): void
{
$currentMock = [
'controller' => 'old_controller',
'method' => 'call',
];

$mock = [ 'controller' => 'new_controller' ];

$expectedMock = [
'controller' => 'new_controller',
'method' => 'call',
];

$this->setReflectionPropertyValue('mock', $currentMock);

$this->class->add_mock_values($mock);

$mockResult = $this->getReflectionPropertyValue('mock');

$this->assertEquals($expectedMock, $mockResult);
}

}

?>
Loading