Skip to content

Commit

Permalink
chore(tests): update test files
Browse files Browse the repository at this point in the history
- Update assertions in ConcreteMagicTest.php
- Update queries in ConcreteScoresTest.php
- Update assertions in HasOptionsTest.php
- Update skip messages in HasSoarBinaryTest.php
- Update assertions in WithDumpableTest.php
- Update assertions in WithRunableTest.php
- Update skip messages in WithRunableTest.php
- Update skip messages in Pest.php
- Update skip messages in SoarTest.php
  • Loading branch information
guanguans committed Jan 16, 2024
1 parent 742c017 commit 83fcd74
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 22 deletions.
8 changes: 4 additions & 4 deletions tests/Concerns/ConcreteMagicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
it('can serialize and unserialize', function (): void {
expect(unserialize(serialize(Soar::create(require __DIR__.'/../../examples/soar.options.full.php'))))
->toBeInstanceOf(Soar::class)
->getSoarBinary()->not->toBeEmpty()
->getOptions()->not->toBeEmpty();
->getSoarBinary()->toBeTruthy()
->getOptions()->toBeTruthy();
})->group(__DIR__, __FILE__);

it('can export soar code block and eval it', function (): void {
Expand All @@ -36,6 +36,6 @@
})()
)
->toBeInstanceOf(Soar::class)
->getSoarBinary()->not->toBeEmpty()
->getOptions()->not->toBeEmpty();
->getSoarBinary()->toBeTruthy()
->getOptions()->toBeTruthy();
})->group(__DIR__, __FILE__);
4 changes: 2 additions & 2 deletions tests/Concerns/ConcreteScoresTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/** @noinspection AnonymousFunctionStaticInspection */
/** @noinspection DebugFunctionUsageInspection */
/** @noinspection ForgottenDebugOutputInspection */
/** @noinspection PhpInternalEntityUsedInspection */
/** @noinspection AnonymousFunctionStaticInspection */
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection SqlNoDataSourceInspection */
/** @noinspection SqlResolve */
Expand All @@ -26,7 +26,7 @@
it('can get array scores', function (): void {
$sqls = <<<'sqls'
SELECT * FROM `post` WHERE `name`='so"a`r';
SELECT DATE_FORMAT (t.last_update,'%Y-%m-%d'),COUNT (DISTINCT (t.city)) FROM city t WHERE t.last_update> '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city='eip' GROUP BY DATE_FORMAT(t.last_update,'%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update,'%Y-%m-%d');
SELECT DATE_FORMAT(t.last_update,'%Y-%m-%d'), COUNT(DISTINCT(t.city)) FROM city t WHERE t.last_update> '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city='eip' GROUP BY DATE_FORMAT(t.last_update,'%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update,'%Y-%m-%d');
DELETE city FROM city LEFT JOIN country ON city.country_id=country.country_id WHERE country.country IS NULL;
Expand Down
2 changes: 1 addition & 1 deletion tests/Concerns/HasOptionsTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/** @noinspection NullPointerExceptionInspection */
/** @noinspection AnonymousFunctionStaticInspection */
/** @noinspection NullPointerExceptionInspection */
/** @noinspection StaticClosureCanBeUsedInspection */

declare(strict_types=1);
Expand Down
2 changes: 1 addition & 1 deletion tests/Concerns/HasSoarBinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
test::double(OS::class, $originals);
})
->group(__DIR__, __FILE__)
->skip('This test is skipped.');
->skip('This test is skipped. Because is not supported in github actions.');

it('will throw InvalidArgumentException when set invalid binary', function (): void {
Soar::create()->setSoarBinary('soar.path');
Expand Down
12 changes: 4 additions & 8 deletions tests/Concerns/WithDumpableTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection UnnecessaryAssertionInspection */
/** @noinspection StaticClosureCanBeUsedInspection */
/** @noinspection UnnecessaryAssertionInspection */

declare(strict_types=1);

Expand All @@ -16,14 +16,10 @@

use Guanguans\SoarPHP\Soar;

it('can dump self and additional params', function (): void {
expect(Soar::create(['foo' => 'bar']))
->dump('foo')
->toBeInstanceOf(Soar::class);
it('can dump self with additional params', function (): void {
expect(Soar::create(['foo' => 'bar']))->dump('foo')->toBeInstanceOf(Soar::class);

$mockObject = $this->getFunctionMock(class_namespace(Soar::class), 'class_exists');
$mockObject->expects($this->any())->willReturn(false);
expect(Soar::create(['foo' => 'bar']))
->dump('foo')
->toBeInstanceOf(Soar::class);
expect(Soar::create(['foo' => 'bar']))->dump('foo')->toBeInstanceOf(Soar::class);
})->group(__DIR__, __FILE__);
8 changes: 4 additions & 4 deletions tests/Concerns/WithRunableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
use Guanguans\SoarPHP\Soar;
use Symfony\Component\Process\Process;

it('will throw InvalidArgumentException when options is boolean', function (): void {
it('will throw InvalidArgumentException when with-options is boolean', function (): void {
Soar::create()->run(true);
})
->group(__DIR__, __FILE__)
->throws(InvalidArgumentException::class, \gettype(true));

it('will throw ProcessFailedException when sqls is invalid sql', function (): void {
Soar::create()->setOnlySyntaxCheck(true)->setQuery('optionsOfError')->run();
Soar::create()->setOnlySyntaxCheck(true)->setQuery('invalid sql')->run();
})
->group(__DIR__, __FILE__)
->throws(ProcessFailedException::class, 'optionsOfError');
->throws(ProcessFailedException::class, 'invalid sql');

it('will throw ProcessFailedException when sudo password is empty', function (): void {
foreach ([
Expand All @@ -55,7 +55,7 @@ protected function shouldApplySudoPassword(): bool
ProcessFailedException::class,
'Password:Sorry, try again * sudo: no password was provided * sudo: 1 incorrect password attempt'
)
->skip('This test is skipped. Because run sudo command is not allowed in github actions.');
->skip('This test is skipped. Because is not supported in github actions.');

it('can run soar process with tapper', function (): void {
expect(Soar::create())
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/** @noinspection PhpInternalEntityUsedInspection */
/** @noinspection AnonymousFunctionStaticInspection */
/** @noinspection DuplicateCustomExpectationInspection */
/** @noinspection PhpInternalEntityUsedInspection */
/** @noinspection StaticClosureCanBeUsedInspection */

declare(strict_types=1);
Expand Down
2 changes: 1 addition & 1 deletion tests/SoarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
expect(Soar::create())->help()->toContain('-version');
})
->group(__DIR__, __FILE__)
->skip(OS::isWindows(), 'The method of help is not supported on windows.');
->skip(OS::isWindows(), 'This test is skipped. Because is not supported in windows.');

it('can get version', function (): void {
expect(Soar::create())->version()->toContain(
Expand Down

0 comments on commit 83fcd74

Please sign in to comment.