Failed tests after installing EcomDev_PHPUnit - magento

For setting up EcomDev_PHPUnit, I installed PHPUnit and relevant modules via PEAR and when I ran "phpunit" for a magento instance, out of 32 tests, 14 were failures and all the failed tests have a similar pattern. Any clues on how to fix this would be helpful.
=== Example 1:
EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Resource_Script::testGetVersionScriptsDiff with data set "to_1.0.5_one_invalid" ('directory_one_invalid', 'scheme', NULL, '1.0.5')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
## ##
Array (
'expected' => Array (
0 => 'install-1.0.0.php'
1 => 'upgrade-1.0.0-1.0.1.php'
2 => 'upgrade-1.0.1-1.0.5.php'
0 => 'install-1.0.5.php' ) 'actual' => Array (
0 => 'upgrade-1.0.0-1.0.1.php' ) )
=== Example 2
EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Resource_Script::testParseVersions with data set "directory_one_invalid" ('directory_one_invalid')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
## ##
Array (
'scheme' => Array (
'install' => Array ()
'upgrade' => Array (
0 => Array (...) ) ) 'data' => Array (...) )
=== Example 3:
EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Resource_Script::testGetVersionScriptsDiff with data set "from_1.0.0_one" ('directory_one_valid', 'scheme', '1.0.0', NULL)
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
## ##
Array (
'expected' => Array (
0 => 'install-1.0.0.php'
- 1 => 'upgrade-1.0.0-1.0.1.php'
)
'actual' => Array (
- 0 => 'install-1.0.0.php'
- 1 => 'upgrade-1.0.0-1.0.1.php'
)
)

Related

How do i know notification send to firebase or not

i want to send notification to specific android device with laravel-firebase . currently i am following this "brozot/laravel-fcm" so when Sending a Downstream Message to a Device , how do i know notification is send or not . when i test it in my postman it returns
LaravelFCM\Response\DownstreamResponse Object
(
[numberTokensSuccess:protected] => 0
[numberTokensFailure:protected] => 1
[numberTokenModify:protected] => 0
[messageId:protected] =>
[tokensToDelete:protected] => Array
(
[0] => .....
)
[tokensToModify:protected] => Array
(
)
[tokensToRetry:protected] => Array
(
)
[tokensWithError:protected] => Array
(
)
[hasMissingToken:protected] =>
[tokens:LaravelFCM\Response\DownstreamResponse:private] => Array
(
[0] => .....
)
[logEnabled:protected] =>
)
You can see in the response how many messages succeeded or failed. From your own output above:
[numberTokensSuccess:protected] => 0
[numberTokensFailure:protected] => 1
It looks like you tried to send a message to one device, and it failed.

Echo from foreach

i have model that return
return array(
'senin'=> $senin->result(),
'selasa'=> $selasa->result(),
'rabu'=> $rabu->result()
);
and controller
$data['ot'] = $this->genbamodel->getOt();
in my view, i use 'foreach $ot as key' and when i tried to print_r($key) the result like this
Array()
Array ( [0] => stdClass Object ( [id_genba] => 1 [hari] => Tuesday [shift1] => 2 [shift2] => 0 ))
Array ( [0] => stdClass Object ( [id_genba] => 1 [hari] => Wednesday [shift1] => 1 [shift2] => 2 ))
how to get just shift1 = 2 and shift2 = 0 (from second array / hari=>Tuesday ??
Thankyou
I don't think you need the foreach loop to access those values. To get just the second record, you can do the below.
$ot['selasa'][0]->shift1
$ot['selasa'][0]->shift2
$ot['selasa'][0]->hari

PHP read array declaration from file?

I've got a text file with an array declaration (actually an array of arrays) that I'm reading into my PHP using 'file_get_contents'. The PHP code is treating the contents that it reads from the file as a literal string, rather than creating an array. I need to actually create the array.
Example:
The file 'probe2.csv' contains the following text:
array(array(22, 296), array(43, 667), array(64, 1008), array(84, 1273), array(105, 1520), array(126, 1899), array(146, 2149))
My PHP is:
$s1 = array(array(22, 256), array(43, 524), array(64, 797), array(84, 1133), array(105, 1515), array(126, 1813), array(146, 2128));
$s2 = file_get_contents('probe2.csv');
print_r($s1);
echo "<p>";
print_r($s2);
echo "</p>";
The output is:
Array ( [0] => Array ( [0] => 22 [1] => 256 ) [1] => Array ( [0] => 43 [1] => 524 ) [2] => Array ( [0] => 64 [1] => 797 ) [3] => Array ( [0] => 84 [1] => 1133 ) [4] => Array ( [0] => 105 [1] => 1515 ) [5] => Array ( [0] => 126 [1] => 1813 ) [6] => Array ( [0] => 146 [1] => 2128 ) )
array(array(22, 296), array(43, 667), array(64, 1008), array(84, 1273), array(105, 1520), array(126, 1899), array(146, 2149))
I'm a bash guy, not a PHP guy, so I have no idea how to do this.
To make it work, you should you need to change it like this:
<?php
$s2 = array(array(22, 296), array(43, 667), array(64, 1008), array(84, 1273), array(105, 1520), array(126, 1899), array(146, 2149));
And then, in you main php file, just include it:
include('probe2.php');
If you have no control about the probe2 file, you can do this (it's bad practice, but works):
$temp = file_get_contents('probe2.csv');
eval('$s2 = ' . $temp . ';');
$s2 will have the right array from here.

Magento custom shippment method

I wrote shippment module with checking a lot of resources/tutorials etc. I am using magento 1.9. Source of module is:
https://github.com/aleextra/magentoshipping
I lost full day to find why it doesn't works fine. Magento see my module, when I am adding at Model/Carrier.php at line 52 code:
die($result);
it shows objec dump:
Mage_Shipping_Model_Rate_Result Object
(
[_rates:protected] => Array
(
[0] => Mage_Shipping_Model_Rate_Result_Method Object
(
[_data:protected] => Array
(
[carrier] => mikshipping
[carrier_title] => Mik Carrier
[method] => fixed
[method_title] => Fixed price 10
[price] => 10
[cost] => 10.00
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
[_error:protected] =>
)
What I am doing wrong?
As a quick guess I say that your carriers name in the config.xml (mshipping) does not match the code used in Carrier.php (mikshipping). I have them always being the same so Iḿ not absolutely sure if this might cause the issue, but it is easy to check.

Magento - How to set media gallery images programmatically?

I try to set a new magento product image e.g. che_3.png with:
$visibility = array (
'thumbnail',
'small_image',
'image'
);
$product->addImageToMediaGallery( $file, $visibility, true, false);
The product image is moved from the
temporary directory: /media/tmp/catalog/product/upload/sessionid/original/che_3.png
to the
destination directory: /media/catalog/product/c/h/che_3.png
Now, if i want to call the image filepath - that is saved by magento - is wrong. The media_gallery object looks like this:
[media_gallery] => Array
(
[images] => Array
(
[0] => Array
(
[value_id] => 89
[file] => /c/h/che_3_2_1.png //che_3.svg is already in here
[label] =>
[position] => 1
[disabled] => 0
[label_default] =>
[position_default] => 1
[disabled_default] => 0
)
[1] => Array // why this second item?
(
[value_id] => 88
[file] => /c/h/che_3_2.png
[label] =>
[position] => 1
[disabled] => 0
[label_default] =>
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
As you can see the filename is extended by magento and also two items are added to the media_gallery.
My question is how can I reset the product respectively the internal counter so magento is using the original file as it is?
Thanks in advance.
Problem solved: I've saved the product twice with $product->save() and it seems $product->addImageToMediaGallery() is also executed twice.

Resources