44
55namespace unit \Codeception \Module ;
66
7+ use ArrayObject ;
78use Codeception \Lib \ModuleContainer ;
89use Codeception \Module \Asserts ;
910use Codeception \PHPUnit \TestCase ;
@@ -46,6 +47,11 @@ public function testCodeceptionAsserts()
4647
4748 public function testPHPUnitAsserts ()
4849 {
50+ $ closedResource = fopen (__FILE__ , 'r ' );
51+ fclose ($ closedResource );
52+
53+ $ openendResource = fopen (__FILE__ , 'r ' );
54+
4955 $ this ->module ->assertArrayHasKey ('one ' , ['one ' => 1 , 'two ' => 2 ]);
5056 $ this ->module ->assertArrayNotHasKey ('three ' , ['one ' => 1 , 'two ' => 2 ]);
5157 $ this ->module ->assertClassHasAttribute ('foo ' , \Support \Data \DummyClass::class);
@@ -54,8 +60,36 @@ public function testPHPUnitAsserts()
5460 $ this ->module ->assertClassNotHasStaticAttribute ('staticBar ' , \Support \Data \DummyClass::class);
5561 $ this ->module ->assertContains (1 , [1 , 2 ]);
5662 $ this ->module ->assertContainsEquals (2 , [1 , 2 ]);
63+ $ this ->module ->assertContainsNotOnlyArray ([['foo ' ], 'foo ' , ['bar ' ]]);
64+ $ this ->module ->assertContainsNotOnlyBool ([true , false , true , 42 ]);
65+ $ this ->module ->assertContainsNotOnlyCallable ([fn () => 'foo ' , 'bar ' , fn () => 'bar ' ]);
66+ $ this ->module ->assertContainsNotOnlyClosedResource ([$ closedResource , $ openendResource ]);
67+ $ this ->module ->assertContainsNotOnlyFloat ([1.1 , 1.42 , 5 ]);
68+ $ this ->module ->assertContainsNotOnlyInstancesOf (\Support \Data \DummyClass::class, [new \Support \Data \DummyClass (), new stdClass (), new \Support \Data \DummyClass ()]);
69+ $ this ->module ->assertContainsNotOnlyInt ([1 , 42 , 42.1 ]);
70+ $ this ->module ->assertContainsNotOnlyIterable ([['foo ' ], 'bar ' , [new ArrayObject (['foo ' ])]]);
71+ $ this ->module ->assertContainsNotOnlyNull ([null , 42 ]);
72+ $ this ->module ->assertContainsNotOnlyNumeric (['foo ' , 42 ]);
73+ $ this ->module ->assertContainsNotOnlyObject ([new stdClass (), []]);
74+ $ this ->module ->assertContainsNotOnlyResource ([$ openendResource , $ closedResource , 'foo ' ]);
75+ $ this ->module ->assertContainsNotOnlyScalar ([1 , new stdClass ()]);
76+ $ this ->module ->assertContainsNotOnlyString (['foo ' , 42 , 'bar ' ]);
5777 $ this ->module ->assertContainsOnly (\Support \Data \DummyClass::class, [new \Support \Data \DummyClass (), new \Support \Data \DummyClass ()]);
78+ $ this ->module ->assertContainsOnly ('integer ' , [5 , 6 ]);
79+ $ this ->module ->assertContainsOnlyArray ([['foo ' ], ['bar ' ]]);
80+ $ this ->module ->assertContainsOnlyBool ([true , false , true ]);
81+ $ this ->module ->assertContainsOnlyCallable ([fn () => 'foo ' , fn () => 'bar ' ]);
82+ $ this ->module ->assertContainsOnlyClosedResource ([$ closedResource ]);
83+ $ this ->module ->assertContainsOnlyFloat ([1.1 , 1.42 ]);
5884 $ this ->module ->assertContainsOnlyInstancesOf (\Support \Data \DummyClass::class, [new \Support \Data \DummyClass (), new \Support \Data \DummyClass ()]);
85+ $ this ->module ->assertContainsOnlyInt ([1 , 42 ]);
86+ $ this ->module ->assertContainsOnlyIterable ([['foo ' ], [new ArrayObject (['foo ' ])]]);
87+ $ this ->module ->assertContainsOnlyNull ([null , null ]);
88+ $ this ->module ->assertContainsOnlyNumeric (['42.5 ' , 42 ]);
89+ $ this ->module ->assertContainsOnlyObject ([new stdClass (), new ArrayObject (['bar ' ])]);
90+ $ this ->module ->assertContainsOnlyResource ([$ openendResource , $ closedResource ]);
91+ $ this ->module ->assertContainsOnlyScalar ([1 , 'foo ' ]);
92+ $ this ->module ->assertContainsOnlyString (['foo ' , 'bar ' ]);
5993 $ this ->module ->assertCount (3 , [1 , 2 , 3 ]);
6094 $ this ->module ->assertDirectoryDoesNotExist (__DIR__ .'notExist ' );
6195 $ this ->module ->assertDirectoryExists (__DIR__ );
@@ -91,16 +125,13 @@ public function testPHPUnitAsserts()
91125 $ this ->module ->assertIsArray ([1 , 2 , 3 ]);
92126 $ this ->module ->assertIsBool (true );
93127 $ this ->module ->assertIsCallable (function () {});
94- $ closedResource = fopen (__FILE__ , 'r ' );
95- fclose ($ closedResource );
96128 $ this ->module ->assertIsClosedResource ($ closedResource );
97129 $ this ->module ->assertIsFloat (1.2 );
98130 $ this ->module ->assertIsInt (2 );
99131 $ this ->module ->assertIsIterable ([]);
100132 $ this ->module ->assertIsNotArray (false );
101133 $ this ->module ->assertIsNotBool ([1 , 2 , 3 ]);
102134 $ this ->module ->assertIsNotCallable ('test ' );
103- $ openendResource = fopen (__FILE__ , 'r ' );
104135 $ this ->module ->assertIsNotClosedResource ($ openendResource );
105136 $ this ->module ->assertIsNotFloat (false );
106137 $ this ->module ->assertIsNotInt (false );
@@ -133,6 +164,7 @@ public function testPHPUnitAsserts()
133164 $ this ->module ->assertNotContains ('three ' , ['one ' , 'two ' ]);
134165 $ this ->module ->assertNotContainsEquals (3 , [1 , 2 ]);
135166 $ this ->module ->assertNotContainsOnly (\Support \Data \DummyClass::class, [new \Support \Data \DummyClass (), new Exception ()]);
167+ $ this ->module ->assertNotContainsOnly ('integer ' , [1 , 42 , 42.1 ]);
136168 $ this ->module ->assertNotCount (1 , ['one ' , 'two ' ]);
137169 $ this ->module ->assertNotEmpty ([1 ]);
138170 $ this ->module ->assertNotEquals (true , false );
0 commit comments