Skip to content

Add strict types #118

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

Merged
merged 1 commit into from
Feb 17, 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
6 changes: 5 additions & 1 deletion src/Codeception/Lib/Connector/Yii2.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector;

use Codeception\Exception\ConfigurationException;
Expand Down Expand Up @@ -402,10 +405,11 @@ protected function encodeCookies(
: $cookie->value;
$value = $security->hashData(serialize($data), $validationKey);
}
$expires = is_int($cookie->expire) ? (string)$cookie->expire : null;
$c = new Cookie(
$cookie->name,
$value,
$cookie->expire,
$expires,
$cookie->path,
$cookie->domain,
$cookie->secure,
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Lib/Connector/Yii2/ConnectionWatcher.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Yii2;

Expand Down
3 changes: 3 additions & 0 deletions src/Codeception/Lib/Connector/Yii2/FixturesStore.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Yii2;

use yii\test\FixtureTrait;
Expand Down
3 changes: 3 additions & 0 deletions src/Codeception/Lib/Connector/Yii2/Logger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Yii2;

use Codeception\Util\Debug;
Expand Down
3 changes: 3 additions & 0 deletions src/Codeception/Lib/Connector/Yii2/TestMailer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Yii2;

use yii\mail\BaseMailer;
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Lib/Connector/Yii2/TransactionForcer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);

namespace Codeception\Lib\Connector\Yii2;

Expand Down
9 changes: 6 additions & 3 deletions src/Codeception/Module/Yii2.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Codeception\Module;

use Codeception\Exception\ConfigurationException;
Expand Down Expand Up @@ -735,7 +738,7 @@ public function seeEmailIsSent(?int $num = null): void
$this->assertNotEmpty($this->grabSentEmails(), 'emails were sent');
return;
}
$this->assertEquals($num, count($this->grabSentEmails()), 'number of sent emails is equal to ' . $num);
$this->assertSame($num, count($this->grabSentEmails()), 'number of sent emails is equal to ' . $num);
}

/**
Expand All @@ -757,7 +760,7 @@ public function dontSeeEmailIsSent(): void
* <?php
* $I->seeEmailIsSent();
* $messages = $I->grabSentEmails();
* $I->assertEquals('admin@site,com', $messages[0]->getTo());
* $I->assertSame('admin@site,com', $messages[0]->getTo());
* ```
*
* @part email
Expand All @@ -780,7 +783,7 @@ public function grabSentEmails(): array
* <?php
* $I->seeEmailIsSent();
* $message = $I->grabLastSentEmail();
* $I->assertEquals('admin@site,com', $message->getTo());
* $I->assertSame('admin@site,com', $message->getTo());
* ```
* @part email
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/closeConnections/fixtures/EmptyFixture.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\fixtures;

use yii\test\DbFixture;
Expand Down
4 changes: 3 additions & 1 deletion tests/cases/closeConnections/functional/FixturesCest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnections;

use Codeception\Example;
Expand Down Expand Up @@ -29,7 +31,7 @@ protected function numberProvider()
*/
public function NoConnections(FunctionalTester $I, Example $example)
{
$I->assertEquals(SqlliteHelper::connectionCount(), $example['count']);
$I->assertSame(SqlliteHelper::connectionCount(), $example['count']);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnections;

use Codeception\Example;
Expand Down Expand Up @@ -29,7 +31,7 @@ protected function numberProvider()
*/
public function NoConnections(FunctionalTester $I, Example $example)
{
$I->assertEquals(SqlliteHelper::connectionCount(), $example['count']);
$I->assertSame(SqlliteHelper::connectionCount(), $example['count']);
}

}
4 changes: 3 additions & 1 deletion tests/cases/closeConnections/functional/NoFixturesCest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnections;

use Codeception\Example;
Expand All @@ -20,6 +22,6 @@ protected function numberProvider()
*/
public function NoConnections(FunctionalTester $I, Example $example)
{
$I->assertEquals(SqlliteHelper::connectionCount(), $example['count']);
$I->assertSame(SqlliteHelper::connectionCount(), $example['count']);
}
}
4 changes: 3 additions & 1 deletion tests/cases/closeConnections/helpers/SqlliteHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\helpers;

