Skip to content

Commit

Permalink
Naming (review)
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Sep 15, 2023
1 parent e2cedc0 commit d4e394f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
42 changes: 21 additions & 21 deletions tests/Common/AssignmentsStorageTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ trait AssignmentsStorageTestTrait
protected function setUp(): void
{
$this->populateItemsStorage();
$this->populateStorage();
$this->populateAssignmentsStorage();
}

protected function tearDown(): void
{
$this->getItemsStorage()->clear();
$this->getStorage()->clear();
$this->getAssignmentsStorage()->clear();
}

public function testHasItem(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();

$this->assertTrue($storage->hasItem('Accountant'));
}

public function testRenameItem(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->renameItem('Accountant', 'Senior accountant');

$this->assertFalse($storage->hasItem('Accountant'));
Expand All @@ -48,7 +48,7 @@ public function testRenameItem(): void

public function testGetAll(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$all = $storage->getAll();

$this->assertCount(3, $all);
Expand All @@ -62,7 +62,7 @@ public function testGetAll(): void

public function testRemoveByItemName(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->removeByItemName('Manager');

$this->assertFalse($storage->hasItem('Manager'));
Expand All @@ -72,7 +72,7 @@ public function testRemoveByItemName(): void

public function testGetByUserId(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$assignments = $storage->getByUserId('john');

$this->assertCount(3, $assignments);
Expand All @@ -99,7 +99,7 @@ public function dataGetByItemNames(): array
*/
public function testGetByItemNames(array $itemNames, array $expectedAssignments): void
{
$assignments = $this->getStorage()->getByItemNames($itemNames);
$assignments = $this->getAssignmentsStorage()->getByItemNames($itemNames);
$this->assertCount(count($expectedAssignments), $assignments);

$assignmentFound = false;
Expand All @@ -121,7 +121,7 @@ public function testGetByItemNames(array $itemNames, array $expectedAssignments)

public function testRemoveByUserId(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->removeByUserId('jack');

$this->assertEmpty($storage->getByUserId('jack'));
Expand All @@ -130,7 +130,7 @@ public function testRemoveByUserId(): void

public function testRemove(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->remove('Accountant', 'john');

$this->assertEmpty($storage->get('Accountant', 'john'));
Expand All @@ -139,15 +139,15 @@ public function testRemove(): void

public function testClear(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->clear();

$this->assertEmpty($storage->getAll());
}

public function testGet(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$assignment = $storage->get('Manager', 'jack');

$this->assertSame('Manager', $assignment->getItemName());
Expand All @@ -157,7 +157,7 @@ public function testGet(): void

public function testGetNonExisting(): void
{
$this->assertNull($this->getStorage()->get('Researcher', 'jeff'));
$this->assertNull($this->getAssignmentsStorage()->get('Researcher', 'jeff'));
}

public function dataExists(): array
Expand All @@ -176,7 +176,7 @@ public function dataExists(): array
*/
public function testExists(string $itemName, string $userId, bool $expectedExists): void
{
$this->assertSame($expectedExists, $this->getStorage()->exists($itemName, $userId));
$this->assertSame($expectedExists, $this->getAssignmentsStorage()->exists($itemName, $userId));
}

public function dataUserHasItem(): array
Expand All @@ -196,12 +196,12 @@ public function dataUserHasItem(): array
*/
public function testUserHasItem(string $userId, array $itemNames, bool $expectedUserHasItem): void
{
$this->assertSame($expectedUserHasItem, $this->getStorage()->userHasItem($userId, $itemNames));
$this->assertSame($expectedUserHasItem, $this->getAssignmentsStorage()->userHasItem($userId, $itemNames));
}

public function testAdd(): void
{
$storage = $this->getStorage();
$storage = $this->getAssignmentsStorage();
$storage->add('Operator', 'john');

$this->assertInstanceOf(Assignment::class, $storage->get('Operator', 'john'));
Expand Down Expand Up @@ -261,10 +261,10 @@ protected function populateItemsStorage(): void
}
}

protected function populateStorage(): void
protected function populateAssignmentsStorage(): void
{
foreach ($this->getFixtures()['assignments'] as $assignmentData) {
$this->getStorage()->add($assignmentData['itemName'], $assignmentData['userId']);
$this->getAssignmentsStorage()->add($assignmentData['itemName'], $assignmentData['userId']);
}
}

Expand All @@ -277,10 +277,10 @@ protected function getItemsStorage(): ItemsStorageInterface
return $this->itemsStorage;
}

protected function getStorage(): AssignmentsStorageInterface
protected function getAssignmentsStorage(): AssignmentsStorageInterface
{
if ($this->storage === null) {
$this->storage = $this->createStorage();
$this->storage = $this->createAssignmentsStorage();
}

return $this->storage;
Expand All @@ -291,7 +291,7 @@ protected function createItemsStorage(): ItemsStorageInterface
return new FakeItemsStorage();
}

protected function createStorage(): AssignmentsStorageInterface
protected function createAssignmentsStorage(): AssignmentsStorageInterface
{
return new FakeAssignmentsStorage();
}
Expand Down
Loading

0 comments on commit d4e394f

Please sign in to comment.