Skip to content
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

Fix tests and remove tests not testing anything. #40

Merged
merged 5 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

sudo: false

Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.0.0] - 2021-05-20
### Fixed
* [#13](https://github.com/drupal-composer/info-rewrite/pull/13): Fix tests.
* [#15](https://github.com/drupal-composer/info-rewrite/pull/15): End info files with EOL character.
* [#16](https://github.com/drupal-composer/info-rewrite/pull/16): Set core and package info.
* [#19](https://github.com/drupal-composer/info-rewrite/pull/19): Don't run rollback on missing info files.
* [#22](https://github.com/drupal-composer/info-rewrite/pull/22): Add core key only if missing core_version_requirement

### Added
* [#17](https://github.com/drupal-composer/info-rewrite/pull/17): Additional package types.

### Changed
* [#24](https://github.com/drupal-composer/info-rewrite/pull/24): Adjusted "Information added by line" for clarity.

## [1.0.0 beta1] - 2018-03-01
### Fixed
* [#7](https://github.com/drupal-composer/info-rewrite/pull/7): Fatal error when no `.info` files exist.
* [#10](https://github.com/drupal-composer/info-rewrite/pull/10): Drupal core had 4-digit version string.

[Unreleased]: https://github.com/drupal-composer/info-rewrite/compare/1.0.0-beta1...HEAD
[Unreleased]: https://github.com/drupal-composer/info-rewrite/compare/1.0.0...HEAD
[1.0.0]: https://github.com/drupal-composer/info-rewrite/compare/1.0.0-beta1...1.0.0
[1.0.0 beta1]: https://github.com/drupal-composer/info-rewrite/compare/1.0.0-alpha1...1.0.0-beta1
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
},
"require-dev": {
"composer/composer": "~1.0",
"jakub-onderka/php-parallel-lint": "~0.8",
"php-parallel-lint/php-parallel-lint": "^1.3",
"mikey179/vfsstream": "~1.2",
"phpunit/phpunit": "~5.6",
"squizlabs/php_codesniffer": "~2.0"
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.0",
"phpspec/prophecy-phpunit": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 0 additions & 3 deletions src/DrupalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ public function activate(Composer $composer, IOInterface $io)
*/
public function deactivate(Composer $composer, IOInterface $io)
{

}

/**
* {@inheritdoc}
*/
public function uninstall(Composer $composer, IOInterface $io)
{

}

/**
Expand Down Expand Up @@ -329,5 +327,4 @@ protected function getPackageFromOperation(OperationInterface $operation)
}
return $package;
}

}
43 changes: 9 additions & 34 deletions tests/DrupalInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use DrupalComposer\Composer\DrupalInfo;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \DrupalComposer\Composer\DrupalInfo
*/
class DrupalInfoTest extends \PHPUnit_Framework_TestCase
class DrupalInfoTest extends TestCase
{
use InfoFileTrait;
use ProphecyTrait;

/**
* @var Composer
Expand All @@ -42,7 +45,7 @@ class DrupalInfoTest extends \PHPUnit_Framework_TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand Down Expand Up @@ -120,27 +123,13 @@ public function testInstallOperationWriteInfoFiles()

foreach ($files as $file) {
$this->assertFileExists($file);
$this->assertContains($info, file_get_contents($file));
$this->assertStringContainsString($info, file_get_contents($file));
}

// Verify that module with existing version information is not updated.
$file = $this->getDirectory() . '/module_with_version/module_with_version.info.yml';
$this->assertFileExists($file);
$this->assertNotContains($info, file_get_contents($file));
}

/**
* @covers ::writeInfoFiles
*/
public function testUpdateOperationWriteInfoFiles()
{
$event = $this->prophesize(PackageEvent::class);
$operation = $this->prophesize(UpdateOperation::class);
$package = $this->prophesize(PackageInterface::class);
$package->getType()->willReturn('drupal-fo');
$operation->getTargetPackage()->willReturn($package->reveal());
$event->getOperation()->willReturn($operation->reveal());
$this->fixture->writeInfoFiles($event->reveal());
$this->assertStringNotContainsString($info, file_get_contents($file));
}

/**
Expand Down Expand Up @@ -186,20 +175,6 @@ public function testNoInfoFile()
$this->fixture->writeInfoFiles($event->reveal());
}

/**
* @covers ::writeInfoFiles
*/
public function testIgnoredPackageType()
{
$event = $this->prophesize(PackageEvent::class);
$operation = $this->prophesize(InstallOperation::class);
$package = $this->prophesize(PackageInterface::class);
$package->getType()->willReturn('drupal-fo');
$operation->getPackage()->willReturn($package->reveal());
$event->getOperation()->willReturn($operation->reveal());
$this->fixture->writeInfoFiles($event->reveal());
}

/**
* @covers ::rollbackRewrite
*/
Expand All @@ -224,7 +199,7 @@ public function testRollbackRewrite()
$handle = fopen($file, 'a');
fwrite($handle, $info_pattern);
fclose($handle);
$this->assertContains($info_pattern, file_get_contents($file));
$this->assertStringContainsString($info_pattern, file_get_contents($file));
}

$package = $this->prophesize(PackageInterface::class);
Expand Down Expand Up @@ -259,7 +234,7 @@ public function testRollbackRewrite()
// Verify that 3 .info files are updated.
foreach ($files as $file) {
$contents = file_get_contents($file);
$this->assertNotContains($info_pattern, $contents);
$this->assertStringNotContainsString($info_pattern, $contents);
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Writer/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
use DrupalComposer\Composer\Writer\Drupal;
use DrupalComposer\Composer\Writer\Drupal7;
use DrupalComposer\Composer\Writer\Factory;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \DrupalComposer\Composer\Writer\Factory
*/
class FactoryTest extends \PHPUnit_Framework_TestCase
class FactoryTest extends TestCase
{
use InfoFileTrait;

Expand Down