Skip to content

tests #260

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 21 commits into from
Mar 11, 2025
Merged

tests #260

merged 21 commits into from
Mar 11, 2025

Conversation

samdark
Copy link
Member

@samdark samdark commented Mar 10, 2025

Q A
Is bugfix?
New feature?
Breaks BC?

samdark and others added 12 commits March 6, 2025 02:39
diff --git c/tests/Column/Base/RendererContainerTest.php i/tests/Column/Base/RendererContainerTest.php
index 7f4408a..bb06371 100644
--- c/tests/Column/Base/RendererContainerTest.php
+++ i/tests/Column/Base/RendererContainerTest.php
@@ -6,6 +6,7 @@ namespace Yiisoft\Yii\DataView\Tests\Column\Base;

 use PHPUnit\Framework\TestCase;
 use Psr\Container\ContainerInterface;
+use RuntimeException;
 use Yiisoft\Yii\DataView\Column\Base\RendererContainer;
 use Yiisoft\Yii\DataView\Tests\Support\TestRenderer;

@@ -15,20 +16,19 @@ use Yiisoft\Yii\DataView\Tests\Support\TestRenderer;
 final class RendererContainerTest extends TestCase
 {
     private TestRenderer $renderer;
-    private ContainerInterface $container;
     private RendererContainer $rendererContainer;

     protected function setUp(): void
     {
         $this->renderer = new TestRenderer();
-        $this->container = $this->createMock(ContainerInterface::class);
-        $this->container
+        $container = $this->createMock(ContainerInterface::class);
+        $container
             ->method('get')
             ->willReturnCallback(fn(string $class) => match ($class) {
                 TestRenderer::class => $this->renderer,
-                default => throw new \RuntimeException("Unexpected class: $class"),
+                default => throw new RuntimeException("Unexpected class: $class"),
             });
-        $this->rendererContainer = new RendererContainer($this->container);
+        $this->rendererContainer = new RendererContainer($container);
     }

     public function testGetCreatesNewInstance(): void
@@ -50,6 +50,7 @@ final class RendererContainerTest extends TestCase
             TestRenderer::class => ['value' => 'custom'],
         ]);

+        /** @var TestRenderer $instance */
         $instance = $container->get(TestRenderer::class);
         $this->assertSame('custom', $instance->getValue());
     }
@@ -60,8 +61,10 @@ final class RendererContainerTest extends TestCase
             ->addConfigs([TestRenderer::class => ['value' => 'first']])
             ->addConfigs([TestRenderer::class => ['option' => 'second']]);

+        /** @var TestRenderer $instance */
         $instance = $container->get(TestRenderer::class);
         $this->assertSame('first', $instance->getValue());
         $this->assertSame('second', $instance->getOption());
     }
 }
+
diff --git c/tests/Column/DataColumnRendererTest.php i/tests/Column/DataColumnRendererTest.php
index f3a2765..45d54d9 100644
--- c/tests/Column/DataColumnRendererTest.php
+++ i/tests/Column/DataColumnRendererTest.php
@@ -4,12 +4,14 @@ declare(strict_types=1);

 namespace Yiisoft\Yii\DataView\Tests\Column;

+use DateTime;
 use PHPUnit\Framework\TestCase;
 use Psr\Container\ContainerInterface;
 use Yiisoft\Data\Reader\Iterable\IterableDataReader;
 use Yiisoft\Data\Reader\Sort;
 use Yiisoft\Di\Container;
 use Yiisoft\Di\ContainerConfig;
+use Yiisoft\Validator\Result;
 use Yiisoft\Validator\Validator;
 use Yiisoft\Yii\DataView\Column\Base\Cell;
 use Yiisoft\Yii\DataView\Column\Base\DataContext;
@@ -19,10 +21,12 @@ use Yiisoft\Yii\DataView\Column\Base\FilterContext;
 use Yiisoft\Yii\DataView\Column\Base\MakeFilterContext;
 use Yiisoft\Yii\DataView\Column\DataColumn;
 use Yiisoft\Yii\DataView\Column\DataColumnRenderer;
