mcrypt_cbc_error.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test mcrypt_cbc() function : error conditions
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("mcrypt")) {
  6. print "skip - mcrypt extension not loaded";
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : string mcrypt_cbc(int cipher, string key, string data, int mode, string iv)
  12. * Description: CBC crypt/decrypt data using key key with cipher cipher starting with iv
  13. * Source code: ext/mcrypt/mcrypt.c
  14. * Alias to functions:
  15. */
  16. echo "*** Testing mcrypt_cbc() : error conditions ***\n";
  17. //Test mcrypt_cbc with one more than the expected number of arguments
  18. echo "\n-- Testing mcrypt_cbc() function with more than expected no. of arguments --\n";
  19. $cipher = 10;
  20. $key = 'string_val';
  21. $data = 'string_val';
  22. $mode = 10;
  23. $iv = 'string_val';
  24. $extra_arg = 10;
  25. var_dump( mcrypt_cbc($cipher, $key, $data, $mode, $iv, $extra_arg) );
  26. // Testing mcrypt_cbc with one less than the expected number of arguments
  27. echo "\n-- Testing mcrypt_cbc() function with less than expected no. of arguments --\n";
  28. $cipher = 10;
  29. $key = 'string_val';
  30. $data = 'string_val';
  31. var_dump( mcrypt_cbc($cipher, $key, $data) );
  32. ?>
  33. ===DONE===
  34. --EXPECTF--
  35. *** Testing mcrypt_cbc() : error conditions ***
  36. -- Testing mcrypt_cbc() function with more than expected no. of arguments --
  37. Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
  38. Warning: mcrypt_cbc() expects at most 5 parameters, 6 given in %s on line %d
  39. NULL
  40. -- Testing mcrypt_cbc() function with less than expected no. of arguments --
  41. Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
  42. Warning: mcrypt_cbc() expects at least 4 parameters, 3 given in %s on line %d
  43. NULL
  44. ===DONE===