Skip to content

Tests: new SettingsAddPathsTest #113

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

Merged
merged 1 commit into from
Apr 5, 2022
Merged
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
64 changes: 64 additions & 0 deletions tests/Unit/SettingsAddPathsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace PHP_Parallel_Lint\PhpParallelLint\Tests\Unit;

use PHP_Parallel_Lint\PhpParallelLint\Settings;
use PHP_Parallel_Lint\PhpParallelLint\Tests\UnitTestCase;

/**
* @covers \PHP_Parallel_Lint\PhpParallelLint\Settings::addPaths
*/
class SettingsAddPathsTest extends UnitTestCase
{
/**
* Test adding additional paths to the paths already in settings.
*
* @dataProvider dataAddPaths
*
* @param array $original The "original" value for $paths as set from the command-line.
* @param array $extra Extra paths to add.
* @param array $expected Expected $paths.
*
* @return void
*/
public function testAddPaths($original, $extra, $expected)
{
$settings = new Settings();
$settings->paths = $original;

$settings->addPaths($extra);

$this->assertSame($expected, $settings->paths);
}

/**
* Data provider.
*
* @return array
*/
public function dataAddPaths()
{
return array(
'No paths passed on CLI, no extra paths' => array(
'original' => array(),
'extra' => array(),
'expected' => array(),
),
'No paths passed on CLI, extra paths' => array(
'original' => array(),
'extra' => array('path/1', 'path/subdir/2'),
'expected' => array('path/1', 'path/subdir/2'),
),
'Paths passed on CLI, no extra paths' => array(
'original' => array('path/1', 'path/subdir/2'),
'extra' => array(),
'expected' => array('path/1', 'path/subdir/2'),
),
'Paths passed on CLI, extra paths, partially duplicate' => array(
'original' => array('path/1', 'path/subdir/2'),
'extra' => array('path/1', 'path/subdir/3'),
'expected' => array('path/1', 'path/subdir/2', 'path/1', 'path/subdir/3'),
),
);
}
}