PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 19, 2022

[FIXED] What is use of "expect_file()" function in Codeception?

 March 19, 2022     codeception, php, phpunit, yii, yii2     No comments   

Issue

Hi i am new to codeception unit testing and i am using it with Yii2. I know the user of functions expect_not() and expect_that() and also know little about expect() function and uses it to check key in error array.

However I don't know the use of expect_file(). I searched little in internet but found not any good help. can anyone please give me little description about the use of this function.


Solution

expect_file() is used to verify with assertions specific to file system objects. It has two parameters (one is optional).

If you call this function with a single parameter, it will be used as the Subject Under Test file name. if it is called with two parameters, will be used as a description to display if the assertion fails but if you if you call it with 0 or more than two arguments it will throw a bad method call exceptions.

You can use it like this

expect_file('filename.txt')->exists();
expect_file('filename.txt')->notExists();

BTW expect_file() is an alternate function for verify_file().



Answered By - Asfandyar Khan
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing