Closed williamespindola closed 8 years ago
Silex min dependency is 5.3.3 - https://github.com/silexphp/Silex/blob/1.0/composer.json#L18
So, any errors on 5.2 won't be fixed.
Hi @ragboyjr the versions is about PHPUnit not PHP ;)
Ha! No problem man!
Can you paste a code example?
Yep!
use Silex\Application;
class MyClassTest extends \PHPUnit_Framework_TestCase
{
public function testMyMethod()
{
$appMock = $this->getMock('Silex\Application');
}
}
PHPUnit 5.3
PHPUnit 5.3.2 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.19
Configuration: .../phpunit.xml
W 1 / 1 (100%)
Time: 49 ms, Memory: 4.25Mb
There was 1 warning:
1) ...\Test\Provider\MyClassTest::testMyMethod
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
PHPUnit 5.2
PHPUnit 5.2.12 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.19
Configuration: .../phpunit.xml
E 1 / 1 (100%)
Time: 50 ms, Memory: 4.25Mb
There was 1 error:
1) ...\Test\Provider\MyClassTest::testMyMethod
PHPUnit_Framework_MockObject_BadMethodCallException:
.../vendor/silex/silex/src/Silex/Application.php:72
.../tests/Provider/RouteServiceProviderTest.php:12
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
https://phpunit.de/manual/current/en/test-doubles.html. Read the big blue section about limitations.
I just did some checking and testing of my own. I don't think you'll be able to because of lines like this: https://github.com/silexphp/Silex/blob/1.0/src/Silex/Application.php#L73. It calls static methods in silex 1.0 and phpunit can't mock static methods.
You either can just instantiate the Application, or maybe use a different mocking framework like Phake or Phony
For now I will try with Phony. Exists some intention to improve silex to work with Pimple 3.0? May be with this upgrade this problem can be solved.
There's no way to make Silex v1 compatible with Pimple v2+. But Silex v2 will use Pimple v3.
I'm trying to mock
Silex\Application
class but the PHPUnit returns the following error:PHPUnit_Framework_MockObject_BadMethodCallException
until 5.2 version, and Warnings from 5.3. This occur because of static methods on Pimple at Lines L116 and L142. I saw that exists new versions of Pimple and has not static methods, but Silex still using 1.0