Files
michaelschiemer/tests/Unit/Framework/Svg/Builder/SvgBuilderTest.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

137 lines
3.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Framework\Core\ValueObjects\Dimensions;
use App\Framework\Svg\Builder\SvgBuilder;
use App\Framework\Svg\ValueObjects\Geometry\Position;
use App\Framework\Svg\ValueObjects\Geometry\Radius;
use App\Framework\Svg\ValueObjects\Styling\Fill;
use App\Framework\Svg\ValueObjects\Styling\SvgColor;
test('can create basic canvas', function () {
$canvas = SvgBuilder::create(100, 100);
expect($canvas)->toBeInstanceOf(\App\Framework\Svg\Builder\SvgCanvas::class)
->and($canvas->count())->toBe(0);
});
test('can create square canvas', function () {
$canvas = SvgBuilder::square(50);
$svg = $canvas->toSvg();
expect($svg)->toContain('width="50"')
->and($svg)->toContain('height="50"');
});
test('can create responsive canvas with viewBox', function () {
$canvas = SvgBuilder::responsive(800, 600);
$svg = $canvas->toSvg();
expect($svg)->toContain('viewBox="0.00 0.00 800.00 600.00"');
});
test('can add rectangle to canvas', function () {
$canvas = SvgBuilder::create(200, 200);
$canvas->rect(
new Position(10, 10),
new Dimensions(50, 30),
Fill::solid(SvgColor::blue())
);
expect($canvas->count())->toBe(1)
->and($canvas->toSvg())->toContain('<rect');
});
test('can add circle to canvas', function () {
$canvas = SvgBuilder::create(200, 200);
$canvas->circle(
new Position(100, 100),
new Radius(50),
Fill::solid(SvgColor::red())
);
expect($canvas->count())->toBe(1)
->and($canvas->toSvg())->toContain('<circle');
});
test('can add text to canvas', function () {
$canvas = SvgBuilder::create(200, 200);
$canvas->text(
'Hello SVG',
new Position(100, 100),
\App\Framework\Svg\ValueObjects\Text\TextStyle::default()
);
expect($canvas->count())->toBe(1)
->and($canvas->toSvg())->toContain('Hello SVG');
});
test('can add multiple elements', function () {
$canvas = SvgBuilder::create(200, 200);
$canvas->rect(
new Position(0, 0),
new Dimensions(200, 200),
Fill::solid(SvgColor::white())
)->circle(
new Position(100, 100),
new Radius(50),
Fill::solid(SvgColor::blue())
);
expect($canvas->count())->toBe(2);
});
test('can clear canvas', function () {
$canvas = SvgBuilder::create(200, 200);
$canvas->circle(
new Position(100, 100),
new Radius(50),
Fill::solid(SvgColor::red())
);
expect($canvas->count())->toBe(1);
$canvas->clear();
expect($canvas->count())->toBe(0);
});
test('generates valid SVG with XML declaration', function () {
$canvas = SvgBuilder::create(100, 100);
$svg = $canvas->toSvg();
expect($svg)->toStartWith('<?xml version="1.0" encoding="UTF-8"?>')
->and($svg)->toContain('<svg')
->and($svg)->toContain('xmlns="http://www.w3.org/2000/svg"')
->and($svg)->toEndWith('</svg>');
});
test('can generate inline SVG without XML declaration', function () {
$canvas = SvgBuilder::create(100, 100);
$svg = $canvas->toInlineSvg();
expect($svg)->not->toContain('<?xml')
->and($svg)->toStartWith('<svg');
});
test('can add title and description for accessibility', function () {
$canvas = SvgBuilder::create(100, 100)
->withTitle('Test Chart')
->withDescription('A test SVG chart');
$svg = $canvas->toSvg();
expect($svg)->toContain('<title>Test Chart</title>')
->and($svg)->toContain('<desc>A test SVG chart</desc>');
});