Improve code coverage for String
authorwidmogrod <widmogrod@gmail.com>
Thu, 21 Dec 2017 21:12:06 +0000 (22:12 +0100)
committerwidmogrod <widmogrod@gmail.com>
Thu, 21 Dec 2017 21:12:06 +0000 (22:12 +0100)
test/Primitive/StringgTest.php

index e3a28cd..c76a22f 100644 (file)
@@ -3,9 +3,10 @@
 namespace test\Widmogrod\Primitive;
 
 use Widmogrod\FantasyLand\Monoid;
+use Widmogrod\Functional as f;
 use Widmogrod\Helpful\MonoidLaws;
+use Widmogrod\Primitive\Product;
 use Widmogrod\Primitive\Stringg;
-use Widmogrod\Functional as f;
 
 class StringgTest extends \PHPUnit\Framework\TestCase
 {
@@ -22,6 +23,16 @@ class StringgTest extends \PHPUnit\Framework\TestCase
         );
     }
 
+    /**
+     * @expectedException \Widmogrod\Primitive\TypeMismatchError
+     * @expectedExceptionMessage Expected type is Widmogrod\Primitive\Stringg but given Widmogrod\Primitive\Product
+     * @dataProvider provideRandomizedData
+     */
+    public function test_it_should_reject_concat_on_different_type(Stringg $a)
+    {
+        $a->concat(Product::of(1));
+    }
+
     private function randomize()
     {
         return Stringg::of(md5(random_int(0, 100)));