-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest-covers.php
More file actions
67 lines (52 loc) · 1.89 KB
/
test-covers.php
File metadata and controls
67 lines (52 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require __DIR__ . '/vendor/autoload.php';
use App\Helpers\ModernCoverGenerator;
// Mock post object
class MockPost {
public $title;
public $tags;
public $date;
public function __construct($title, $tags, $date) {
$this->title = $title;
$this->tags = $tags;
$this->date = new DateTime($date);
}
public function getDate() {
return $this->date;
}
public function getFilename() {
return str_replace(' ', '-', strtolower($this->title));
}
}
// Create test posts
$posts = [
new MockPost('How to make faker uses multiple locales with Laravel model factories', ['php', 'laravel'], '2022-05-04'),
new MockPost('Hello World', ['general'], '2021-12-14'),
new MockPost('How to implement translations and routes into Inertia and Laravel', ['php', 'laravel'], '2022-04-18'),
];
$generator = new ModernCoverGenerator();
$destination = __DIR__;
echo "Generating test covers...\n\n";
foreach ($posts as $post) {
echo "Generating: {$post->title}\n";
echo " Tags: " . implode(', ', $post->tags) . "\n";
echo " Date: {$post->date->format('Y-m-d')}\n";
// Debug: Show composite seed calculation
$tagString = implode(',', $post->tags);
$dateString = $post->date->format('Y-m-d');
$compositeString = $post->title . $tagString . $dateString;
$compositeSeed = crc32($compositeString);
echo " Composite String: '$compositeString'\n";
echo " Composite Seed: $compositeSeed\n";
echo " Day of Year: {$post->date->format('z')}\n";
$shift = ((int)$post->date->format('z') % 30) - 15;
echo " Color Shift: $shift\n";
$result = $generator->generate($post, $destination);
if ($result) {
echo " ✓ Generated: assets/images/covers/{$post->getFilename()}.png\n";
} else {
echo " ✗ Failed to generate\n";
}
echo "\n";
}
echo "Done! Check assets/images/covers/ folder\n";