Server IP : 127.0.0.2 / Your IP : 52.14.154.79 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/sebastian/recursion-context/tests/ |
Upload File : |
<?php /* * This file is part of the Recursion Context package. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\RecursionContext; use PHPUnit_Framework_TestCase; /** * @covers SebastianBergmann\RecursionContext\Context */ class ContextTest extends PHPUnit_Framework_TestCase { /** * @var \SebastianBergmann\RecursionContext\Context */ private $context; protected function setUp() { $this->context = new Context(); } public function failsProvider() { return array( array(true), array(false), array(null), array('string'), array(1), array(1.5), array(fopen('php://memory', 'r')) ); } public function valuesProvider() { $obj2 = new \stdClass(); $obj2->foo = 'bar'; $obj3 = (object) array(1,2,"Test\r\n",4,5,6,7,8); $obj = new \stdClass(); //@codingStandardsIgnoreStart $obj->null = null; //@codingStandardsIgnoreEnd $obj->boolean = true; $obj->integer = 1; $obj->double = 1.2; $obj->string = '1'; $obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"; $obj->object = $obj2; $obj->objectagain = $obj2; $obj->array = array('foo' => 'bar'); $obj->array2 = array(1,2,3,4,5,6); $obj->array3 = array($obj, $obj2, $obj3); $obj->self = $obj; $storage = new \SplObjectStorage(); $storage->attach($obj2); $storage->foo = $obj2; return array( array($obj, spl_object_hash($obj)), array($obj2, spl_object_hash($obj2)), array($obj3, spl_object_hash($obj3)), array($storage, spl_object_hash($storage)), array($obj->array, 0), array($obj->array2, 0), array($obj->array3, 0) ); } /** * @covers SebastianBergmann\RecursionContext\Context::add * @uses SebastianBergmann\RecursionContext\InvalidArgumentException * @dataProvider failsProvider */ public function testAddFails($value) { $this->setExpectedException( 'SebastianBergmann\\RecursionContext\\Exception', 'Only arrays and objects are supported' ); $this->context->add($value); } /** * @covers SebastianBergmann\RecursionContext\Context::contains * @uses SebastianBergmann\RecursionContext\InvalidArgumentException * @dataProvider failsProvider */ public function testContainsFails($value) { $this->setExpectedException( 'SebastianBergmann\\RecursionContext\\Exception', 'Only arrays and objects are supported' ); $this->context->contains($value); } /** * @covers SebastianBergmann\RecursionContext\Context::add * @dataProvider valuesProvider */ public function testAdd($value, $key) { $this->assertEquals($key, $this->context->add($value)); // Test we get the same key on subsequent adds $this->assertEquals($key, $this->context->add($value)); } /** * @covers SebastianBergmann\RecursionContext\Context::contains * @uses SebastianBergmann\RecursionContext\Context::add * @depends testAdd * @dataProvider valuesProvider */ public function testContainsFound($value, $key) { $this->context->add($value); $this->assertEquals($key, $this->context->contains($value)); // Test we get the same key on subsequent calls $this->assertEquals($key, $this->context->contains($value)); } /** * @covers SebastianBergmann\RecursionContext\Context::contains * @dataProvider valuesProvider */ public function testContainsNotFound($value) { $this->assertFalse($this->context->contains($value)); } }