Skip to content

Instantly share code, notes, and snippets.

View yoeriboven's full-sized avatar
👋
Check out my blog!

Yoeri Boven yoeriboven

👋
Check out my blog!
View GitHub Profile
@yoeriboven
yoeriboven / WithStatamicEntryFaking.php
Created April 28, 2022 15:19
Write your Laravel Statamic tests with this trait. More info: https://yoeri.me/blog/testing-your-statamic-implementation
<?php
namespace Tests;
use Exception;
use Statamic\Facades\User;
use Statamic\Stache\Stache;
use Statamic\Entries\Entry;
trait WithStatamicEntryFaking
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewLayoutAttributes *currentItemAttributes = [super layoutAttributesForItemAtIndexPath:indexPath];
CGFloat topInset = [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:indexPath.section].top;
// First row should be aligned at the top
if (indexPath.item < self.numColumns){
currentItemAttributes.frame = ({
CGRect frame = currentItemAttributes.frame;
frame.origin.y = topInset + 0;