| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Axstrad library. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Dan Kempster <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @copyright 2014-2015 Dan Kempster <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace Axstrad\Component\Content\Tests\Functional; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Axstrad\Component\Content\Entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Axstrad\Component\Content\Exception\InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Axstrad\Component\Content\Introduction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Axstrad\Component\Content\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Axstrad\Component\Content\Tests\Stubs\Traits\CopyBasedIntroductionTraitStub; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Axstrad\Component\Content\Tests\Stubs\Traits\IntroductionTraitStub; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * Axstrad\Component\Content\Tests\Functional\SatisfiesIntroductionInterfaceTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @author Dan Kempster <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @license MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @package Axstrad/Content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @subpackage Tests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @group functional | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | class SatisfiesIntroductionInterfaceTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     public function fixtureProvider() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             // Traits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             [new IntroductionTraitStub()], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             [new CopyBasedIntroductionTraitStub()], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             // Model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             [new Model\ArticleIntroduction], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             // Doctrine/ORM | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             [new Entity\ArticleIntroduction], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function classNameProvider() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             // Model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             ['Axstrad\Component\Content\Model\ArticleIntroduction'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             // Doctrine/ORM | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             ['Axstrad\Component\Content\Entity\ArticleIntroduction'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @dataProvider classNAmeProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public function testImplementsIntroductionInterface($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $this->assertTrue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             is_a($fixture, 'Axstrad\Component\Content\Introduction', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 '%s doesn\'t implement the %s interface', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 $fixture, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                 'Axstrad\Component\Content\Introduction' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |     public function testIntroductionIsNullToStart($fixture) | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         $this->assertNull( | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |             $fixture->getIntroduction() | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     public function testCanSetIntroduction($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $fixture->setIntroduction('An introduction.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             'An introduction.', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             $fixture->getIntroduction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     public function testSetIntroductionReturnsSelf($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $this->assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             $fixture, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             $fixture->setIntroduction('foo') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     public function testIntroductionIsTypeCastToString($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $fixture->setIntroduction(1.1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $this->assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             '1.1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             $fixture->getIntroduction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function testIntroductionCanBeSetToNull($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $fixture->setIntroduction('My Introduction'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $fixture->setIntroduction(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $this->assertNull( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             $fixture->getIntroduction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * @dataProvider fixtureProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @expectedException InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * @param Introduction $fixture | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     public function testSetIntroductionThrowsExceptionIfArgumentIsNotScalar($fixture) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $fixture->setIntroduction($this); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 154 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 155 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: