Skip to content

Add new assertions #218

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

TavoNiievez
Copy link
Member

No description provided.

@TavoNiievez
Copy link
Member Author

Hi @ThomasLandauer @xEdelweiss ,
I'm proposing adding some new assertions to the module.

Can you take a look at the PR and give me your opinion on the new methods, please?

* $I->seeDoctrineDatabaseIsUp('custom');
* ```
*
* @param non-empty-string $connectionName The name of the Doctrine connection to check.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the name of the entity manager (in case you have multiple)?

* $I->seeDoctrineProxyDirIsWritable('custom');
* ```
*/
public function seeDoctrineProxyDirIsWritable(string $entityManagerName = 'default'): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you aware that Doctrine is moving away from their own proxy system, in favor of the new native PHP lazy objects? So (as far as I understand it), the proxy dir soon won't be needed anymore.

*
* ```php
* <?php
* $I->assertSymfonyVersion('>=', '6.4');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also work with one and three digit versions?

* $I->seeAppEnvAndDebugMatchKernel();
* ```
*/
public function seeAppEnvAndDebugMatchKernel(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. How is it possible that they don't mach?
  2. Are you only looking at real environment variables or also at resolved .env variables?

/**
* Helper to get the project's root directory.
*/
protected function getProjectDir(): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually do it like this:

$kernel = $I->grabService('kernel');
$kernel->getContainer()->getParameter('foobar');

Is this just a shortcut? I'm asking cause if there's a shortcut for this one parameter, I always ask myself: What about all the others?

@@ -147,6 +152,100 @@ public function seeUserPasswordDoesNotNeedRehash(?UserInterface $user = null): v
$this->assertFalse($hasher->needsRehash($userToValidate), 'User password needs rehash.');
}

/**
* Asserts that a security firewall is configured and active.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Active" in the sense that it was actually used for the current request? Or just generally up and running?

@ThomasLandauer
Copy link
Member

Well, these are many... :-)

  1. Do you have a clear picture when Codeception usually uses see vs. assert? Or at least clearer than me? ;-)
  2. Is there a reason why you're putting those Doctrine assertions in the Symfony and not in the Doctrine module?
  3. For some assertions I don't get the idea, since the outcome usually differs between TEST and PROD environment, e.g. seeDoctrineDatabaseIsUp(), seeDebugModeEnabled(). What's your reasoning here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants