Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PhpUnitBridge] Mock DNS functions #18181

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
Mar 16, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #16819
License MIT
Doc PR -

@natechicago
Copy link
Contributor

Thanks for this, @nicolas-grekas !

{
return isset(self::$resolutions[$type][$host])
? self::$resolutions[$type][$host]
: \checkdnsrr($host, $type);
Copy link
Member

Choose a reason for hiding this comment

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

should be on one line :)

@nicolas-grekas nicolas-grekas force-pushed the mock-checkdnsrr branch 3 times, most recently from 9f5b856 to d21746c Compare March 16, 2016 10:15
@nicolas-grekas nicolas-grekas changed the title [PhpUnitBridge] Mock checkdnsrr() [PhpUnitBridge] Mock DNS functions Mar 16, 2016
@nicolas-grekas
Copy link
Member Author

This PR now has mocks for all DNS functions, and unit tests.
Ready for merge.

"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
"Symfony\\Bridge\\": "src/Symfony/Bridge/",
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason we didn't have this before?

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted

@nicolas-grekas nicolas-grekas force-pushed the mock-checkdnsrr branch 2 times, most recently from 0a79ba1 to 7a8b925 Compare March 16, 2016 11:08

use Symfony\Bridge\PhpUnit\DnsMock;

require_once __DIR__.'/../DnsMock.php';
Copy link
Member Author

Choose a reason for hiding this comment

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

this is temporary until our phpunit wrapper is updated (PR coming on 2.3 after merge)

@nicolas-grekas nicolas-grekas force-pushed the mock-checkdnsrr branch 5 times, most recently from 84455f4 to 1a8bb65 Compare March 16, 2016 12:44
@@ -26,13 +26,18 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
private $wasSkipped = array();
private $isSkipped = array();

public function __construct(array $extraClockMockedNamespaces = array())
public function __construct(array $extraClockMockedNamespaces = array(), array $extraDnsMockedNamespaces = array())
Copy link
Member

Choose a reason for hiding this comment

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

That does not scale well. I think we need to think about another way to inject those mocked configs.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@nicolas-grekas nicolas-grekas force-pushed the mock-checkdnsrr branch 2 times, most recently from 98e58fa to 4619210 Compare March 16, 2016 13:05
@@ -26,11 +26,25 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
private $wasSkipped = array();
private $isSkipped = array();

public function __construct(array $extraClockMockedNamespaces = array())
public function __construct(array $mockedNamespaces = array())
Copy link
Member

Choose a reason for hiding this comment

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

I think we should now document which keys (groups) are supported by the listener.

Copy link
Member Author

Choose a reason for hiding this comment

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

documented, ok for you ?

Copy link
Member

Choose a reason for hiding this comment

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

looks good

@fabpot
Copy link
Member

fabpot commented Mar 16, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 0b31285 into symfony:master Mar 16, 2016
fabpot added a commit that referenced this pull request Mar 16, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[PhpUnitBridge] Mock DNS functions

| Q             | A
| ------------- | ---
| Branch        | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16819
| License       | MIT
| Doc PR        | -

Commits
-------

0b31285 [PhpUnitBridge] Mock DNS functions
@nicolas-grekas nicolas-grekas deleted the mock-checkdnsrr branch March 16, 2016 15:06
}
}
if (self::$globallyEnabled) {
$this->state = -2;
} else {
self::$globallyEnabled = true;
if ($warn) {
echo "Clock-mocked namespaces for SymfonyTestsListener need to be nested in a \"time-sensitive\" key. This will be enforced in Symfony 4.0.\n";
Copy link
Member

Choose a reason for hiding this comment

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

writing this to stderr would be better than in stdout

Copy link
Member Author

Choose a reason for hiding this comment

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

but did not work when I tried so I resorted to stdout, which is where phpunit and this listener echo in other cases...

@fabpot fabpot mentioned this pull request May 13, 2016
fabpot added a commit that referenced this pull request May 21, 2017
This PR was merged into the 3.2 branch.

Discussion
----------

[PhpUnitBridge] add a changelog file

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18181
| License       | MIT
| Doc PR        |

Commits
-------

e5455db [PhpUnitBridge] add a changelog file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants