Skip to content

Commit

Permalink
refactor: logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yogyrton committed Dec 25, 2024
1 parent 85b2278 commit f533533
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/Tests/TableTestState.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class TableTestState extends Assert
{
use FixturesTrait;

public bool $globalExportMode;

protected string $tableName;
protected array $jsonFields;
protected ?string $connectionName;
protected bool $globalExportMode;
protected Collection $state;

public function __construct(
Expand Down
14 changes: 7 additions & 7 deletions tests/ModelTestStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public function testInitializationViaPrepareModelTestState()
$datasetMock = collect($this->getJsonFixture('initialization/dataset.json'));
$this->mockGettingDataset($datasetMock);

$mock = $this->getMockBuilder(TestCase::class)
$mock = $this
->getMockBuilder(TestCase::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$reflection = new ReflectionClass($mock);

$this->assertFalse($reflection->getProperty('globalExportMode')->getValue($mock));
$reflection->getMethod('setGlobalExportMode')->invoke($mock);

$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode');
$setGlobalExportMode->invoke($mock);
$prepareModelTestState = $reflection->getMethod('prepareModelTestState')->invoke($mock, TestModel::class);

$prepareModelTestState = $reflection->getMethod('prepareModelTestState');
$prepareModelTestState->invoke($mock, TestModel::class);
$testCaseGlobalExportMode = $reflection->getProperty('globalExportMode')->getValue($mock);

$this->assertTrue($reflection->getProperty('globalExportMode')->getValue($mock));
$this->assertTrue($testCaseGlobalExportMode);
$this->assertEquals($prepareModelTestState->globalExportMode, $testCaseGlobalExportMode);
}

public function testAssertChangesEqualsFixture()
Expand Down
14 changes: 7 additions & 7 deletions tests/TableTestStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public function testInitializationViaPrepareTableTestState()
$datasetMock = collect($this->getJsonFixture('initialization/dataset.json'));
$this->mockGettingDataset($datasetMock);

$mock = $this->getMockBuilder(TestCase::class)
$mock = $this
->getMockBuilder(TestCase::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$reflection = new ReflectionClass($mock);

$this->assertFalse($reflection->getProperty('globalExportMode')->getValue($mock));
$reflection->getMethod('setGlobalExportMode')->invoke($mock);

$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode');
$setGlobalExportMode->invoke($mock);
$prepareTableTestState = $reflection->getMethod('prepareTableTestState')->invoke($mock, 'test_models');

$prepareTableTestState = $reflection->getMethod('prepareTableTestState');
$prepareTableTestState->invoke($mock, 'test_models');
$testCaseGlobalExportMode = $reflection->getProperty('globalExportMode')->getValue($mock);

$this->assertTrue($reflection->getProperty('globalExportMode')->getValue($mock));
$this->assertTrue($testCaseGlobalExportMode);
$this->assertEquals($prepareTableTestState->globalExportMode, $testCaseGlobalExportMode);
}

public function testAssertChangesEqualsFixture()
Expand Down

0 comments on commit f533533

Please sign in to comment.