Skip to content

Commit

Permalink
Фикс тестов
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerych1984 committed Feb 1, 2025
1 parent ed6c4ac commit d51c36d
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/Tag/MathML/Mmultiscripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Yiisoft\Html\Tag\Base\NormalTag;

/**
* @link https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mmultiscripts
*/
final class Mmultiscripts extends NormalTag implements MathItemInterface
{
private MathItemInterface $base;

Check failure on line 14 in src/Tag/MathML/Mmultiscripts.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PropertyNotSetInConstructor

src/Tag/MathML/Mmultiscripts.php:14:31: PropertyNotSetInConstructor: Property Yiisoft\Html\Tag\MathML\Mmultiscripts::$base is not defined in constructor of Yiisoft\Html\Tag\MathML\Mmultiscripts or in any private or final methods called in the constructor (see https://psalm.dev/074)

Check failure on line 14 in src/Tag/MathML/Mmultiscripts.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.2-ubuntu-latest

PropertyNotSetInConstructor

src/Tag/MathML/Mmultiscripts.php:14:31: PropertyNotSetInConstructor: Property Yiisoft\Html\Tag\MathML\Mmultiscripts::$base is not defined in constructor of Yiisoft\Html\Tag\MathML\Mmultiscripts or in any private or final methods called in the constructor (see https://psalm.dev/074)

Check failure on line 14 in src/Tag/MathML/Mmultiscripts.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.3-ubuntu-latest

PropertyNotSetInConstructor

src/Tag/MathML/Mmultiscripts.php:14:31: PropertyNotSetInConstructor: Property Yiisoft\Html\Tag\MathML\Mmultiscripts::$base is not defined in constructor of Yiisoft\Html\Tag\MathML\Mmultiscripts or in any private or final methods called in the constructor (see https://psalm.dev/074)
Expand Down Expand Up @@ -49,11 +52,10 @@ public function base(MathItemInterface $base): self
public function post(MathItemInterface $item, MathItemInterface ...$items): self
{
$new = clone $this;
$new->post = [$item];

if ($items) {
$new->post = [...[$item], ...$items];
} else {
$new->post = [$item];
$new->post = [...$new->post, ...$items];
}

return $new;
Expand Down
3 changes: 0 additions & 3 deletions src/Tag/MathML/Mrow.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace Yiisoft\Html\Tag\MathML;

use Override;

/**
* @link https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mrow
*/
final class Mrow extends AbstractMathItems
{
#[Override]
protected function getName(): string
{
return 'mrow';
Expand Down
17 changes: 17 additions & 0 deletions tests/Tag/MathML/MmultiscriptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ public function testSimple(): void
);
}

public function testPost(): void
{
$mmultiscripts = Mmultiscripts::tag()
->base(Mi::tag()->identifier('X'))
->post(
Mi::tag()->identifier('a'),
);

$this->assertSame(
'<mmultiscripts>' . "\n" .
'<mi>X</mi>' . "\n" .
'<mi>a</mi>' . "\n" .
'</mmultiscripts>',
(string) $mmultiscripts
);
}

public function testWithoutPre(): void
{
$mmultiscripts = Mmultiscripts::tag()
Expand Down
18 changes: 18 additions & 0 deletions tests/Tag/MathML/MsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Html\Tests\Tag\MathML;

use PHPUnit\Framework\TestCase;
use Yiisoft\Html\Tag\MathML\Ms;

final class MsTest extends TestCase
{
public function testHelloWorld(): void
{
$ms = Ms::tag()->content('Hello World');

$this->assertSame('<ms>Hello World</ms>', (string) $ms);
}
}
27 changes: 27 additions & 0 deletions tests/Tag/MathML/MsqrtTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Html\Tests\Tag\MathML;

use PHPUnit\Framework\TestCase;
use Yiisoft\Html\Tag\MathML\Mi;
use Yiisoft\Html\Tag\MathML\Msqrt;

final class MsqrtTest extends TestCase
{
public function testSimple(): void
{
$msqrt = Msqrt::tag()
->items(
Mi::tag()->identifier('x'),
);

$this->assertSame(
'<msqrt>' . "\n" .
'<mi>x</mi>' . "\n" .
'</msqrt>',
(string) $msqrt
);
}
}
30 changes: 30 additions & 0 deletions tests/Tag/MathML/MsubTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Html\Tests\Tag\MathML;

use PHPUnit\Framework\TestCase;
use Yiisoft\Html\Tag\MathML\Mi;
use Yiisoft\Html\Tag\MathML\Mn;
use Yiisoft\Html\Tag\MathML\Msub;

final class MsubTest extends TestCase
{
public function testSimple(): void
{
$msub = Msub::tag()
->items(
Mi::tag()->identifier('X'),
Mn::tag()->value(1),
);

$this->assertSame(
'<msub>' . "\n" .
'<mi>X</mi>' . "\n" .
'<mn>1</mn>' . "\n" .
'</msub>',
(string) $msub
);
}
}
32 changes: 32 additions & 0 deletions tests/Tag/MathML/MsubsupTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Html\Tests\Tag\MathML;

use PHPUnit\Framework\TestCase;
use Yiisoft\Html\Tag\MathML\Mn;
use Yiisoft\Html\Tag\MathML\Mo;
use Yiisoft\Html\Tag\MathML\Msubsup;

final class MsubsupTest extends TestCase
{
public function testSimple(): void
{
$msubsup = Msubsup::tag()
->items(
Mo::tag()->operator('&#x222B;'),
Mn::tag()->value(0),
Mn::tag()->value(1),
);

$this->assertSame(
'<msubsup>' . "\n" .
'<mo>&#x222B;</mo>' . "\n" .
'<mn>0</mn>' . "\n" .
'<mn>1</mn>' . "\n" .
'</msubsup>',
(string) $msubsup
);
}
}

0 comments on commit d51c36d

Please sign in to comment.