class SqlliteHelper
Expand All @@ -9,7 +11,7 @@ class SqlliteHelper
public static function getTmpFile()
{
if (empty(self::$temp_name)) {
self::$temp_name = tempnam(null, '/file0');
self::$temp_name = tempnam('', '/file0');
}
return self::$temp_name;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnectionsNoCleanup;

use tests\FunctionalTester;
Expand All @@ -20,19 +22,19 @@ public function _fixtures()
public function NoConnections1(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(0, $count);
$I->assertSame(0, $count);
}

public function NoConnections2(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(0, $count);
$I->assertSame(0, $count);
}

public function NoConnections3(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(0, $count);
$I->assertSame(0, $count);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnectionsNoCleanup;

use tests\FunctionalTester;
Expand All @@ -20,18 +22,18 @@ public function _before(FunctionalTester $I)
public function OnlyOneConnection1(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(1, $count);
$I->assertSame(1, $count);
}

public function OnlyOneConnection2(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(1, $count);
$I->assertSame(1, $count);
}

public function OnlyOneConnection3(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(1, $count);
$I->assertSame(1, $count);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests\closeConnectionsNoCleanup;

use tests\FunctionalTester;
Expand All @@ -11,7 +13,7 @@ class ThirdCest
public function NoConnections1(FunctionalTester $I)
{
$count = SqlliteHelper::connectionCount();
$I->assertEquals(0, $count);
$I->assertSame(0, $count);
}

public function OnlyOneConnection2(FunctionalTester $I)
Expand All @@ -23,7 +25,7 @@ public function OnlyOneConnection2(FunctionalTester $I)
]);

$count = SqlliteHelper::connectionCount();
$I->assertEquals(1, $count);
$I->assertSame(1, $count);
}

public function OnlyOneConnection3(FunctionalTester $I)
Expand All @@ -35,6 +37,6 @@ public function OnlyOneConnection3(FunctionalTester $I)
]);

$count = SqlliteHelper::connectionCount();
$I->assertEquals(1, $count);
$I->assertSame(1, $count);
}
}
2 changes: 2 additions & 0 deletions tests/cases/events/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\controllers;
use yii\web\Controller;

Expand Down
15 changes: 9 additions & 6 deletions tests/cases/events/functional/ResponseCest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use Codeception\Lib\Connector\Yii2;
Expand All @@ -18,11 +21,11 @@ public function testAfterSend(FunctionalTester $I)
});
$I->assertEmpty($sources);
$I->amOnRoute('/');
$I->assertEquals(['config', 'bootstrap'], $sources);
$I->assertSame(['config', 'bootstrap'], $sources);

$sources = [];
$I->amOnRoute('/');
$I->assertEquals(['config', 'bootstrap'], $sources);
$I->assertSame(['config', 'bootstrap'], $sources);

}

Expand All @@ -41,13 +44,13 @@ public function testAfterSendWithRecreate(FunctionalTester $I, \Codeception\Modu
});
$I->assertEmpty($sources);
$I->amOnRoute('/');
$I->assertEquals(['config', 'bootstrap'], $sources);
$I->assertSame(['config', 'bootstrap'], $sources);

$sources = [];
$I->amOnRoute('/');

// The module should fall back to the CLEAN_CLEAR method and keep event handlers intact.
$I->assertEquals(['config', 'bootstrap'], $sources);
$I->assertSame(['config', 'bootstrap'], $sources);

}

Expand All @@ -70,14 +73,14 @@ public function testAfterSendWithForcedRecreate(FunctionalTester $I, \Codeceptio

// We recreated the response component, since it has an event handler in its config
// that event handler will still work.
$I->assertEquals(['config'], $sources);
$I->assertSame(['config'], $sources);

$sources = [];
$I->amOnRoute('/');

// We recreated the response component, since it has an event handler in its config
// that event handler will still work.
$I->assertEquals(['config'], $sources);
$I->assertSame(['config'], $sources);

}
}
2 changes: 2 additions & 0 deletions tests/cases/locale-urls/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\localeurls\controllers;
use yii\helpers\Url;
use yii\web\Controller;
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/locale-urls/functional/LocaleUrlCest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use yii\web\Application;
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/mock-mailer/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\mockmailer\controllers;

use yii\web\Controller;
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/mock-mailer/functional/MockMailerCest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use yii\web\Application;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\pageCacheHeaderAlreadySent\controllers;

use yii\filters\PageCache;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class PageCest {

public function testCache(\tests\FunctionalTester $I)
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/simple/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\simple\controllers;
use app\simple\helpers\EmptyString;
use yii\base\Action;
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/simple/functional/SimpleCest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use Codeception\Exception\ModuleException;
Expand Down
Loading