@@ -258,4 +258,74 @@ public function removeRemovesModel()
258
258
$ numberOfModelsAfterRemove = count ($ this ->subject ->findAll ());
259
259
static ::assertSame (1 , $ numberOfModelsBeforeRemove - $ numberOfModelsAfterRemove );
260
260
}
261
+
262
+ /**
263
+ * @test
264
+ */
265
+ public function findOneBySubscriberListAndSubscriberForNeitherMatchingReturnsNull ()
266
+ {
267
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_TABLE_NAME , __DIR__ . '/../Fixtures/Subscriber.csv ' );
268
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_LIST_TABLE_NAME , __DIR__ . '/../Fixtures/SubscriberList.csv ' );
269
+ $ this ->getDataSet ()->addTable (static ::TABLE_NAME , __DIR__ . '/../Fixtures/Subscription.csv ' );
270
+ $ this ->applyDatabaseChanges ();
271
+
272
+ $ subscriberList = $ this ->subscriberListRepository ->find (3 );
273
+ $ subscriber = $ this ->subscriberRepository ->find (4 );
274
+ $ result = $ this ->subject ->findOneBySubscriberListAndSubscriber ($ subscriberList , $ subscriber );
275
+
276
+ static ::assertNull ($ result );
277
+ }
278
+
279
+ /**
280
+ * @test
281
+ */
282
+ public function findOneBySubscriberListAndSubscriberForMatchingSubscriberListOnlyReturnsNull ()
283
+ {
284
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_TABLE_NAME , __DIR__ . '/../Fixtures/Subscriber.csv ' );
285
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_LIST_TABLE_NAME , __DIR__ . '/../Fixtures/SubscriberList.csv ' );
286
+ $ this ->getDataSet ()->addTable (static ::TABLE_NAME , __DIR__ . '/../Fixtures/Subscription.csv ' );
287
+ $ this ->applyDatabaseChanges ();
288
+
289
+ $ subscriberList = $ this ->subscriberListRepository ->find (2 );
290
+ $ subscriber = $ this ->subscriberRepository ->find (4 );
291
+ $ result = $ this ->subject ->findOneBySubscriberListAndSubscriber ($ subscriberList , $ subscriber );
292
+
293
+ static ::assertNull ($ result );
294
+ }
295
+
296
+ /**
297
+ * @test
298
+ */
299
+ public function findOneBySubscriberListAndSubscriberForMatchingSubscriberOnlyReturnsNull ()
300
+ {
301
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_TABLE_NAME , __DIR__ . '/../Fixtures/Subscriber.csv ' );
302
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_LIST_TABLE_NAME , __DIR__ . '/../Fixtures/SubscriberList.csv ' );
303
+ $ this ->getDataSet ()->addTable (static ::TABLE_NAME , __DIR__ . '/../Fixtures/Subscription.csv ' );
304
+ $ this ->applyDatabaseChanges ();
305
+
306
+ $ subscriberList = $ this ->subscriberListRepository ->find (3 );
307
+ $ subscriber = $ this ->subscriberRepository ->find (1 );
308
+ $ result = $ this ->subject ->findOneBySubscriberListAndSubscriber ($ subscriberList , $ subscriber );
309
+
310
+ static ::assertNull ($ result );
311
+ }
312
+
313
+ /**
314
+ * @test
315
+ */
316
+ public function findOneBySubscriberListAndSubscriberForBothMatchingReturnsMatch ()
317
+ {
318
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_TABLE_NAME , __DIR__ . '/../Fixtures/Subscriber.csv ' );
319
+ $ this ->getDataSet ()->addTable (static ::SUBSCRIBER_LIST_TABLE_NAME , __DIR__ . '/../Fixtures/SubscriberList.csv ' );
320
+ $ this ->getDataSet ()->addTable (static ::TABLE_NAME , __DIR__ . '/../Fixtures/Subscription.csv ' );
321
+ $ this ->applyDatabaseChanges ();
322
+
323
+ $ subscriberList = $ this ->subscriberListRepository ->find (2 );
324
+ $ subscriber = $ this ->subscriberRepository ->find (1 );
325
+ $ result = $ this ->subject ->findOneBySubscriberListAndSubscriber ($ subscriberList , $ subscriber );
326
+
327
+ static ::assertInstanceOf (Subscription::class, $ result );
328
+ static ::assertSame ($ subscriberList , $ result ->getSubscriberList ());
329
+ static ::assertSame ($ subscriber , $ result ->getSubscriber ());
330
+ }
261
331
}
0 commit comments