+use Yiisoft\Yii\DataView\Filter\Factory\LikeFilterFactory;
 use Yiisoft\Yii\DataView\Tests\Support\Mock;
 use Yiisoft\Yii\DataView\Tests\Support\TestTrait;
 use Yiisoft\Yii\DataView\UrlConfig;
 use Yiisoft\Validator\Rule\Number;
+use Yiisoft\Yii\DataView\UrlParameterProviderInterface;

 final class DataColumnRendererTest extends TestCase
 {
@@ -178,7 +182,7 @@ final class DataColumnRendererTest extends TestCase

     public function testRenderBodyWithDateTime(): void
     {
-        $date = new \DateTime('2025-03-06 02:00:22');
+        $date = new DateTime('2025-03-06 02:00:22');
         $column = new DataColumn('created_at', dateTimeFormat: 'Y-m-d');
         $cell = new Cell();
         $data = ['id' => 1, 'created_at' => $date];
@@ -236,7 +240,7 @@ final class DataColumnRendererTest extends TestCase
         );
         $cell = new Cell();

-        $urlParameterProvider = new class () implements \Yiisoft\Yii\DataView\UrlParameterProviderInterface {
+        $urlParameterProvider = new class () implements UrlParameterProviderInterface {
             public function get(string $name, int $type): ?string
             {
                 return 'active';
@@ -245,7 +249,7 @@ final class DataColumnRendererTest extends TestCase

         $context = new FilterContext(
             'filter-form',
-            new \Yiisoft\Validator\Result(),
+            new Result(),
             'invalid',
             ['class' => 'error-container'],
             $urlParameterProvider
@@ -268,10 +272,10 @@ final class DataColumnRendererTest extends TestCase
     {
         $column = new DataColumn(
             'name',
-            filterFactory: \Yiisoft\Yii\DataView\Filter\Factory\LikeFilterFactory::class
+            filterFactory: LikeFilterFactory::class
         );

-        $urlParameterProvider = new class () implements \Yiisoft\Yii\DataView\UrlParameterProviderInterface {
+        $urlParameterProvider = new class () implements UrlParameterProviderInterface {
             public function get(string $name, int $type): ?string
             {
                 return match ($name) {
@@ -284,7 +288,7 @@ final class DataColumnRendererTest extends TestCase
         };

         $context = new MakeFilterContext(
-            new \Yiisoft\Validator\Result(),
+            new Result(),
             $urlParameterProvider
         );

@@ -304,7 +308,7 @@ final class DataColumnRendererTest extends TestCase
             filterValidation: [new Number()]
         );

-        $urlParameterProvider = new class () implements \Yiisoft\Yii\DataView\UrlParameterProviderInterface {
+        $urlParameterProvider = new class () implements UrlParameterProviderInterface {
             public function get(string $name, int $type): ?string
             {
                 return match ($name) {
@@ -317,7 +321,7 @@ final class DataColumnRendererTest extends TestCase
         };

         $context = new MakeFilterContext(
-            new \Yiisoft\Validator\Result(),
+            new Result(),
             $urlParameterProvider
         );

@@ -338,7 +342,7 @@ final class DataColumnRendererTest extends TestCase
             filterEmpty: true
         );

-        $urlParameterProvider = new class () implements \Yiisoft\Yii\DataView\UrlParameterProviderInterface {
+        $urlParameterProvider = new class () implements UrlParameterProviderInterface {
             public function get(string $name, int $type): ?string
             {
                 return match ($name) {
@@ -351,7 +355,7 @@ final class DataColumnRendererTest extends TestCase
         };

         $context = new MakeFilterContext(
-            new \Yiisoft\Validator\Result(),
+            new Result(),
             $urlParameterProvider
         );
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.43%. Comparing base (5a09ab1) to head (4ba5a8e).
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #260      +/-   ##
============================================
+ Coverage     82.89%   84.43%   +1.54%     
+ Complexity      624      621       -3     
============================================
  Files            51       51              
  Lines          2110     2114       +4     
============================================
+ Hits           1749     1785      +36     
+ Misses          361      329      -32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samdark samdark marked this pull request as ready for review March 11, 2025 22:16
@samdark samdark merged commit 3a01c9a into master Mar 11, 2025
20 checks passed
@samdark samdark deleted the test3 branch March 11, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants