Skip to content

Commit

Permalink
update tests for new namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Apr 19, 2021
1 parent a83e2be commit 535ad36
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"php": "^7.4 || ^8.0",
"ext-mbstring": "*",
"cypresslab/php-curry": "^0.5.0",
"mallardduck/immutable-read-file": "^0.5.2"
"mallardduck/immutable-read-file": "^0.5.3"
},
"require-dev": {
"ext-json": "*",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\Verraes\\Parsica\\": "tests/"
"Tests\\Parsica\\Parsica\\": "tests/"
}
},
"scripts": {
Expand Down
24 changes: 24 additions & 0 deletions src/PHPUnit/ParserAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Exception;
use Parsica\Parsica\Parser;
use Parsica\Parsica\Stream;
use Parsica\Parsica\StringStream;

/**
Expand Down Expand Up @@ -46,6 +47,29 @@ protected function assertParses(string $input, Parser $parser, $expectedOutput,
}
}

/**
* @psalm-param mixed $expectedOutput
*
* @api
*/
protected function assertParsesStream(Stream $input, Parser $parser, $expectedOutput, string $message = ""): void
{
$actualResult = $parser->run($input);
if ($actualResult->isSuccess()) {
$this->assertStrictlyEquals(
$expectedOutput,
$actualResult->output(),
$message . "\n" . "The parser succeeded but the output doesn't match your expected output."
);
} else {
$this->fail(
$message . "\n"
."The parser failed with the following error message:\n"
.$actualResult->errorMessage()."\n"
);
}
}

/**
* Behaves like assertSame for primitives, behaves like assertEquals for objects of the same type, and fails
* for everything else.
Expand Down
8 changes: 4 additions & 4 deletions src/TextFileStream.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php declare(strict_types=1);

namespace Verraes\Parsica;
namespace Parsica\Parsica;

use InvalidArgumentException;
use MallardDuck\ImmutableReadFile\ImmutableFile;
use Verraes\Parsica\Internal\EndOfStream;
use Verraes\Parsica\Internal\Position;
use Verraes\Parsica\Internal\TakeResult;
use Parsica\Parsica\Internal\EndOfStream;
use Parsica\Parsica\Internal\Position;
use Parsica\Parsica\Internal\TakeResult;

/**
* @psalm-external-mutation-free
Expand Down
2 changes: 1 addition & 1 deletion tests/Examples/ExcelClasses.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Verraes\Parsica\Examples;
namespace Tests\Parsica\Parsica\Examples;

class Cell
{
Expand Down
10 changes: 5 additions & 5 deletions tests/Examples/ExcelTextFileStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* file that was distributed with this source code.
*/

namespace Tests\Verraes\Parsica\Examples;
namespace Tests\Parsica\Parsica\Examples;

use PHPUnit\Framework\TestCase;
use Verraes\Parsica\Parser;
use Verraes\Parsica\PHPUnit\ParserAssertions;
use Verraes\Parsica\TextFileStream;
use function Verraes\Parsica\{alphaChar, between, char, collect, digitChar, skipHSpace1, space, string};
use Parsica\Parsica\Parser;
use Parsica\Parsica\PHPUnit\ParserAssertions;
use Parsica\Parsica\TextFileStream;
use function Parsica\Parsica\{alphaChar, between, char, collect, digitChar, skipHSpace1, space, string};

final class ExcelTextFileStreamTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Internal/TextFileStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
* file that was distributed with this source code.
*/

namespace Tests\Verraes\Parsica\Internal;
namespace Tests\Parsica\Parsica\Internal;

use PHPUnit\Framework\TestCase;
use Verraes\Parsica\Internal\Position;
use Verraes\Parsica\TextFileStream;
use Parsica\Parsica\Internal\Position;
use Parsica\Parsica\TextFileStream;

final class TextFileStreamTest extends TestCase
{
Expand Down

0 comments on commit 535ad36

Please sign in to comment.