Skip to content

v0.3.0 - EdgeBinder Interface Enhancement

Choose a tag to compare

@iampersistent iampersistent released this 06 Aug 20:11
· 57 commits to main since this release

EdgeBinder v0.3.0 - Interface Enhancement Release

This release implements the EdgeBinder Interface Enhancement Proposal, significantly improving testability and architectural flexibility while maintaining 100% backward compatibility.

🚀 Major Features

Enhanced Testability

  • Removed final keyword from EdgeBinder and BindingQueryBuilder classes
  • Enable mocking for unit tests and dependency injection
  • Fast unit testing without external dependencies

New Testing Utilities

  • InMemoryEdgeBinder: Complete in-memory implementation for lightning-fast unit tests
  • EdgeBinderTestFactory: Factory class for creating test instances and mocks
  • 24 new comprehensive tests covering all testing utilities

Improved Architecture

  • Dependency Injection Support: Services can now depend on EdgeBinderInterface
  • Extension Support: Enable decorators, wrappers, and custom implementations
  • Framework Integration: Better support for DI containers and frameworks

📊 What's New

Before vs After

Before (Integration Testing Required):

// Slow integration test with real storage
$edgeBinder = new EdgeBinder($weaviateAdapter); // Requires Weaviate running
$service = new RelationshipService($edgeBinder);

After (Fast Unit Testing):

// Lightning-fast unit test
$edgeBinder = EdgeBinderTestFactory::createInMemory(); // Milliseconds, no dependencies
$service = new RelationshipService($edgeBinder);

// Or use mocks for behavior verification
$mock = $this->createMock(EdgeBinderInterface::class);
$mock->expects($this->once())->method('bind');

New Testing Capabilities

use EdgeBinder\Testing\{InMemoryEdgeBinder, EdgeBinderTestFactory};

// Fast in-memory testing
$edgeBinder = new InMemoryEdgeBinder();
$edgeBinder->bind($user, $project, 'has_access');
assert($edgeBinder->getBindingCount() === 1);

// Factory methods
$edgeBinder = EdgeBinderTestFactory::createInMemory();
$edgeBinder = EdgeBinderTestFactory::createWithInMemoryAdapter();

// Pre-populated test data
$edgeBinder = EdgeBinderTestFactory::createWithTestData([
    ['from' => $user, 'to' => $project, 'type' => 'owns']
]);

🔧 Technical Improvements

  • PHPStan Level 8: Maintains strict static analysis with 0 errors
  • Static Return Types: Fixed static return type issues in BindingQueryBuilder
  • Code Quality: Enhanced with targeted PHPStan rules for safe patterns

📈 Test Coverage

  • 246 tests passing (24 new tests added)
  • 694 assertions
  • Comprehensive coverage of all new testing utilities
  • Zero regressions - all existing functionality preserved

🔄 Backward Compatibility

100% backward compatible - no breaking changes:

// Existing code continues to work unchanged
$edgeBinder = new EdgeBinder($adapter);
$edgeBinder->bind($from, $to, 'relationship_type');

// New code can leverage interface benefits
class MyService {
    public function __construct(private EdgeBinderInterface $edgeBinder) {}
}

🎯 Benefits for Developers

Unit Testing

  • 10-100x faster test execution
  • No external dependencies required
  • Isolated test environments
  • Easy setup and teardown

Architecture

  • Dependency injection support
  • Decorator pattern enablement
  • Framework integration improvements
  • Custom implementations possible

Development Experience

  • Faster feedback loops
  • Better IDE support for mocking
  • Cleaner test code
  • Improved maintainability

📦 Installation

composer require edgebinder/edgebinder:^0.3.0

🔗 Framework Integration Examples

Laravel

// AppServiceProvider.php
$this->app->bind(EdgeBinderInterface::class, EdgeBinder::class);

Symfony

# config/services.yaml
services:
    EdgeBinder\Contracts\EdgeBinderInterface:
        alias: EdgeBinder\EdgeBinder

Laminas/Mezzio

// config/dependencies.php
'aliases' => [
    EdgeBinderInterface::class => EdgeBinder::class,
],

🙏 Migration Guide

For Library Authors:

// Recommended: Use interface for flexibility
class MyService {
    public function __construct(EdgeBinderInterface $edgeBinder) {}
}

For Application Developers:
No changes required - existing code continues to work, but you can now write better tests!


Full Changelog: v0.2.0...v0.3.0