public function testMysqlFunc() { $table = TestHelper::fetchProperty($this->change, 'mysqlTable'); foreach ($table as $name => $dummy) { $this->assertHasSpot($name . '();'); } }
public function test() { $this->assertNotSpot('never_emit_spot();'); $this->assertHasSpot('clearstatcache();'); $this->assertHasSpot('realpath();'); $this->assertHasSpot('gd_info();'); $table = TestHelper::fetchProperty($this->change, 'arrFuncTable'); foreach ($table as $name => $dummy) { $this->assertHasSpot($name . '();'); } }
public function testFunc() { // Not-new $this->assertNotSpot('not_new();'); $table = TestHelper::fetchProperty($this->change, 'funcTable'); foreach ($table as $name => $dummy) { // Normal name $this->assertHasSpot(sprintf('%s();', $name)); // Case Insensitive name $this->assertHasSpot(sprintf('%s();', strtoupper($name))); } }
public function test() { $table = TestHelper::fetchProperty($this->change, 'funcTable'); foreach ($table as $name => $dummy) { $this->assertHasSpot($name . '("salsa10");'); $this->assertHasSpot($name . '("salsa20");'); $this->assertNotSpot($name . '("md5");'); // Uncertain $this->assertHasSpot($name . '($a);'); // Emtpy $this->assertNotSpot($name . '();'); } }
public function test() { // Function $table = TestHelper::fetchProperty($this->change, 'autoGlobals'); foreach ($table as $name => $dummy) { $this->assertHasSpot(sprintf('function f($%s) {}', $name)); $this->assertHasSpot(sprintf('class Cl { function f($%s) {} }', $name)); $this->assertHasSpot(sprintf('function f($a, $b, $c, $%s) {}', $name)); $this->assertHasSpot(sprintf('class Cl { function f($a, $b, $c, $%s) {} }', $name)); } // Method $this->assertHasSpot('class Cl { public function me($this) {} }'); $this->assertNotSpot('class Cl { public static function me($this) {} }'); }
public function testVar() { // Not-new $code = '$not_removed;'; $this->assertNotSpot($code); $table = TestHelper::fetchProperty($this->change, 'varTable'); if (is_null($table)) { return; } foreach ($table as $name => $dummy) { $code = '$' . $name . ';'; $this->assertHasSpot($code); } }
public function test() { $words = []; $table = TestHelper::fetchProperty($this->change, 'forbiddenTable'); foreach ($table as $name => $dummy) { $words[] = $name; } $table = TestHelper::fetchProperty($this->change, 'reservedTable'); foreach ($table as $name => $dummy) { $words[] = $name; } $this->assertNotSpot('class not_keyword {}'); $this->assertNotSpot('trait not_keyword {}'); $this->assertNotSpot('interface not_keyword {}'); $this->assertNotSpot('$o = new class {};'); foreach ($words as $word) { $this->assertHasSpot('class ' . $word . ' {}'); $this->assertHasSpot('trait ' . $word . ' {}'); $this->assertHasSpot('interface ' . $word . ' {}'); $this->assertHasSpot('namespace Dummy; class ' . $word . ' {}'); $this->assertHasSpot('namespace Dummy; trait ' . $word . ' {}'); $this->assertHasSpot('namespace Dummy; interface ' . $word . ' {}'); } }
public function assertNotSpot($code) { $spots = TestHelper::runChange($this->change, $code); $this->assertEmpty($spots); }
public function testNewConst() { // Not-new $code = $this->genDefine('NOTNEW'); $this->assertNotSpot($code); $table = TestHelper::fetchProperty($this->change, 'constTable'); foreach ($table as $name => $dummy) { // Normal name $code = $this->genDefine($name); $this->assertHasSpot($code); // Case Insensitive name $code = $this->genDefine(strtolower($name)); $this->assertNotSpot($code); } // #Issue 7: First argument not a string $this->assertNotSpot('define(DUMMY, 0);'); $this->assertNotSpot('define(123, 0);'); $this->assertNotSpot('define($dummy, 0);'); }