From 80abcda83146d43ecdd28f63990a256d70af11e0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 8 Aug 2022 19:45:06 +1000 Subject: [PATCH] Working on data matching --- tests/Feature/Bank/YodleeApiTest.php | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/Feature/Bank/YodleeApiTest.php b/tests/Feature/Bank/YodleeApiTest.php index 74ce98f6fc8d..29aff207bc53 100644 --- a/tests/Feature/Bank/YodleeApiTest.php +++ b/tests/Feature/Bank/YodleeApiTest.php @@ -29,6 +29,52 @@ class YodleeApiTest extends TestCase } + public function testDataMatching() + { + + $transaction = collect([ + (object)[ + 'description' => 'tinkertonkton' + ], + (object)[ + 'description' => 'spud' + ], + ]); + + $this->assertEquals(2, $transaction->count()); + + $hit = $transaction->where('description', 'spud')->first(); + + $this->assertNotNull($hit); + + $hit = $transaction->where('description', 'tinkertonkton')->first(); + + $this->assertNotNull($hit); + + $hit = $transaction->contains('description', 'tinkertonkton'); + + $this->assertTrue($hit); + + + $transaction = collect([ + (object)[ + 'description' => 'tinker and spice' + ], + (object)[ + 'description' => 'spud with water' + ], + ]); + + $hit = $transaction->contains('description', 'tinker and spice'); + + $this->assertTrue($hit); + + $transaction->contains(function ($value, $key) { + return str_contains($value->description, 'tinker'); + }); + + } + public function testYodleeInstance() { @@ -435,4 +481,6 @@ class YodleeApiTest extends TestCase + + }