1
0
Fork 0

fix risky tests (without any assertion)

pull/8581/head
Ion Bazan 2020-02-07 14:35:07 +08:00
parent db32d6bc18
commit 58b34d13e8
11 changed files with 33 additions and 16 deletions

View File

@ -222,6 +222,7 @@ class ConfigTest extends TestCase
/** /**
* @dataProvider allowedUrlProvider * @dataProvider allowedUrlProvider
* @doesNotPerformAssertions
* *
* @param string $url * @param string $url
*/ */

View File

@ -153,7 +153,7 @@ class FossilDownloaderTest extends TestCase
->method('execute') ->method('execute')
->with($this->equalTo($expectedResetCommand)); ->with($this->equalTo($expectedResetCommand));
$filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->once())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -712,7 +712,7 @@ composer https://github.com/old/url (push)
->with($this->equalTo($expectedGitResetCommand)) ->with($this->equalTo($expectedGitResetCommand))
->will($this->returnValue(0)); ->will($this->returnValue(0));
$filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->once())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -142,7 +142,7 @@ class HgDownloaderTest extends TestCase
->method('execute') ->method('execute')
->with($this->equalTo($expectedResetCommand)); ->with($this->equalTo($expectedResetCommand));
$filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->once())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -103,6 +103,9 @@ class PerforceDownloaderTest extends TestCase
return $repository; return $repository;
} }
/**
* @doesNotPerformAssertions
*/
public function testInitPerforceInstantiatesANewPerforceObject() public function testInitPerforceInstantiatesANewPerforceObject()
{ {
$this->downloader->initPerforce($this->package, $this->testPath, 'SOURCE_REF'); $this->downloader->initPerforce($this->package, $this->testPath, 'SOURCE_REF');

View File

@ -17,6 +17,9 @@ use Composer\Test\TestCase;
class BasePackageTest extends TestCase class BasePackageTest extends TestCase
{ {
/**
* @doesNotPerformAssertions
*/
public function testSetSameRepository() public function testSetSameRepository()
{ {
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo')); $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));

View File

@ -83,7 +83,7 @@ class ArrayLoaderTest extends TestCase
$this->assertEquals('1.2.3.4', $package->getVersion()); $this->assertEquals('1.2.3.4', $package->getVersion());
} }
public function testParseDumpProvider() public function parseDumpProvider()
{ {
$validConfig = array( $validConfig = array(
'name' => 'A/B', 'name' => 'A/B',
@ -142,7 +142,7 @@ class ArrayLoaderTest extends TestCase
* The default parser should default to loading the config as this * The default parser should default to loading the config as this
* allows require-dev libraries to have transport options included. * allows require-dev libraries to have transport options included.
* *
* @dataProvider testParseDumpProvider * @dataProvider parseDumpProvider
*/ */
public function testParseDumpDefaultLoadConfig($config) public function testParseDumpDefaultLoadConfig($config)
{ {
@ -153,7 +153,7 @@ class ArrayLoaderTest extends TestCase
} }
/** /**
* @dataProvider testParseDumpProvider * @dataProvider parseDumpProvider
*/ */
public function testParseDumpTrueLoadConfig($config) public function testParseDumpTrueLoadConfig($config)
{ {
@ -165,7 +165,7 @@ class ArrayLoaderTest extends TestCase
} }
/** /**
* @dataProvider testParseDumpProvider * @dataProvider parseDumpProvider
*/ */
public function testParseDumpFalseLoadConfig($config) public function testParseDumpFalseLoadConfig($config)
{ {

View File

@ -62,8 +62,10 @@ class ChannelReaderTest extends TestCase
$reader = new \Composer\Repository\Pear\ChannelReader($rfs); $reader = new \Composer\Repository\Pear\ChannelReader($rfs);
$reader->read('http://pear.1.0.net/'); $pear10 = $reader->read('http://pear.1.0.net/');
$reader->read('http://pear.1.1.net/'); $this->assertCount(2, $pear10->getPackages());
$pear11 = $reader->read('http://pear.1.1.net/');
$this->assertCount(3, $pear11->getPackages());
} }
public function testShouldCreatePackages() public function testShouldCreatePackages()

View File

@ -84,7 +84,7 @@ class RepositoryManagerTest extends TestCase
$rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository'); $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
$rm->createRepository('composer', array('url' => 'http://example.org')); $rm->createRepository('composer', array('url' => 'http://example.org'));
$rm->createRepository($type, $options); $this->assertInstanceOf('Composer\Repository\RepositoryInterface', $rm->createRepository($type, $options));
} }
public function creationCases() public function creationCases()

View File

@ -20,6 +20,16 @@ use Composer\Test\TestCase;
*/ */
class ErrorHandlerTest extends TestCase class ErrorHandlerTest extends TestCase
{ {
public function setUp()
{
ErrorHandler::register();
}
public function tearDown()
{
restore_error_handler();
}
/** /**
* Test ErrorHandler handles notices * Test ErrorHandler handles notices
*/ */
@ -27,8 +37,6 @@ class ErrorHandlerTest extends TestCase
{ {
$this->setExpectedException('\ErrorException', 'Undefined index: baz'); $this->setExpectedException('\ErrorException', 'Undefined index: baz');
ErrorHandler::register();
$array = array('foo' => 'bar'); $array = array('foo' => 'bar');
$array['baz']; $array['baz'];
} }
@ -40,18 +48,15 @@ class ErrorHandlerTest extends TestCase
{ {
$this->setExpectedException('\ErrorException', 'array_merge'); $this->setExpectedException('\ErrorException', 'array_merge');
ErrorHandler::register();
array_merge(array(), 'string'); array_merge(array(), 'string');
} }
/** /**
* Test ErrorHandler handles warnings * Test ErrorHandler handles warnings
* @doesNotPerformAssertions
*/ */
public function testErrorHandlerRespectsAtOperator() public function testErrorHandlerRespectsAtOperator()
{ {
ErrorHandler::register();
@trigger_error('test', E_USER_NOTICE); @trigger_error('test', E_USER_NOTICE);
} }
} }

View File

@ -102,6 +102,7 @@ class GitTest extends TestCase
$this->mockConfig($protocol); $this->mockConfig($protocol);
$this->process $this->process
->expects($this->atLeast(2))
->method('execute') ->method('execute')
->willReturnMap(array( ->willReturnMap(array(
array('git command failing', null, null, 1), array('git command failing', null, null, 1),
@ -113,11 +114,13 @@ class GitTest extends TestCase
->willReturn(false); ->willReturn(false);
$this->io $this->io
->expects($this->atLeastOnce())
->method('hasAuthentication') ->method('hasAuthentication')
->with($this->equalTo('github.com')) ->with($this->equalTo('github.com'))
->willReturn(true); ->willReturn(true);
$this->io $this->io
->expects($this->atLeastOnce())
->method('getAuthentication') ->method('getAuthentication')
->with($this->equalTo('github.com')) ->with($this->equalTo('github.com'))
->willReturn(array('username' => 'token', 'password' => $gitHubToken)); ->willReturn(array('username' => 'token', 'password' => $gitHubToken));