[Phpmyadmin-devel] Refactoring: Displaying query results

Chanaka Dharmarathna pe.chanaka.ck at gmail.com
Sat Jul 14 12:55:47 CEST 2012


>
>>>> > These days I'm having problems with improving the test cases.
>>>> > It's not a good idea to run all the tests after improve test for each
>>>> > function since it takes much time.
>>>> > As well I can't run tests individually without errors again and again.
>>>> > (File not found, undefined constant,  undefined variable)
>>>> > I cannot find that my tests are correct or not.Chanaka
>>>>
>>>> First of all the tests should run standalone as well as part of
>>>> testsuite. I see lot of tests fail in both modes, so maybe that's the
>>>> reason why it fails for you?
>>>>
>>>> > Please suggest me some way to get rid of this problem.
>>>> > Its very helpful if you can give one example for fixing a failing
>>>> test in
>>>> > PMA_DisplayResults_test.php
>>>>
>>>> Fix the tests and code to work together :-).
>>>>
>>>
>>> Okay I'll try again Michal
>>>
>>
>> Hi Michal,
>>
>> I managed to run only needed tests by modifying phpunit.xml.dist file.
>> And now Its no need to wait till all tests are running.
>>
>> The problem for the errors in PMA_DisplayResults_test.php tests is not
>> properly set the properties of PMA_DisplayResults class.
>> So that, I get following two types of errors :
>> 1. Trying to get property of non-object  -   $fields_meta[0]->table
>> 2. Invalid argument supplied for foreach()  -  foreach
>> ($vertical_display[$operation] as $val)
>>
>> I try to set those parameters by calling setProperties() method.
>> As I found, the conditions inside __set and __get method are not
>> satisfying.
>>
>> That is,
>> if (property_exists($this, $property))
>>
>> But if I print the object at testing time, it shows me the properties are
>> actually there itself.
>> I am confusing about this.
>> Do you have any idea or suggestion for this ?
>>
>> Hi Michal,
>
> I just found that, property_exists method cannot detect properties in
> magic method __get, from the manual [0].
> I'll try with changing the method names.
>
> [0] : http://php.net/manual/en/function.property-exists.php
>

Hi Michal,

I try some modifications in those magic methods in order to fix those tests.
I use an array to store the all properties instead of using separate set of
properties. (I feel Dieter also try to say something like that in a
previous mail)
Now there is no doubt of using magic methods at any place.

I need your suggestion before doing this change.
Following snippet shows what I'm going to do.

// initialize at the top so that any property should include here
private $_properties_array = array('_db'=>null, '_table'=>null, .........);

public function __set($property, $value)
{
    if(array_key_exists($property, $this->_properties_array)) { // check
array key is defined - this is same as check property exist
        $this->_properties_array[$property] = $value;
    }
}

public function __get($property)
{
    if(array_key_exists($property, $this->_properties_array)) {
        return $this->_properties_array[$property];
    }
}

Waiting for your suggestions.

Regards !

*Chanaka*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20120714/f0c3f592/attachment.html>


More information about the Developers mailing list