Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Mar 28, 2024
1 parent 86d4727 commit 1d7a708
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>
<php>
<!-- <env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/> -->
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<source>
<include>
Expand Down
11 changes: 1 addition & 10 deletions tests/Fixture/BlogsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@

class BlogsFixture extends TestFixture
{
public $fields = [
'id' => ['type' => 'integer'],
'is_active' => ['type' => 'boolean', 'default' => true, 'null' => false],
'name' => ['type' => 'string', 'length' => 255, 'null' => false],
'body' => ['type' => 'text', 'null' => false],
'user_id' => ['type' => 'integer'],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

public $records = [
public array $records = [
['name' => '1st post', 'body' => '1st post body', 'user_id' => 1],
['name' => '2nd post', 'body' => '2nd post body', 'user_id' => 1],
['name' => '3rd post', 'body' => '3rd post body', 'user_id' => 1],
Expand Down
10 changes: 6 additions & 4 deletions tests/TestCase/Listener/ViewSearchListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/
class ViewSearchListenerTest extends TestCase
{
protected $fixtures = ['plugin.CrudView.Blogs'];
protected array $fixtures = ['plugin.CrudView.Blogs'];

/**
* @var \Cake\Controller\Controller;
*/
protected $controller;
protected Controller $controller;

/**
* @var \CrudView\Listener\ViewSearchListener
*/
protected $listener;
protected ViewSearchListener $listener;

public function setUp(): void
{
Expand All @@ -39,7 +39,8 @@ public function setUp(): void
'params' => ['controller' => 'Blogs', 'action' => 'index', 'plugin' => null, '_ext' => null],
]);

$this->controller = new Controller($request, null, 'Blogs');
$this->controller = new Controller($request, 'Blogs');
$this->controller->loadComponent('Crud.Crud');

$this->listener = new ViewSearchListener($this->controller);

Expand Down Expand Up @@ -67,6 +68,7 @@ public function testFields()
'data-tags' => 'true',
'data-allow-clear' => 'true',
'data-placeholder' => '',
'empty' => 'Name',
],
'is_active' => [
'required' => false,
Expand Down
16 changes: 16 additions & 0 deletions tests/schema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

return [
[
'table' => 'blogs',
'columns' => [
'id' => ['type' => 'integer'],
'is_active' => ['type' => 'boolean', 'default' => true, 'null' => false],
'name' => ['type' => 'string', 'length' => 255, 'null' => false],
'body' => ['type' => 'text', 'null' => false],
'user_id' => ['type' => 'integer'],
],
'constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
],
];

0 comments on commit 1d7a708

Please sign in to comment.