Skip to content

Commit 89f343a

Browse files
authored
Merge pull request #184 from wayofdev/feat/remove-factories
2 parents cacfdf8 + 1b60ed9 commit 89f343a

File tree

12 files changed

+82
-588
lines changed

12 files changed

+82
-588
lines changed

composer.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,8 @@
5050
"wayofdev/cs-fixer-config": "^1.1"
5151
},
5252
"autoload": {
53-
"files": [
54-
"src/helpers.php"
55-
],
5653
"psr-4": {
57-
"WayOfDev\\Cycle\\": "src/",
58-
"WayOfDev\\Cycle\\Database\\Factories\\": "database/factories/"
54+
"WayOfDev\\Cycle\\": "src/"
5955
}
6056
},
6157
"autoload-dev": {

composer.lock

Lines changed: 69 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bridge/Laravel/Factories/Factory.php

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/Testing/Concerns/InteractsWithDatabase.php

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
namespace WayOfDev\Cycle\Testing\Concerns;
66

77
use Cycle\Database\DatabaseProviderInterface;
8-
use Exception;
98
use PHPUnit\Framework\Constraint\Constraint;
109
use PHPUnit\Framework\Constraint\LogicalNot as ReverseConstraint;
1110
use WayOfDev\Cycle\Testing\Constraints\CountInDatabase;
1211
use WayOfDev\Cycle\Testing\Constraints\HasInDatabase;
13-
use WayOfDev\Cycle\Testing\Constraints\NotSoftDeletedInDatabase;
14-
use WayOfDev\Cycle\Testing\Constraints\SoftDeletedInDatabase;
1512

1613
/**
1714
* @method void assertThat($value, Constraint $constraint, string $message = '')
@@ -27,7 +24,7 @@ trait InteractsWithDatabase
2724
protected function assertDatabaseHas($table, array $data, $connection = null): static
2825
{
2926
$this->assertThat(
30-
$this->getTable($table),
27+
$table,
3128
new HasInDatabase(app(DatabaseProviderInterface::class), $data)
3229
);
3330

@@ -46,7 +43,7 @@ protected function assertDatabaseMissing($table, array $data, $connection = null
4643
new HasInDatabase(app(DatabaseProviderInterface::class), $data)
4744
);
4845

49-
$this->assertThat($this->getTable($table), $constraint);
46+
$this->assertThat($table, $constraint);
5047

5148
return $this;
5249
}
@@ -60,7 +57,7 @@ protected function assertDatabaseMissing($table, array $data, $connection = null
6057
protected function assertDatabaseCount($table, int $count, $connection = null): static
6158
{
6259
$this->assertThat(
63-
$this->getTable($table),
60+
$table,
6461
new CountInDatabase(app(DatabaseProviderInterface::class), $count)
6562
);
6663

@@ -76,64 +73,10 @@ protected function assertDatabaseCount($table, int $count, $connection = null):
7673
protected function assertDatabaseEmpty($table, $connection = null): static
7774
{
7875
$this->assertThat(
79-
$this->getTable($table),
76+
$table,
8077
new CountInDatabase(app(DatabaseProviderInterface::class), 0)
8178
);
8279

8380
return $this;
8481
}
85-
86-
/**
87-
* @param string|object $table
88-
* @param string|null $connection
89-
* @param string|null $deletedAtColumn
90-
*
91-
* @throws Exception
92-
*
93-
* @return $this
94-
*/
95-
protected function assertSoftDeleted($table, array $data = [], $connection = null, $deletedAtColumn = 'deleted_at'): static
96-
{
97-
if ($this->isSoftDeletableModel($table)) {
98-
throw new Exception('Eloquent not supported');
99-
}
100-
101-
$this->assertThat(
102-
$this->getTable($table),
103-
new SoftDeletedInDatabase(app(DatabaseProviderInterface::class), $data, $deletedAtColumn)
104-
);
105-
106-
return $this;
107-
}
108-
109-
/**
110-
* @param string|object $table
111-
* @param string|null $connection
112-
* @param string|null $deletedAtColumn
113-
*
114-
* @throws Exception
115-
*
116-
* @return $this
117-
*/
118-
protected function assertNotSoftDeleted($table, array $data = [], $connection = null, $deletedAtColumn = 'deleted_at'): static
119-
{
120-
if ($this->isSoftDeletableModel($table)) {
121-
throw new Exception('Eloquent not supported');
122-
}
123-
124-
$this->assertThat(
125-
$this->getTable($table),
126-
new NotSoftDeletedInDatabase(app(DatabaseProviderInterface::class), $data, $deletedAtColumn)
127-
);
128-
129-
return $this;
130-
}
131-
132-
/**
133-
* @param string|object $table
134-
*/
135-
protected function getTable($table): string
136-
{
137-
return $table;
138-
}
13982
}

src/Testing/Constraints/CountInDatabase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ public function __construct(DatabaseProviderInterface $database, int $expectedCo
2727
$this->database = $database->database();
2828
}
2929

30-
public function matches(mixed $table): bool
30+
public function matches(mixed $other): bool
3131
{
3232
/** @var Table $tableInterface */
33-
$tableInterface = $this->database->table($table);
33+
$tableInterface = $this->database->table($other);
3434

3535
$this->actualCount = $tableInterface->count();
3636

3737
return $this->actualCount === $this->expectedCount;
3838
}
3939

40-
public function failureDescription(mixed $table): string
40+
public function failureDescription(mixed $other): string
4141
{
4242
return sprintf(
4343
"table [%s] matches expected entries count of %s. Entries found: %s.\n",
44-
$table,
44+
$other,
4545
$this->expectedCount,
4646
$this->actualCount
4747
);

src/Testing/Constraints/HasInDatabase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public function __construct(DatabaseProviderInterface $database, array $data)
2929
$this->database = $database->database();
3030
}
3131

32-
public function matches(mixed $table): bool
32+
public function matches(mixed $other): bool
3333
{
3434
/** @var SelectQuery $tableInterface */
35-
$tableInterface = $this->database->table($table);
35+
$tableInterface = $this->database->table($other);
3636

3737
try {
3838
$count = $tableInterface->where($this->data)->count();
@@ -46,11 +46,11 @@ public function matches(mixed $table): bool
4646
/**
4747
* @throws JsonException
4848
*/
49-
public function failureDescription(mixed $table): string
49+
public function failureDescription(mixed $other): string
5050
{
5151
return sprintf(
5252
'a row in the table [%s] matches the attributes %s.',
53-
$table,
53+
$other,
5454
$this->toString(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
5555
);
5656
}

src/Testing/Constraints/NotSoftDeletedInDatabase.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)