Ich benutze die Travis-Ci, um meine Tests zu laufen. In meinem lokalen Computer überprüfte ich die zwei PHP-Version, und es ist gut. Aber in Travis sind die Tests unter 5.6 PHP-Version gescheitert. Aber Tests werden in PHP 7.0 Version übergeben. Ich weiß nicht, was das eigentliche Problem ist.PHPUnit vergleichen XML-String mit XML-Datei in PHP 5,6 fehlgeschlagen, aber übergeben in PHP 7,0
$client = static::createClient();
$crawler = $client->request('GET', '/sitemap.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertXmlStringEqualsXmlFile(
__DIR__ . '/../Resources/sample.xml',
$client->getResponse()->getContent()
);
Ich habe eine sample.xml, die die korrekte XML-Struktur mit Werten enthält. Ich generiere die sitemap.xml über den Link /sitemap.xml.
Ich bekomme immer Fehler: Die beiden DOM ist nicht gleich.
PHPUnit Version ist 5.1.3 auf meinem Computer.
Hier die Log-Datei von Travis-ci:
$ php --version
PHP 5.6.5 (cli) (built: Feb 12 2015 01:41:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
$ composer --version
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Composer version 1.2-dev (32a8a60695b9b9c9e2da01406ac3713903182669) 2016-05-17 13:08:17
before_install.1
0.00s$ if [[ ! $PHP = ${MIN_PHP%.*} && $TRAVIS_PULL_REQUEST != false ]]; then skip=1; fi
before_install.2
2.11s$ composer self-update --stable;
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Updating to version 1.1.1 (stable channel).
Downloading: Connecting... Downloading: 100%
Use composer self-update --rollback to return to version 32a8a60695b9b9c9e2da01406ac3713903182669
before_install.3
0.00s$ if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony:${SYMFONY_VERSION}; fi
install
60.18s$ if [ ! $skip ]; then composer update --prefer-dist; fi
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing psr/log (1.0.0)
Loading from cache
- Installing doctrine/lexer (v1.0.1)
Loading from cache
- Installing doctrine/annotations (v1.2.7)
Loading from cache
- Installing doctrine/collections (v1.3.0)
Loading from cache
- Installing doctrine/cache (v1.6.0)
Loading from cache
- Installing doctrine/inflector (v1.1.0)
Loading from cache
- Installing doctrine/common (v2.6.1)
Loading from cache
- Installing symfony/polyfill-util (v1.1.1)
Loading from cache
- Installing paragonie/random_compat (v1.4.1)
Loading from cache
- Installing symfony/polyfill-php70 (v1.1.1)
Loading from cache
- Installing symfony/polyfill-php56 (v1.1.1)
Loading from cache
- Installing symfony/polyfill-mbstring (v1.1.1)
Loading from cache
- Installing symfony/symfony (v3.0.6)
Loading from cache
- Installing symfony/polyfill-intl-icu (v1.1.1)
Loading from cache
- Installing twig/twig (v1.24.0)
Loading from cache
- Installing sensio/framework-extra-bundle (v3.0.16)
Loading from cache
- Installing doctrine/instantiator (1.0.5)
Loading from cache
- Installing doctrine/dbal (v2.5.4)
Loading from cache
- Installing doctrine/orm (v2.5.4)
Loading from cache
- Installing doctrine/doctrine-cache-bundle (1.3.0)
Loading from cache
- Installing jdorn/sql-formatter (v1.2.17)
Loading from cache
- Installing doctrine/doctrine-bundle (1.6.2)
Loading from cache
- Installing myclabs/deep-copy (1.5.1)
Loading from cache
- Installing sebastian/version (1.0.6)
Loading from cache
- Installing sebastian/resource-operations (1.0.0)
Loading from cache
- Installing sebastian/global-state (1.1.1)
Loading from cache
- Installing sebastian/recursion-context (1.0.2)
Loading from cache
- Installing sebastian/exporter (1.2.1)
Loading from cache
- Installing sebastian/environment (1.3.7)
Loading from cache
- Installing sebastian/diff (1.4.1)
Loading from cache
- Installing sebastian/comparator (1.2.0)
Loading from cache
- Installing phpdocumentor/reflection-docblock (2.0.4)
Loading from cache
- Installing phpspec/prophecy (v1.6.0)
Loading from cache
- Installing phpunit/php-text-template (1.2.1)
Loading from cache
- Installing phpunit/phpunit-mock-objects (3.1.3)
Loading from cache
- Installing phpunit/php-timer (1.0.8)
Loading from cache
- Installing sebastian/code-unit-reverse-lookup (1.0.0)
Loading from cache
- Installing phpunit/php-token-stream (1.4.8)
Loading from cache
- Installing phpunit/php-file-iterator (1.4.1)
Loading from cache
- Installing phpunit/php-code-coverage (3.3.1)
Loading from cache
- Installing phpunit/phpunit (5.1.7)
Loading from cache
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
sensio/framework-extra-bundle suggests installing symfony/psr-http-message-bridge (To use the PSR-7 converters)
doctrine/doctrine-cache-bundle suggests installing symfony/security-acl (For using this bundle to cache ACLs)
sebastian/global-state suggests installing ext-uopz (*)
phpdocumentor/reflection-docblock suggests installing dflydev/markdown (~1.0)
phpdocumentor/reflection-docblock suggests installing erusev/parsedown (~1.0)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Generating autoload files
1.10s$ phpunit Tests/;
PHPUnit 5.1.7 by Sebastian Bergmann and contributors.
F.... 5/5 (100%)
Time: 973 ms, Memory: 28.25MB
There was 1 failure:
1) RepoSitemapBundle\Tests\Controller\DefaultControllerTest::testSitemapAction
Failed asserting that two DOM documents are equal.
--- Expected
+++ Actual
@@ @@
<?xml version="1.0"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">
- <url>
- <loc>http://www.localhosttest/1</loc>
- <lastmod>2010-01-01</lastmod>
- <changefreq>daily</changefreq>
- <priority>0.9</priority>
- </url>
-</urlset>
+ <url>
+ <loc>http://www.localhosttest/1</loc>
+ <lastmod>2010-01-01</lastmod>
+ <changefreq>daily</changefreq>
+ <priority>0.9</priority>
+ </url>
+ </urlset>
/home/travis/build/botalaszlo/tmp-sitemap-bundle/Tests/Controller/DefaultControllerTest.php:37
phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:152
phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:104
FAILURES!
Tests: 5, Assertions: 10, Failures: 1.
The command "phpunit Tests/;" exited with 1.
Aber in PHP 7.0 dies nicht ausgefallen ist. Ich habe versucht, mit SimpleXml die Datei sample.xml zu laden, aber ich hatte das gleiche Problem.
Short Lösung läuft nicht Tests in PHP 5.6
Vielen Dank, aber wenn ich das DomDocument verwende, dann whitespaces = false beibehalten, hat auch nicht funktioniert. Ich habe keine Ahnung. Es ist sehr schwierig. – Dabagab
Sie müssen wirklich die xml genau umrissen werden. Keine zusätzlichen Leerzeichen oder Tabulatoren –