PHPUnit Segmentation fault

后端 未结 13 781
故里飘歌
故里飘歌 2020-12-28 14:56

When a PHPUnit test fails normally on my dev box (Linux Mint), it causes a \"Segmentation Fault\" on my Continous Integration box (Centos). Both machines are running the sam

13条回答
  •  [愿得一人]
    2020-12-28 15:31

    I had the same problem and could nail it down, that I tried to write a class variable which was not definied:

    My class (it's a cakePHP-class) which caused segmentation fault:

    class MyClass extends AppModel {
    
      protected $classVariableOne;
    
      public function __construct($id = false, $table = null, $ds = null) {
        parent::__construct($id, $table, $ds);
    
        $this->classVariableOne =& ClassRegistry::init('ClassVariableOne');
    
        // This line caused the segmentation fault as the variable doesn't exists
        $this->classVariableTwo =& ClassRegistry::init('ClassVariableTwo');
    
      }
    }
    

    I fixed it by adding the second variable:

    class MyClass extends AppModel {
    
      protected $classVariableOne;
      protected $classVariableTwo; // Added this line
    
      public function __construct($id = false, $table = null, $ds = null) {
        parent::__construct($id, $table, $ds);
    
        $this->classVariableOne =& ClassRegistry::init('ClassVariableOne');
        $this->classVariableTwo =& ClassRegistry::init('ClassVariableTwo');
    
      }
    }
    

提交回复
热议问题