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

PhpBrowser uses wrong port when redirects disabled and base url is identical #4383

Closed
frantzen opened this Issue Jul 4, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@frantzen
Contributor

frantzen commented Jul 4, 2017

What are you trying to achieve?

I access with PhpBrowser the same page, but with two different ports. I disable redirects.

What do you get instead?

For the second call, the port of the first call is used, not the port of the second call.

The code below should first do a call on port 8110, and then on port 8112. But it does the second call also on port 8110 (even though the debug output claims it is 8112).

If between the two calls I do a:

getModule('PhpBrowser')->_initialize();

Then the correct port is used for the second call.

Provide test source code if related

$I->setRedirects(false);
// this does a:     getModule('PhpBrowser')->client->followRedirects(false);
$I->amOnUrl('http://bla.com:8110');
$I->seeResponseCodeIs(301);
$I->amOnUrl('http://bla.com:8112');
$I->seeResponseCodeIs(200);

Wild guess: the issue seems to be in the getAbsoluteUri method of the Guzzle6.php. For the second call it returns the Uri of the history (line 172), which is wrong, since that one has the old port.

Details

  • Codeception version: 2.3.3

  • PHP Version: 7.0.9

  • Operating System: Linux

  • Installation type: Composer

  • List of installed packages (composer show)
    behat/behat v3.3.0 Scenario-oriented BDD framework for PHP 5.3
    behat/gherkin v4.4.5 Gherkin DSL parser for PHP 5.3
    behat/transliterator v1.2.0 String transliterator
    codeception/c3 2.0.12 CodeCoverage collector for Codeception
    codeception/codeception 2.3.3 BDD-style testing framework
    consolidation/annotated-command 2.4.8 Initialize Symfony Console commands from annotated command class methods.
    consolidation/config 1.0.0 Provide configuration services for a commandline tool.
    consolidation/log 1.0.3 Improved Psr-3 / Psr\Log logger based on Symfony Console components.
    consolidation/output-formatters 3.1.10 Format text by applying transformations provided by plug-in formatters.
    consolidation/robo 1.1.0 Modern task runner
    container-interop/container-interop 1.2.0 Promoting the interoperability of container objects (DIC, SL, etc.)
    dflydev/dot-access-data v1.1.0 Given a deep data structure, access data by dot notation.
    doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invok...
    facebook/webdriver 1.4.1 A PHP client for Selenium WebDriver
    grasmash/yaml-expander 1.1.0 Expands internal property references in a yaml file.
    guzzlehttp/guzzle 6.3.0 Guzzle is a PHP HTTP client library
    guzzlehttp/promises v1.3.1 Guzzle promises library
    guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods
    league/container 2.4.1 A fast and intuitive dependency injection container.
    monolog/monolog 1.23.0 Sends your logs to files, sockets, inboxes, databases and various web se...
    myclabs/deep-copy 1.6.1 Create deep copies (clones) of your objects
    pdepend/pdepend 2.5.0 Official version of pdepend to be handled with Composer
    phing/phing 2.16.0 PHing Is Not GNU make; it's a PHP project build system or build tool bas...
    phpdocumentor/reflection-common 1.0 Common reflection classes used by phpdocumentor to reflect the code stru...
    phpdocumentor/reflection-docblock 3.1.1 With this component, a library can provide support for annotations via D...
    phpdocumentor/type-resolver 0.2.1
    phpmd/phpmd 2.6.0 PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalen...
    phpspec/prophecy v1.7.0 Highly opinionated mocking framework for PHP 5.3+
    phpunit/php-code-coverage 4.0.8 Library that provides collection, processing, and rendering functionalit...
    phpunit/php-file-iterator 1.4.2 FilterIterator implementation that filters files based on a list of suff...
    phpunit/php-text-template 1.2.1 Simple template engine.
    phpunit/php-timer 1.0.9 Utility class for timing
    phpunit/php-token-stream 1.4.11 Wrapper around PHP's tokenizer extension.
    phpunit/phpunit 5.7.21 The PHP Unit Testing framework.
    phpunit/phpunit-mock-objects 3.4.3 Mock Object library for PHPUnit
    psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11)
    psr/http-message 1.0.1 Common interface for HTTP messages
    psr/log 1.0.2 Common interface for logging libraries
    sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
    sebastian/comparator 1.2.4 Provides the functionality to compare PHP values for equality
    sebastian/diff 1.4.3 Diff implementation
    sebastian/environment 2.0.0 Provides functionality to handle HHVM/PHP environments
    sebastian/exporter 2.0.0 Provides the functionality to export PHP variables for visualization
    sebastian/finder-facade 1.2.1 FinderFacade is a convenience wrapper for Symfony's Finder component.
    sebastian/global-state 1.1.1 Snapshotting of global state
    sebastian/object-enumerator 2.0.1 Traverses array structures and object graphs to enumerate all referenced...
    sebastian/phpcpd 3.0.0 Copy/Paste Detector (CPD) for PHP code.
    sebastian/recursion-context 2.0.0 Provides functionality to recursively process PHP variables
    sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
    sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP pr...
    squizlabs/php_codesniffer 2.9.1 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects viol...
    stecman/symfony-console-completion 0.7.0 Automatic BASH completion for Symfony Console Component based applications.
    symfony/browser-kit v3.3.2 Symfony BrowserKit Component
    symfony/class-loader v3.3.2 Symfony ClassLoader Component
    symfony/config v3.3.2 Symfony Config Component
    symfony/console v3.3.2 Symfony Console Component
    symfony/css-selector v3.3.2 Symfony CssSelector Component
    symfony/debug v3.3.2 Symfony Debug Component
    symfony/dependency-injection v3.3.2 Symfony DependencyInjection Component
    symfony/dom-crawler v3.3.2 Symfony DomCrawler Component
    symfony/event-dispatcher v3.3.2 Symfony EventDispatcher Component
    symfony/filesystem v3.3.2 Symfony Filesystem Component
    symfony/finder v3.3.2 Symfony Finder Component
    symfony/polyfill-mbstring v1.4.0 Symfony polyfill for the Mbstring extension
    symfony/process v3.3.2 Symfony Process Component
    symfony/translation v3.3.2 Symfony Translation Component
    symfony/yaml v3.3.2 Symfony Yaml Component
    theseer/fdomdocument 1.6.6 The classes contained within this repository extend the standard DOM to ...
    webmozart/assert 1.2.0 Assertions to validate method input/output with nice error messages.

  • Suite configuration:

actor: Sandbox2Tester
modules:
    enabled:
        - \Helper\Sandbox2
        - \Helper\OverallHelper
        - PhpBrowser:
            url: 'foo'
@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Jul 11, 2017

Member

Your bug report is way overcomplicated, this issue happens because the second url has an empty path component.

I simplified testcase to

        $I->amOnUrl('https://www.example.com');
        $I->see('Example Domain');
        $I->amOnUrl('http://www.codeception.com');
        $I->dontSee('Example Domain');

Appending / to second URL makes it work as expected.

Member

Naktibalda commented Jul 11, 2017

Your bug report is way overcomplicated, this issue happens because the second url has an empty path component.

I simplified testcase to

        $I->amOnUrl('https://www.example.com');
        $I->see('Example Domain');
        $I->amOnUrl('http://www.codeception.com');
        $I->dontSee('Example Domain');

Appending / to second URL makes it work as expected.

@frantzen

This comment has been minimized.

Show comment
Hide comment
@frantzen

frantzen Jul 17, 2017

Contributor

Thanks @Naktibalda for your analysis!

Contributor

frantzen commented Jul 17, 2017

Thanks @Naktibalda for your analysis!

@DavertMik DavertMik closed this in #4393 Jul 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment