Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 18, 2023
1 parent 508c116 commit 7d42673
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 28 deletions.
10 changes: 2 additions & 8 deletions src/Controller/Component/RecaptchaComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ class RecaptchaComponent extends Component
public function initialize(array $config = []): void
{
if (empty($config)) {
$config = Configure::read('Recaptcha', []);
$this->setConfig(Configure::read('Recaptcha', []));
}

$this->setConfig($config);

$method = 'setHelpers';
if (method_exists($this->getController()->viewBuilder(), 'addHelpers')) {
$method = 'addHelpers';
}
$this->getController()->viewBuilder()->{$method}(['Recaptcha.Recaptcha' => $this->_config]);
$this->getController()->viewBuilder()->addHelpers(['Recaptcha.Recaptcha' => $this->_config]);
}

/**
Expand Down
11 changes: 0 additions & 11 deletions src/View/Helper/RecaptchaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
*/
class RecaptchaHelper extends Helper
{
/**
* Constructor.
*
* @param array $config The settings for this helper.
* @return void
*/
public function initialize(array $config = []): void
{
$this->setConfig($config);
}

/**
* Display recaptcha function
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function setUp(): void
->getMock();
}

public function testVerifyFalse()
public function testVerifyFalse(): void
{
$this->assertFalse($this->Recaptcha->verify());

Expand All @@ -48,7 +48,7 @@ public function testVerifyFalse()
$this->assertFalse($this->Recaptcha->verify());
}

public function testVerifyTrue()
public function testVerifyTrue(): void
{
$this->controller->setRequest($this->controller->getRequest()->withData('g-recaptcha-response', 'foo'));

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/RecaptchaHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setUp(): void
);
}

public function testDisplay()
public function testDisplay(): void
{
$result = $this->Recaptcha->display();
$this->assertTrue(is_string($result));
Expand Down
6 changes: 0 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
declare(strict_types=1);

use Cake\Core\Configure;

/*
* Test suite bootstrap
*
Expand All @@ -24,7 +22,3 @@
unset($findRoot);
chdir($root);
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';

Configure::write('Error.ignoredDeprecationPaths', [
'src/TestSuite/Fixture/FixtureInjector.php',
]);

0 comments on commit 7d42673

Please sign in to comment.