Closed kop closed 10 years ago
Hello. I have the following test class:
class ValidatorTest extends \Codeception\TestCase\Test { use \Codeception\Specify; /** * @var \mb\tools\url\Validator $instance ; */ public $instance; /** * @var \UnitTester */ protected $tester; /** * @inheritdoc */ protected function _before() { $this->instance = new \mb\tools\url\Validator(); $this->assertInstanceOf('\mb\tools\url\Validator', $this->instance); } /** * @covers \mb\tools\url\Validator::url */ public function testUrl() { $dataDir = \Codeception\Configuration::dataDir(); $urlSamples = include("{$dataDir}/url_samples.php"); var_dump($this->instance->validSchemes); $this->specify('check URLs with invalid scheme if $validSchemes property is set', function ($testData) { $this->instance->validSchemes = ['https', 'ftps']; verify($this->instance->url($testData))->false(); }, ['examples' => $urlSamples['restrictedScheme']]); var_dump($this->instance->validSchemes); die; } }
The results are:
array(2) { [0] => string(4) "http" [1] => string(5) "https" } array(2) { [0] => string(5) "https" [1] => string(4) "ftps" }
Means that $this->instance class attribute has been changed. What am I doing wrong?
$this->instance
For now, I was able to workaround this with help of
$this->beforeSpecify(function() { $this->instance = new \mb\tools\url\Validator(); });
But it doesn't looks like correct solution.
Fixed in https://github.com/Codeception/Specify/commit/f040e2e54b74155c5c699d880b6f400febf299f6
Hello. I have the following test class:
The results are:
Means that
$this->instance
class attribute has been changed. What am I doing wrong?For now, I was able to workaround this with help of
But it doesn't looks like correct solution.