Skip to content

Commit

Permalink
fix: deprecated test warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
  • Loading branch information
malukenho committed Jul 3, 2024
1 parent a197c17 commit 5142eec
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
composer.lock
.phpunit.cache
30 changes: 16 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
colors="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
columns="max"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory=".phpunit.cache"
>
<testsuite name="Kawaii gherkin tests">
<directory>./tests</directory>
</testsuite>
<testsuite name="Kawaii gherkin functional tests">
<directory suffix=".phpt">./tests/functional</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="Kawaii gherkin tests">
<directory>./tests</directory>
</testsuite>
<testsuite name="Kawaii gherkin functional tests">
<directory suffix=".phpt">./tests/functional</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
12 changes: 3 additions & 9 deletions tests/Command/CheckGherkinCodeStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,17 @@
use Behat\Gherkin\Node\TableNode;
use Behat\Gherkin\Parser;
use KawaiiGherkin\Command\CheckGherkinCodeStyle;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;

/**
* Tests for {@see \KawaiiGherkin\Command\CheckGherkinCodeStyle}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Command\CheckGherkinCodeStyle
* @group Coverage
* @license MIT
*/
#[CoversClass(CheckGherkinCodeStyle::class)]
final class CheckGherkinCodeStyleTest extends TestCase
{
public function testShouldReturnOkIfThereIsNoFilesFound()
{
/* @var \Behat\Gherkin\Parser|\PHPUnit_Framework_MockObject_MockObject $parser */
/* @var \Behat\Gherkin\Parser|\PHPUnit\Framework\MockObject\MockObject $parser */
$parser = $this->getMockBuilder(Parser::class)
->disableOriginalConstructor()
->getMock();
Expand Down
21 changes: 9 additions & 12 deletions tests/FeatureResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
namespace KawaiiGherkinTest;

use KawaiiGherkin\FeatureResolve;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

final class FeatureResolveTest extends TestCase
{
/**
* @dataProvider unExistsDirectory
*
* @param string $directory
* @param string $expectedDirectory
* @param string $expectedFile
*/
public function testShouldReturnCorrectDirectory(
$directory,
$expectedDirectory,
$expectedFile
) {
#[Test]
#[DataProvider('unExistsDirectory')]
public function itShouldReturnCorrectDirectory(
string $directory,
string $expectedDirectory,
string $expectedFile
): void {
$feature = new FeatureResolve($directory);

self::assertObjectHasProperty('directoryOrFile', $feature);
Expand Down
19 changes: 6 additions & 13 deletions tests/Formatter/BackgroundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,15 @@
use Behat\Gherkin\Node\StepNode;
use Behat\Gherkin\Node\TableNode;
use KawaiiGherkin\Formatter\Background;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

/**
* Tests for {@see \KawaiiGherkin\Formatter\Background}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\Background
* @group Coverage
* @license MIT
*/
#[CoversClass(Background::class)]
final class BackgroundTest extends TestCase
{
/**
* @var Background
*/
private $formatter;
private Background $formatter;

/**
* {@inheritDoc}
Expand All @@ -48,7 +40,8 @@ public function setUp(): void
$this->formatter = new Background();
}

public function testCanFormatFeatureDescription()
#[Test]
public function canFormatFeatureDescription(): void
{
$expected = <<<EOS
Background: Turning people kawaii
Expand Down
25 changes: 8 additions & 17 deletions tests/Formatter/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,22 @@
use Behat\Gherkin\Node\ExampleTableNode;
use Behat\Gherkin\Node\OutlineNode;
use KawaiiGherkin\Formatter\Example;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \KawaiiGherkin\Formatter\Example}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\Example
* @group Coverage
* @license MIT
*/
#[CoversClass(Example::class)]
final class ExampleTest extends TestCase
{
/**
* @var Example
*/
private $formatter;
private Example $formatter;

/**
* {@inheritDoc}
*/
public function setUp(): void
{
$this->formatter = new Example();
}

public function testCanGenerateExamplesTableProperly(): void
#[Test]
public function canGenerateExamplesTableProperly(): void
{
$expected = <<<EOS
Examples:
Expand All @@ -67,7 +57,8 @@ public function testCanGenerateExamplesTableProperly(): void
self::assertSame($expected, $this->formatter->format($outlineNode));
}

public function testShouldReturnVoidIfThereIsNoExample()
#[Test]
public function shouldReturnVoidIfThereIsNoExample(): void
{
$outlineNode = new OutlineNode(
'',
Expand Down
22 changes: 6 additions & 16 deletions tests/Formatter/FeatureDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,22 @@

use Behat\Gherkin\Node\FeatureNode;
use KawaiiGherkin\Formatter\FeatureDescription;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \KawaiiGherkin\Formatter\FeatureDescription}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\FeatureDescription
* @group Coverage
* @license MIT
*/
#[CoversClass(FeatureDescription::class)]
final class FeatureDescriptionTest extends TestCase
{
/**
* @var FeatureDescription
*/
private $formatter;
private FeatureDescription $formatter;

/**
* {@inheritDoc}
*/
public function setUp(): void
{
$this->formatter = new FeatureDescription();
}

public function testCanFormatFeatureDescription()
#[Test]
public function canFormatFeatureDescription(): void
{
$expected =<<<EOS
Feature: How to be a kawai person
Expand Down
20 changes: 4 additions & 16 deletions tests/Formatter/ScenarioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,14 @@
use Behat\Gherkin\Node\StepNode;
use Behat\Gherkin\Node\TableNode;
use KawaiiGherkin\Formatter\Scenario;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \KawaiiGherkin\Formatter\Scenario}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\Scenario
* @group Coverage
* @license MIT
*/
#[CoversClass(Scenario::class)]
final class ScenarioTest extends TestCase
{
/**
* @var Scenario
*/
private $formatter;

/**
* {@inheritDoc}
*/
private Scenario $formatter;

public function setUp(): void
{
$this->formatter = new Scenario();
Expand Down
20 changes: 4 additions & 16 deletions tests/Formatter/StepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,14 @@
use Behat\Gherkin\Node\StepNode;
use Behat\Gherkin\Node\TableNode;
use KawaiiGherkin\Formatter\Step;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \KawaiiGherkin\Formatter\Step}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\Step
* @group Coverage
* @license MIT
*/
#[CoversClass(Step::class)]
final class StepTest extends TestCase
{
/**
* @var Step
*/
private $formatter;

/**
* {@inheritDoc}
*/
private Step $formatter;

public function setUp(): void
{
$this->formatter = new Step();
Expand Down
24 changes: 8 additions & 16 deletions tests/Formatter/TagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,24 @@
namespace KawaiiGherkinTest\Formatter;

use KawaiiGherkin\Formatter\Tags;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
* Tests for {@see \KawaiiGherkin\Formatter\Tags}
*
* @author Jefersson Nathan <malukenho@phpse.net>
* @covers \KawaiiGherkin\Formatter\Tags
* @group Coverage
* @license MIT
*/
#[Small]
#[CoversClass(Tags::class)]
final class TagsTest extends TestCase
{
/**
* @var Tags
*/
private $formatter;
private Tags $formatter;

/**
* {@inheritDoc}
*/
public function setUp(): void
{
$this->formatter = new Tags();
}

public function testCanFormatTag()
#[Test]
public function canFormatTag(): void
{
$wrongTagsInput = [
' user ',
Expand Down

0 comments on commit 5142eec

Please sign in to comment.