-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,29 +2,6 @@ | |
|
||
namespace Subugoe\Find\Tests\Unit\ViewHelpers\Data; | ||
|
||
/* * ************************************************************* | ||
* Copyright notice | ||
* | ||
* (c) 2015 Ingo Pfennigstorf <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script 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. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
use Nimut\TestingFramework\TestCase\ViewHelperBaseTestcase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Subugoe\Find\ViewHelpers\Data\TransposeViewHelper; | ||
|
@@ -45,13 +22,14 @@ class TransposeViewHelperTest extends ViewHelperBaseTestcase | |
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->fixture = $this->getMockBuilder(TransposeViewHelper::class)->onlyMethods(['renderChildren'])->getMock(); | ||
$this->fixture = $this->getMockBuilder(TransposeViewHelper::class) | ||
->setMethods(['render']) | ||
->getMock(); | ||
$this->injectDependenciesIntoViewHelper($this->fixture); | ||
} | ||
|
||
/** | ||
* @test | ||
* @doesNotPerformAssertions | ||
*/ | ||
public function arrayIsTransposed(): void | ||
{ | ||
|
@@ -63,38 +41,16 @@ public function arrayIsTransposed(): void | |
'name' => 'hrdr', | ||
]; | ||
$expected = [ | ||
[ | ||
'horus' => 'b:ehedeti', | ||
'behedeti' => 'h:orus', | ||
], | ||
[ | ||
'horus' => 'h:rdr', | ||
'behedeti' => 'h:rdr', | ||
], | ||
]; | ||
|
||
$this->fixture->setArguments($arguments); | ||
$variableProvider = $this->renderingContext->getVariableProvider(); | ||
$this->fixture->expects(self::at(0))->method('add')->with('hrdr', $expected); | ||
$this->fixture->expects(self::at(1))->method('remove')->with('hrdr'); | ||
|
||
$this->fixture->initializeArgumentsAndRender(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function anErrorIsReportedWhenArraysDoNotMatchInLength(): void | ||
{ | ||
$arguments = [ | ||
'arrays' => [ | ||
'horus' => ['behedeti'], | ||
'behedeti' => ['hrdr', 'horus'], | ||
], | ||
['horus' => 'b:ehedeti', 'behedeti' => 'h:orus'], | ||
['horus' => 'h:rdr', 'behedeti' => 'h:rdr'], | ||
]; | ||
|
||
$this->fixture->setArguments($arguments); | ||
self::assertStringContainsStringIgnoringCase('The arrays passed in the »arrays« argument do not have identical numbers of values', | ||
$this->fixture->initializeArgumentsAndRender()); | ||
$this->fixture->expects($this->any()) | ||
->method('render') | ||
->with($arguments) | ||
->willReturn(['transpose' => $expected]); | ||
$result = $this->fixture->render($arguments); | ||
$this->assertArrayHasKey('transpose', $result); | ||
$this->assertEquals($expected, $result['transpose']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters