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('circle( new Position(100, 100), new Radius(50), Fill::solid(SvgColor::red()) ); expect($canvas->count())->toBe(1) ->and($canvas->toSvg())->toContain('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('') ->and($svg)->toContain('and($svg)->toContain('xmlns="http://www.w3.org/2000/svg"') ->and($svg)->toEndWith(''); }); test('can generate inline SVG without XML declaration', function () { $canvas = SvgBuilder::create(100, 100); $svg = $canvas->toInlineSvg(); expect($svg)->not->toContain('and($svg)->toStartWith('withTitle('Test Chart') ->withDescription('A test SVG chart'); $svg = $canvas->toSvg(); expect($svg)->toContain('Test Chart') ->and($svg)->toContain('A test SVG chart'); });