Skip to content

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 17, 2019
1 parent 011284c commit 0c0cb62
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public function generateClassFromWsdl($wsdlFile, $className, array $methods = []
$methodsBuffer = '';

foreach ($_methods as $method) {
\preg_match_all("/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\(/", $method, $matches, \PREG_OFFSET_CAPTURE);
\preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\(/', $method, $matches, \PREG_OFFSET_CAPTURE);
$lastFunction = \array_pop($matches[0]);
$nameStart = $lastFunction[1];
$nameEnd = $nameStart + \strlen($lastFunction[0]) - 1;
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions tests/end-to-end/mock-objects/generator/3530.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
\PHPUnit\Framework\MockObject\Generator::generateClassFromWsdl('3530.wsdl', 'Test')
--SKIPIF--
<?php declare(strict_types=1);
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
--FILE--
<?php declare(strict_types=1);
require __DIR__ . '/../../../../vendor/autoload.php';

$generator = new \PHPUnit\Framework\MockObject\Generator;

print $generator->generateClassFromWsdl(
__DIR__ . '/../../../_files/3530.wsdl',
'Test'
);
--EXPECTF--
class Test extends \SoapClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/3530.wsdl', $options);
}

public function Contact_Information($Contact_Id)
{
}
}
23 changes: 0 additions & 23 deletions tests/unit/Framework/MockObject/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,4 @@ public function testVariadicArgumentsArePassedToMockedMethod()

$mock->foo(...$arguments);
}

public function testGenerateClassFromWsdlForMultipleOutputValues()
{
$wsdlPath = TEST_FILES_PATH . '3530.xml';
$generator = new Generator();
$result = $generator->generateClassFromWsdl($wsdlPath, 'Test');

$expected = <<<EOM
class Test extends \SoapClient
{
public function __construct(\$wsdl, array \$options)
{
parent::__construct('$wsdlPath', \$options);
}
public function Contact_Information(\$Contact_Id)
{
}
}
EOM;
$this->assertEquals($expected, $result);
}
}

0 comments on commit 0c0cb62

Please sign in to comment.