1--TEST-- 2TokenList: toggle 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = DOM\XMLDocument::createFromString('<root class="A B C"/>'); 9$element = $dom->documentElement; 10$list = $element->classList; 11 12echo "--- Toggle A (forced add) ---\n"; 13 14var_dump($list->toggle("A", true)); 15 16echo $dom->saveXML(), "\n"; 17 18echo "--- Toggle A (not forced) ---\n"; 19 20var_dump($list->toggle("A")); 21 22echo $dom->saveXML(), "\n"; 23 24echo "--- Toggle A (forced remove) ---\n"; 25 26var_dump($list->toggle("A", false)); 27 28echo $dom->saveXML(), "\n"; 29 30echo "--- Toggle B (forced remove) ---\n"; 31 32var_dump($list->toggle("B", false)); 33 34echo $dom->saveXML(), "\n"; 35 36echo "--- Toggle D ---\n"; 37 38var_dump($list->toggle("D")); 39 40echo $dom->saveXML(), "\n"; 41 42echo "--- Toggle C ---\n"; 43 44var_dump($list->toggle("C")); 45 46echo $dom->saveXML(), "\n"; 47 48echo "--- Toggle E ---\n"; 49 50$list->value = 'E'; 51$list->toggle('E'); 52 53echo $dom->saveXML(), "\n"; 54 55?> 56--EXPECT-- 57--- Toggle A (forced add) --- 58bool(true) 59<?xml version="1.0" encoding="UTF-8"?> 60<root class="A B C"/> 61--- Toggle A (not forced) --- 62bool(false) 63<?xml version="1.0" encoding="UTF-8"?> 64<root class="B C"/> 65--- Toggle A (forced remove) --- 66bool(false) 67<?xml version="1.0" encoding="UTF-8"?> 68<root class="B C"/> 69--- Toggle B (forced remove) --- 70bool(false) 71<?xml version="1.0" encoding="UTF-8"?> 72<root class="C"/> 73--- Toggle D --- 74bool(true) 75<?xml version="1.0" encoding="UTF-8"?> 76<root class="C D"/> 77--- Toggle C --- 78bool(false) 79<?xml version="1.0" encoding="UTF-8"?> 80<root class="D"/> 81--- Toggle E --- 82<?xml version="1.0" encoding="UTF-8"?> 83<root class=""/> 84